-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathJenkinsfile
81 lines (79 loc) · 2.11 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
pipeline {
agent {
label 'master'
}
environment {
TARGET_BRANCH = getTargetBranch()
}
stages {
stage('Build and unit test') {
steps {
build(job: 'crisiscleanup-web-unit',
parameters: [
string(name: 'upstreamBranch', value: "${env.TARGET_BRANCH}")
],
propagate: true,
wait: true)
slackSend(color: "good", message: "UNIT TESTS PASSED: ${env.JOB_NAME} ${env.BUILD_NUMBER} (<${env.BUILD_URL}|Open>)")
}
}
stage('Environments build') {
steps {
build(job: 'crisiscleanup-web-build',
parameters: [
string(name: 'upstreamBranch', value: "${env.TARGET_BRANCH}")
],
propagate: true,
wait: true)
}
}
stage('Functional environment test') {
steps {
build(job: 'crisiscleanup-functional-tests',
parameters: [string(name: 'upstreamBranch', value: "${env.TARGET_BRANCH}")],
propagate: true,
wait: true)
}
}
stage('Deploy pull request to dev and staging') {
when {
branch 'staging'
}
steps {
build(job: 'crisiscleanup-web-deploy',
parameters: [
string(name: 'deployEnv', value: "devstaging")
],
propagate: true,
wait: true)
}
}
stage('Deploy to prod') {
when {
branch 'master'
}
steps {
build(job: 'crisiscleanup-web-deploy',
parameters: [
string(name: 'deployEnv', value: "prod")
],
propagate: true,
wait: true)
}
}
}
post {
success {
slackSend(color: "good", message: "SUCCESS: ${env.JOB_NAME} ${env.BUILD_NUMBER} (<${env.BUILD_URL}|Open>)")
}
failure {
slackSend(color: "danger", message: "FAILED: ${env.JOB_NAME} ${env.BUILD_NUMBER} (<${env.BUILD_URL}|Open>)")
}
unstable {
slackSend(color: "warn", message: "UNSTABLE: ${env.JOB_NAME} ${env.BUILD_NUMBER} (<${env.BUILD_URL}|Open>)")
}
}
}
def getTargetBranch() {
return env.CHANGE_TARGET ? env.CHANGE_TARGET : env.BRANCH_NAME
}