This repository has been archived by the owner on Jan 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
73 lines (66 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
#!groovy
def tryStep(String message, Closure block, Closure tearDown = null) {
try {
block()
}
catch (Throwable t) {
slackSend message: "${env.JOB_NAME}: ${message} failure ${env.BUILD_URL}", channel: '#ci-channel', color: 'danger'
throw t
}
finally {
if (tearDown) {
tearDown()
}
}
}
String BRANCH = "${env.BRANCH_NAME}"
node('BS16 || BS17') {
stage("Checkout") {
def scmVars = checkout(scm)
env.GIT_COMMIT = scmVars.GIT_COMMIT
env.COMPOSE_DOCKER_CLI_BUILD = 1
}
if (BRANCH == "develop" || BRANCH == "master") {
stage("Build and push image") {
tryStep "build", {
docker.withRegistry("${DOCKER_REGISTRY_HOST}",'docker_registry_auth') {
def cachedImage = docker.image("ois/signalsfrontend:latest")
if (cachedImage) {
cachedImage.pull()
}
def image = docker.build("ois/signalsfrontend:${env.BUILD_NUMBER}",
"--shm-size 1G " +
"--build-arg BUILD_NUMBER=${env.BUILD_NUMBER} " +
"--build-arg GIT_COMMIT=${env.GIT_COMMIT} " +
".")
image.push()
image.push("latest")
}
}
}
}
if (BRANCH == "develop") {
stage("Deploy Amsterdam ACC") {
tryStep "deployment", {
build job: '/SIA_Signalen_Amsterdam/signals-amsterdam/develop'
}
}
stage("Deploy Weesp ACC") {
tryStep "deployment", {
build job: '/SIA_Signalen_Amsterdam/signals-weesp/develop'
}
}
}
if (BRANCH == "master") {
stage("Deploy Amsterdam PROD") {
tryStep "deployment", {
build job: '/SIA_Signalen_Amsterdam/signals-amsterdam/master'
}
}
stage("Deploy Weesp PROD") {
tryStep "deployment", {
build job: '/SIA_Signalen_Amsterdam/signals-weesp/master'
}
}
}
}