Skip to content

Commit fba7ea3

Browse files
Merge pull request #57 from ca-cwds/FIT-586
Add rollback for Geo services api release pipeline
2 parents efd36e0 + 1008f75 commit fba7ea3

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

JenkinsfileDeploy.groovy

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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
77
def 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+
2834
def 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=$env.USE_NEWRELIC -e GEO_API_VERSION=$version -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

4652
def 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

src/main/java/gov/ca/cwds/geo/web/rest/SystemInformationResource.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import org.slf4j.Logger;
2525
import org.slf4j.LoggerFactory;
2626

27-
import com.fasterxml.jackson.databind.ObjectMapper;
2827
import com.google.inject.Inject;
2928

3029
/**
@@ -40,8 +39,6 @@ public class SystemInformationResource extends AbstractSystemInformationResource
4039
private static final String BUILD_NUMBER = "Geo-Services-Api-Build";
4140
private static final String N_A = "N/A";
4241

43-
private static final ObjectMapper MAPPER = new ObjectMapper();
44-
4542
private static final Logger LOGGER = LoggerFactory.getLogger(SystemInformationResource.class);
4643

4744
/**
@@ -89,7 +86,7 @@ private Attributes getManifestProperties() {
8986
try (InputStream input = new URL(archivePath + "/META-INF/MANIFEST.MF").openStream()) {
9087
attributes = new Manifest(input).getMainAttributes();
9188
} catch (Exception e) {
92-
LOGGER.error("Loading properties from MANIFEST failed! {}", e);
89+
LOGGER.error("Loading properties from MANIFEST failed!", e);
9390
}
9491
return attributes;
9592
}

0 commit comments

Comments
 (0)