@@ -2,7 +2,7 @@ import groovy.transform.Field
22@Library (' jenkins-pipeline-utils' ) _
33
44@Field
5- def githubCredentialsId = ' 433ac100-b3c2-4519-b4d6-20node7c029a103b '
5+ def GITHUB_CREDENTIALS_ID = ' fa29964d-237e-4ecb-96bc-1350dda63f79 '
66@Field
77def deAnsibleGithubUrl
= ' [email protected] :ca-cwds/de-ansible.git' 88
@@ -13,9 +13,11 @@ def deploy(environment) {
1313 node(environment) {
1414 try {
1515 checkoutStage(environment)
16- deployStage(environment, env. version)
17- updateManifestStage(environment, env. version)
18- testsStage(environment)
16+ rollbackDeployOnFailure(' geo-services-api' , environment, GITHUB_CREDENTIALS_ID , ansibleCommand(environment, env. version)) {
17+ deployStage(environment, env. version)
18+ updateManifestStage(environment, env. version)
19+ testsStage(environment)
20+ }
1921 } catch (Exception e) {
2022 currentBuild. result = ' FAILURE'
2123 throw e
@@ -25,6 +27,10 @@ def deploy(environment) {
2527 }
2628}
2729
30+ def ansibleCommand (environment , version ) {
31+ " ansible-playbook -e NEW_RELIC_AGENT=$env . USE_NEWRELIC -e GEO_API_VERSION=$version -i inventories/$environment /hosts.yml deploy-geo-services-api.yml --vault-password-file ~/.ssh/vault.txt"
32+ }
33+
2834def checkoutStage (environment ) {
2935 stage(" Checkout for $environment " ) {
3036 deleteDir()
@@ -36,16 +42,16 @@ def deployStage(environment, version) {
3642 stage(" Deploy to $environment " ) {
3743 ws {
3844 environmentDashboard(addColumns : false , buildJob : ' ' , buildNumber : version, componentName : ' Geo-Services-API' , data : [], nameOfEnv : environment, packageName : ' Geo-Services-API' ) {
39- git branch : ' master' , credentialsId : githubCredentialsId , url : deAnsibleGithubUrl
40- sh " ansible-playbook -e NEW_RELIC_AGENT= $e nv . USE_NEWRELIC -e GEO_API_VERSION= $v ersion -i inventories/ $ environment /hosts.yml deploy-geo-services-api.yml --vault-password-file ~/.ssh/vault.txt "
45+ git branch : ' master' , credentialsId : GITHUB_CREDENTIALS_ID , url : deAnsibleGithubUrl
46+ sh ansibleCommand( environment, version)
4147 }
4248 }
4349 }
4450}
4551
4652def updateManifestStage (environment , version ) {
4753 stage(" Update Manifest for $environment " ) {
48- updateManifest(' geo-services-api' , environment, githubCredentialsId , version)
54+ updateManifest(' geo-services-api' , environment, GITHUB_CREDENTIALS_ID , version)
4955 }
5056}
5157
0 commit comments