This repository has been archived by the owner on Sep 29, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathJenkinsfile.salobj
166 lines (163 loc) · 8.22 KB
/
Jenkinsfile.salobj
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
pipeline {
agent any
environment {
registryCredential = "dockerhub-lssttsadmin"
dockerImageNameMaster = "lsstts/salobj:master"
dockerImageNameDevelop = "lsstts/salobj:develop"
dockerImageNameBuild = "lsstts/salobj:b${BUILD_NUMBER}"
dockerImageMaster = ""
dockerImageDevelop = ""
dockerImageBuild = ""
base_image_tag = "${base_image_tag}"
}
parameters {
string defaultValue: 'w_latest_1000_1000', description: 'Which tag of lsstts/base-env docker image to use as base?', name: 'base_image_tag', trim: false
string defaultValue: 'tags/v0.5.0', description: 'Which version of ts_config_ocs to build?', name: 'ts_config_ocs', trim: false
string defaultValue: 'tags/v0.5.0', description: 'Which version of ts_config_attcs to build?', name: 'ts_config_attcs', trim: false
string defaultValue: 'tags/v0.1.0', description: 'Which version of ts_config_eas to build?', name: 'ts_config_eas', trim: false
string defaultValue: 'tags/v0.4.0', description: 'Which version of ts_config_latiss to build?', name: 'ts_config_latiss', trim: false
string defaultValue: 'tags/v0.2.0', description: 'Which version of ts_config_mttcs to build?', name: 'ts_config_mttcs', trim: false
string defaultValue: 'tags/v0.1.0', description: 'Which version of ts_config_atcalsys to build?', name: 'ts_config_atcalsys', trim: false
string defaultValue: 'tags/v4.1.3', description: 'Which version of ts_sal to build?', name: 'ts_sal', trim: false
string defaultValue: 'tags/v5.14.0', description: 'Which version of ts_salobj to build?', name: 'ts_salobj', trim: false
string defaultValue: 'tags/v5.1.0', description: 'Which version of ts_xml to build?', name: 'ts_xml', trim: false
string defaultValue: 'tags/v1.2.0', description: 'Which version of ts_idl to build?', name: 'ts_idl', trim: false
booleanParam defaultValue: false, description: 'Build master branch for all repos. Ignores All version parameters.', name: 'build_master'
booleanParam defaultValue: false, description: 'Build develop branch for all repos. Ignores All version parameters.', name: 'build_develop'
booleanParam defaultValue: true, description: 'Push the tagged build to docker hub?', name: 'push_tag'
booleanParam defaultValue: false, description: 'Trigger the DevelopEnvironment/develop build?', name: 'BuildDevEnv_develop'
booleanParam defaultValue: false, description: 'Trigger the DevelopEnvironment/master build?', name: 'BuildDevEnv_master'
}
stages {
stage("Create docker network.") {
steps {
script {
// Set the Current Build status, in order to make the email notification function work.
currentBuild.result = 'SUCCESS'
// Create Docker network.
sh "docker network create salobj_b${BUILD_NUMBER}"
}
}
}
stage("Pull base image.") {
steps {
script {
sh "docker pull lsstts/base-env:${base_image_tag}"
}
}
}
stage("Build Docker image (master)") {
when {
expression { return env.build_master.toBoolean() }
}
steps {
script {
dockerImageMaster = docker.build(dockerImageNameMaster, "--no-cache --network salobj_b${BUILD_NUMBER} --build-arg ts_config_ocs=master --build-arg ts_config_attcs=master --build-arg ts_config_eas=master --build-arg ts_config_latiss=master --build-arg ts_config_mttcs=master --build-arg ts_config_atcalsys=master --build-arg ts_sal=master --build-arg ts_salobj=master --build-arg ts_xml=master --build-arg ts_idl=master --build-arg base_image_tag=${base_image_tag} ./develop-env/salobj/")
}
}
}
stage("Build Docker image (develop)") {
when {
expression { return env.build_develop.toBoolean() }
}
steps {
script {
dockerImageDevelop = docker.build(dockerImageNameDevelop, "--no-cache --network salobj_b${BUILD_NUMBER} --build-arg ts_config_ocs=develop --build-arg ts_config_attcs=develop --build-arg ts_config_eas=develop --build-arg ts_config_latiss=develop --build-arg ts_config_mttcs=develop --build-arg ts_config_atcalsys=develop --build-arg ts_sal=develop --build-arg ts_salobj=develop --build-arg ts_xml=develop --build-arg ts_idl=develop --build-arg base_image_tag=${base_image_tag} ./develop-env/salobj/")
}
}
}
stage("Build Docker image (tag/branch)") {
when {
not{
anyOf {
expression { return env.build_develop.toBoolean() }
expression { return env.build_master.toBoolean() }
}
}
}
steps {
script {
dockerImageBuild = docker.build(dockerImageNameBuild, "--no-cache --network salobj_b${BUILD_NUMBER} --build-arg ts_config_ocs=${params.ts_config_ocs} --build-arg ts_config_attcs=${params.ts_config_attcs} --build-arg ts_config_eas=${params.ts_config_eas} --build-arg ts_config_latiss=${params.ts_config_latiss} --build-arg ts_config_mttcs=${params.ts_config_mttcs} --build-arg ts_config_atcalsys=${params.ts_config_atcalsys} --build-arg ts_sal=${params.ts_sal} --build-arg ts_salobj=${params.ts_salobj} --build-arg ts_xml=${params.ts_xml} --build-arg ts_idl=${params.ts_idl} --build-arg base_image_tag=${base_image_tag} ./develop-env/salobj/")
}
}
}
stage("Push Docker image (master)") {
when {
expression { return env.build_master.toBoolean() }
}
steps {
script {
docker.withRegistry("", registryCredential) {
dockerImageMaster.push()
}
}
}
}
stage("Push Docker image (develop)") {
when {
expression { return env.build_develop.toBoolean() }
}
steps {
script {
docker.withRegistry("", registryCredential) {
dockerImageDevelop.push()
}
}
}
}
stage("Push Docker image (tag/branch)") {
when {
allOf {
expression { return env.push_tag.toBoolean() }
not{
anyOf {
expression { return env.build_develop.toBoolean() }
expression { return env.build_master.toBoolean() }
}
}
}
}
steps {
script {
docker.withRegistry("", registryCredential) {
dockerImageBuild.push()
dockerImageBuild.push("latest")
}
}
}
}
stage("Trigger the DevelopEnvironment/develop job") {
when {
expression {
return params.BuildDevEnv_develop
}
}
steps {
build job: 'DevelopEnvironment', parameters: [booleanParam(name: 'build_develop', value: true),
booleanParam(name: 'push_tag', value: false)], wait: false
}
}
stage("Trigger the DevelopEnvironment/master job") {
when {
expression {
return params.BuildDevEnv_master
}
}
steps {
build job: 'DevelopEnvironment', parameters: [booleanParam(name: 'build_master', value: true),
booleanParam(name: 'push_tag', value: false)], wait: false
}
}
}
post {
cleanup {
sh "docker network rm salobj_b${BUILD_NUMBER}"
}
always {
step([$class: 'Mailer',
notifyEveryUnstableBuild: false,
recipients: "[email protected]",
sendToIndividuals: true])
}
}
}