Created
March 14, 2018 18:17
-
-
Save mauriciosilva/081bc67a00c493a7a934333485c71aea to your computer and use it in GitHub Desktop.
multistage-jenkinsfile v2
This file contains 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
##vars/myDeliveryPipeline.groovy | |
def call(Map pipelineParams) { | |
pipeline { | |
agent any | |
stages { | |
stage('checkout git') { | |
steps { | |
git branch: pipelineParams.branch, credentialsId: 'GitCredentials', url: pipelineParams.scmUrl | |
} | |
} | |
stage('build') { | |
steps { | |
sh 'mvn clean package -DskipTests=true' | |
} | |
} | |
stage ('test') { | |
steps { | |
parallel ( | |
"unit tests": { sh 'mvn test' }, | |
"integration tests": { sh 'mvn integration-test' } | |
) | |
} | |
} | |
stage('deploy developmentServer'){ | |
steps { | |
deploy(pipelineParams.developmentServer, pipelineParams.serverPort) | |
} | |
} | |
stage('deploy staging'){ | |
steps { | |
deploy(pipelineParams.stagingServer, pipelineParams.serverPort) | |
} | |
} | |
stage('deploy production'){ | |
steps { | |
deploy(pipelineParams.productionServer, pipelineParams.serverPort) | |
} | |
} | |
} | |
post { | |
failure { | |
mail to: pipelineParams.email, subject: 'Pipeline failed', body: "${env.BUILD_URL}" | |
} | |
} | |
} | |
} | |
## jenkinsfile that invokes shared lib | |
Jenkinsfile | |
myDeliveryPipeline(branch: 'master', scmUrl: 'ssh://git@myScmServer.com/repos/myRepo.git', | |
email: 'team@example.com', serverPort: '8080', | |
developmentServer: 'dev-myproject.mycompany.com', | |
stagingServer: 'staging-myproject.mycompany.com', | |
productionServer: 'production-myproject.mycompany.com') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment