This repository has been archived by the owner on Aug 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Jenkinsfile
93 lines (79 loc) · 2.97 KB
/
Jenkinsfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!groovy
node {
try {
// Checkout the proper revision into the workspace.
stage('checkout') {
checkout scm
}
env.GIT_COMMIT = sh(returnStdout: true, script: 'git rev-parse --short HEAD').trim()
env.AWS_PROFILE = 'climate'
env.CC_SETTINGS_BUCKET = 'staging-us-east-1-climate-lab-config'
env.CC_SITE_BUCKET = 'staging-us-east-1-climate-lab-site'
// set environment variables for staging or production; default to staging
env.API_HOST = 'https://app.staging.climate.azavea.com';
if (env.BRANCH_NAME == 'master') {
env.API_HOST = 'https://app.climate.azavea.com';
env.CC_SETTINGS_BUCKET = 'production-us-east-1-climate-lab-config'
env.CC_SITE_BUCKET = 'production-us-east-1-climate-lab-site'
}
stage('setup') {
wrap([$class: 'AnsiColorBuildWrapper']) {
sh 'scripts/update'
}
}
stage('test') {
wrap([$class: 'AnsiColorBuildWrapper']) {
sh "aws s3 cp 's3://${env.CC_SETTINGS_BUCKET}/angular/constants.ts' 'src/app/constants.ts'"
sh './scripts/test --jenkins'
step([$class: 'WarningsPublisher',
parserConfigurations: [[
parserName: 'JSLint',
pattern: 'jenkins/violations.xml'
]],
// mark build unstable if there are any linter warnings
unstableTotalAll: '0',
usePreviousBuildAsReference: true
])
}
}
stage('cibuild') {
wrap([$class: 'AnsiColorBuildWrapper']) {
sh './scripts/cibuild'
}
}
// Publish to S3
stage('infra') {
if (env.BRANCH_NAME == 'develop' || env.BRANCH_NAME == 'master') {
wrap([$class: 'AnsiColorBuildWrapper']) {
sh 'docker-compose -f docker-compose.ci.yml run --rm terraform ./scripts/infra plan'
sh 'docker-compose -f docker-compose.ci.yml run --rm terraform ./scripts/infra apply'
}
}
}
// if got this far, build must not have failed
def slackMessage = ":jenkins: *climate-change-lab (${env.BRANCH_NAME}) #${env.BUILD_NUMBER}*"
if (env.CHANGE_TITLE) {
slackMessage += "\n${env.CHANGE_TITLE} - ${env.CHANGE_AUTHOR}"
}
slackMessage += "\n<${env.BUILD_URL}|View Build>"
slackSend color: 'good', channel: '#doe-climate-change', message: slackMessage
} catch (err) {
// Some exception was raised in the `try` block above. Assemble
// an appropirate error message for Slack.
def slackMessage = ":jenkins-angry: *climate-change-lab (${env.BRANCH_NAME}) #${env.BUILD_NUMBER}*"
if (env.CHANGE_TITLE) {
slackMessage += "\n${env.CHANGE_TITLE} - ${env.CHANGE_AUTHOR}"
}
slackMessage += "\n<${env.BUILD_URL}|View Build>"
slackSend color: 'danger', channel: '#doe-climate-change', message: slackMessage
// Re-raise the exception so that the failure is propagated to
// Jenkins.
throw err
} finally {
stage('cleanup') {
wrap([$class: 'AnsiColorBuildWrapper']) {
sh 'docker-compose down -v'
}
}
}
}