Created
March 19, 2017 15:10
-
-
Save crashbell/d42e6b800e83c94e3ea4ffdb9b363b23 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def servers = ['server1', 'server2'] | |
| def version = "1.0.0-${env.BUILD_ID}" | |
| stage 'Build, UT, IT' | |
| node { | |
| checkout scm | |
| env.PATH = "${tool 'Maven'}/bin:${env.PATH}" | |
| withEnv(["PATH+MAVEN=${tool 'Maven'}/bin"]) { | |
| sh "mvn -e org.codehaus.mojo:versions-maven-plugin:2.1:set -DnewVersion=$version -DgenerateBackupPoms=false" | |
| sh 'mvn -e clean deploy' | |
| sh 'mvn -e scm:tag' | |
| } | |
| } | |
| def nodes = [:] | |
| for (int i = 0; i < servers.size(); i++) { | |
| def server = servers.get(i) | |
| nodes["$server"] = { | |
| stage "Deploy to INT ($server)" | |
| node { | |
| sshagent(['SOME-ID']) { | |
| sh """ | |
| ssh ${server}.example.com <<END | |
| hostname | |
| /apps/stop.sh | |
| yum -y update-to my-app.noarch | |
| /apps/start.sh | |
| END""".stripIndent() | |
| } | |
| } | |
| } | |
| } | |
| parallel nodes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment