This repository has been archived by the owner on Sep 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
executable file
·112 lines (99 loc) · 3.06 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
#!groovy
def PROJECT_NAME = "waarnemingen-voertuigen"
def SLACK_CHANNEL = '#waarnemingen-deployments'
def PLAYBOOK = 'deploy.yml'
def SLACK_MESSAGE = [
"title_link": BUILD_URL,
"fields": [
["title": "Project","value": PROJECT_NAME],
["title":"Branch", "value": BRANCH_NAME, "short":true],
["title":"Build number", "value": BUILD_NUMBER, "short":true]
]
]
pipeline {
agent any
options {
timeout(time: 1, unit: 'HOURS')
}
environment {
SHORT_UUID = sh( script: "uuidgen | cut -d '-' -f1", returnStdout: true).trim()
COMPOSE_PROJECT_NAME = "${PROJECT_NAME}-${env.SHORT_UUID}"
VERSION = env.BRANCH_NAME.replace('master', 'latest')
}
stages {
stage('Test') {
steps {
sh 'make test'
}
}
stage('Build') {
steps {
sh 'make build'
}
}
stage('Push') {
when {
anyOf {
buildingTag()
branch 'master'
}
}
steps {
retry(3) {
sh 'make push'
}
}
}
stage('Deploy to acceptance') {
when {
branch 'master'
}
steps {
sh 'VERSION=acceptance make push'
build job: 'Subtask_Openstack_Playbook', parameters: [
string(name: 'PLAYBOOK', value: PLAYBOOK),
string(name: 'INVENTORY', value: "acceptance"),
string(
name: 'PLAYBOOKPARAMS',
value: "-e 'deployversion=${VERSION} cmdb_id=app_waarnemingen-voertuigen'"
)
], wait: true
}
}
stage('Deploy to production') {
when {
tag pattern: "^(?i)\\d+\\.\\d+\\.\\d+(?!-rc.*)", comparator: "REGEXP"
}
steps {
sh 'VERSION=production make push'
build job: 'Subtask_Openstack_Playbook', parameters: [
string(name: 'PLAYBOOK', value: PLAYBOOK),
string(name: 'INVENTORY', value: "production"),
string(
name: 'PLAYBOOKPARAMS',
value: "-e 'deployversion=${VERSION} cmdb_id=app_waarnemingen-voertuigen'"
)
], wait: true
slackSend(channel: SLACK_CHANNEL, attachments: [SLACK_MESSAGE <<
[
"color": "#36a64f",
"title": "Deploy to production succeeded :rocket:",
]
])
}
}
}
post {
always {
sh 'make clean'
}
failure {
slackSend(channel: SLACK_CHANNEL, attachments: [SLACK_MESSAGE <<
[
"color": "#D53030",
"title": "Build failed :fire:",
]
])
}
}
}