forked from lsst-ts/ts_Dockerfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile.salobj
122 lines (118 loc) · 4.51 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
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}"
}
stages {
stage("Create docker network.") {
steps {
script {
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 sal_v=master --build-arg salobj_v=master --build-arg xml_v=master --build-arg idl_v=master --build-arg config_ocs_v=master --build-arg base_image_tag=${base_image_tag} ./develop-env/salobj_4/")
}
}
}
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 sal_v=develop --build-arg salobj_v=develop --build-arg xml_v=develop --build-arg idl_v=develop --build-arg config_ocs_v=develop --build-arg base_image_tag=${base_image_tag} ./develop-env/salobj_4/")
}
}
}
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 sal_v=${env.sal_v} --build-arg salobj_v=${env.salobj_v} --build-arg xml_v=${env.xml_v} --build-arg idl_v=${env.idl_v} --build-arg config_ocs_v=${config_ocs_v} --build-arg base_image_tag=${base_image_tag} ./develop-env/salobj_4/")
}
}
}
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()
}
}
}
}
}
post {
cleanup {
sh "docker network rm salobj_b${BUILD_NUMBER}"
}
}
// post {
// failure {
// mail bcc: '', body: "<b>Example</b><br>Project: ${env.JOB_NAME} <br>Build Number: ${env.BUILD_NUMBER} <br> URL de build: ${env.BUILD_URL}", cc: '', charset: 'UTF-8', from: '', mimeType: 'text/html', replyTo: '', subject: "ERROR CI: Project name -> ${env.JOB_NAME}", to: "[email protected]";
// }
// }
}