Created
November 21, 2016 06:35
-
-
Save moinsam/26bc2011562d9da175ee2d4aff7de639 to your computer and use it in GitHub Desktop.
Jenkins Pipeline Build script
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
| node { | |
| def mvnHome | |
| stage('Preparation') { | |
| git url: 'GIT_REPO_URL', branch: 'BRANCH_NAME', credentialsId: 'CREDENTIALS_ID' | |
| mvnHome = tool 'Maven-3.3.9' | |
| } | |
| stage('Build') { | |
| // Run the maven build | |
| if (isUnix()) { | |
| sh "'${mvnHome}/bin/mvn' clean package -DskipTests docker:build" | |
| } else { | |
| bat(/"${mvnHome}\bin\mvn" clean package -DskipTests docker:build/) | |
| } | |
| } | |
| stage('Publish') { | |
| // Push the image | |
| if (isUnix()) { | |
| sh 'eval $(aws ecr get-login --region REGION_NAME)' | |
| sh "'${mvnHome}/bin/mvn' docker:push" | |
| } else { | |
| bat(/"${mvnHome}\bin\mvn" docker:push/) | |
| } | |
| } | |
| } | |
| // we don't need this method now | |
| def version() { | |
| def matcher = readFile('pom.xml') =~ '<version>(.+)</version>' | |
| matcher ? matcher[0][1] : null | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment