-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
133 lines (133 loc) · 3.83 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
pipeline {
agent none
options {
skipDefaultCheckout true
}
stages {
stage('Checkout repo') {
steps {
checkout scm
}
}
stage('Determine projects to build') {
steps {
script {
if (env.CHANGE_TARGET) {
// For PR's compare the working branch against the merge branch. CHANGE_TARGET is the merge branch variable.
// CHANGE_TARGET only exists as a variable if the job is a PR.
sh "python automation/monorepo_builder.py remotes/origin/${CHANGE_TARGET} && cat changes"
} else {
// For merges post PR, we just want to compare HEAD to HEAD~1 (Latest versus Latest-1)
sh "python automation/monorepo_builder.py HEAD~1 && cat changes"
}
}
}
}
// Build projects
stage('Build example a') {
when {
expression {
// TODO: Write an external function that does this better. This doesn't work without specifics.
return readFile('changes').contains('a')
}
}
steps {
sh "make build-example-a"
}
}
stage('Build example b') {
when {
expression {
return readFile('changes').contains('b')
}
}
steps {
sh "make build-repo"
}
}
// Test projects
stage('Test example a') {
when {
expression {
return readFile('changes').contains('a')
}
}
steps {
sh "make test-example-a"
}
}
stage('Test example b') {
when {
expression {
return readFile('changes').contains('b')
}
}
steps {
sh "make test-example-b"
}
}
// Upload projects
stage('Upload example a') {
when {
allOf {
branch 'master'
expression {
return readFile('changes').contains('a')
}
}
}
steps {
sh "make upload-example-a"
}
}
stage('Upload example b') {
when {
allOf {
branch 'master'
expression {
return readFile('changes').contains('b')
}
}
}
steps {
sh "make upload-example-b"
}
}
// Deploy projects
stage('Deploy example a') {
when {
allOf {
branch 'master'
expression {
return readFile('changes').contains('a')
}
}
}
steps {
sh "make deploy-example-a"
}
}
stage('Deploy example b') {
when {
allOf {
branch 'master'
expression {
return readFile('changes').contains('b')
}
}
}
steps {
sh "make deploy-example-b"
}
}
}
// Post actions
post {
success {
slackSend (color: 'good', message: "SUCCESS: <${env.BUILD_URL}|${env.JOB_NAME}>")
}
failure {
slackSend (color: 'danger', message: "FAILURE: <${env.BUILD_URL}|${env.JOB_NAME}>")
}
}
}