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.develop-env
139 lines (135 loc) · 7.11 KB
/
Jenkinsfile.develop-env
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
pipeline {
agent any
environment {
registryCredential = "dockerhub-lssttsadmin"
dockerImageNameMaster = "lsstts/develop-env:master"
dockerImageNameDevelop = "lsstts/develop-env:develop"
dockerImageNameBuild = "lsstts/develop-env:b${BUILD_NUMBER}"
dockerImageMaster = ""
dockerImageDevelop = ""
dockerImageBuild = ""
}
parameters {
string defaultValue: 'latest', description: 'Which tag of salobj docker image to use as base?', name: 'base_image_tag', trim: false
string defaultValue: 'tags/v2.5.1', description: 'Which version of ts_scriptqueue to use?', name: 'ts_scriptqueue', trim: false
string defaultValue: 'tags/v0.2.2', description: 'Which version of ts_observatory_control to use?', name: 'ts_observatory_control', trim: false
string defaultValue: 'tags/v1.1.1', description: 'Which version of ts_standardscripts to use?', name: 'ts_standardscripts', trim: false
string defaultValue: 'tags/v0.4.0', description: 'Which version of ts_externalscripts to use?', name: 'ts_externalscripts', trim: false
string defaultValue: 'tags/v1.0.3', description: 'Which version of ts_ATMCSSimulator to use?', name: 'ts_ATMCSSimulator', trim: false
string defaultValue: 'tags/v1.1.3', description: 'Which version of ts_ATDome to use?', name: 'ts_ATDome', trim: false
string defaultValue: 'tags/v1.3.3', description: 'Which version of ts_ATDomeTrajectory to use?', name: 'ts_ATDomeTrajectory', trim: false
string defaultValue: 'tags/v1.0.1', description: 'Which version of ts_simactuators to use?', name: 'ts_simactuators', trim: false
string defaultValue: 'tags/v0.5.1', description: 'Which version of ts_hexrotcomm to use?', name: 'ts_hexrotcomm', trim: false
booleanParam defaultValue: false, description: 'Build master branch for all repos. Ignores All "_v" parameters.', name: 'build_master'
booleanParam defaultValue: false, description: 'Build develop branch for all repos. Ignores All "_v" parameters.', name: 'build_develop'
booleanParam defaultValue: true, description: 'Push the tagged build to docker hub?', name: 'push_tag'
}
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 the Docker network.
sh """
docker network create net_b${BUILD_NUMBER} || echo Network exists...
"""
}
}
}
stage("Build Docker image (master)") {
when {
expression { return env.build_master.toBoolean() }
}
steps {
script {
sh "docker pull lsstts/salobj:master"
dockerImageMaster = docker.build(dockerImageNameMaster, "--no-cache --network net_b${BUILD_NUMBER} --build-arg base_image_tag=master --build-arg ts_scriptqueue=master --build-arg ts_observatory_control=master --build-arg ts_standardscripts=master --build-arg ts_externalscripts=master --build-arg ts_ATMCSSimulator=master --build-arg ts_ATDome=master --build-arg ts_ATDomeTrajectory=master --build-arg ts_simactuators=master --build-arg ts_hexrotcomm=master ./develop-env/develop-env/")
}
}
}
stage("Build Docker image (develop)") {
when {
expression { return env.build_develop.toBoolean() }
}
steps {
script {
sh "docker pull lsstts/salobj:develop"
dockerImageDevelop = docker.build(dockerImageNameDevelop, "--no-cache --network net_b${BUILD_NUMBER} --build-arg base_image_tag=develop --build-arg ts_scriptqueue=develop --build-arg ts_observatory_control=develop --build-arg ts_standardscripts=develop --build-arg ts_externalscripts=develop --build-arg ts_ATMCSSimulator=develop --build-arg ts_ATDome=develop --build-arg ts_ATDomeTrajectory=develop --build-arg ts_simactuators=develop --build-arg ts_hexrotcomm=develop ./develop-env/develop-env/")
}
}
}
stage("Build Docker image (tag/branch)") {
when {
not{
anyOf {
expression { return env.build_develop.toBoolean() }
expression { return env.build_master.toBoolean() }
}
}
}
steps {
script {
sh "docker pull lsstts/salobj:${params.base_image_tag}"
dockerImageBuild = docker.build(dockerImageNameBuild, "--no-cache --network net_b${BUILD_NUMBER} --build-arg base_image_tag=${params.base_image_tag} --build-arg ts_scriptqueue=${params.ts_scriptqueue} --build-arg ts_observatory_control=${params.ts_observatory_control} --build-arg ts_standardscripts=${params.ts_standardscripts} --build-arg ts_externalscripts=${params.ts_externalscripts} --build-arg ts_ATMCSSimulator=${params.ts_ATMCSSimulator} --build-arg ts_ATDome=${params.ts_ATDome} --build-arg ts_ATDomeTrajectory=${params.ts_ATDomeTrajectory} --build-arg ts_simactuators=${params.ts_simactuators} --build-arg ts_hexrotcomm=${params.ts_hexrotcomm} ./develop-env/develop-env/")
}
}
}
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")
}
}
}
}
}
post {
cleanup {
sh "docker network rm net_b${BUILD_NUMBER}"
}
always {
step([$class: 'Mailer',
notifyEveryUnstableBuild: false,
recipients: "[email protected]",
sendToIndividuals: true])
}
}
}