-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
52 lines (43 loc) · 1.37 KB
/
Jenkinsfile
File metadata and controls
52 lines (43 loc) · 1.37 KB
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
#!groovy
ansiColor('xterm') {
node('executor') {
checkout scm
def authorName = sh(returnStdout: true, script: 'git --no-pager show --format="%an" --no-patch')
def isMain = env.BRANCH_NAME == "main"
def serviceName = env.JOB_NAME.tokenize("/")[1]
def commitHash = sh(returnStdout: true, script: 'git rev-parse HEAD | cut -c-7').trim()
def imageTag = "${env.BUILD_NUMBER}-${commitHash}"
try {
stage("Run Tests") {
try {
sh "IMAGE_TAG=${imageTag} make test-ci"
} finally {
sh "make docker-clean"
}
}
stage("Package") {
try {
sh "IMAGE_TAG=${imageTag} make package"
} finally {
sh "make clean"
}
}
if(isMain) {
stage ('Build and Push') {
sh "IMAGE_TAG=${imageTag} make publish"
}
stage("Deploy") {
build job: "service-deploy/pennsieve-non-prod/us-east-1/dev-vpc-use1/dev/${serviceName}",
parameters: [
string(name: 'IMAGE_TAG', value: imageTag),
string(name: 'TERRAFORM_ACTION', value: 'apply')
]
}
}
} catch (e) {
slackSend(color: '#b20000', message: "FAILED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]' (${env.BUILD_URL}) by ${authorName}")
throw e
}
slackSend(color: '#006600', message: "SUCCESSFUL: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]' (${env.BUILD_URL}) by ${authorName}")
}
}