-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
77 lines (66 loc) · 1.86 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
// This Jenkinsfile is dedicated to the jenkins job: ansible-collection
//
// This job is the CI for the ansible-collection project
@Library('toucan-jenkins-lib')_
import com.toucantoco.ToucanVars
RELEASE_BRANCH_NAMES = [
'master',
]
pipeline {
agent any
options {
// Enable color in logs
ansiColor('gnome-terminal')
}
environment {
BUILD_RANDOM_ID = Math.round(Math.random() * 1000000)
GITHUB_TOKEN = credentials('GITHUB_TOUCANTOCO_TOKEN')
}
stages {
stage('Test') {
steps {
storeStage()
sh 'make docker-test'
}
}
stage('Build and Deploy') {
when {
expression {
// Only when the latest commit messages is like vX.Y.Z
// and the branch is declared in RELEASE_BRANCH_NAMES
LAST_COMMIT_MESSAGE = sh(
script: 'git log --format=%B -n 1',
returnStdout: true
).trim()
return RELEASE_BRANCH_NAMES.contains(BRANCH_NAME) && LAST_COMMIT_MESSAGE ==~ /v\d+\.\d+\.\d+$/
}
}
stages {
stage('Build archive') {
steps {
storeStage()
sh 'make docker-build'
}
}
stage('Create release and push archive') {
steps {
storeStage()
sh 'make release-version'
}
}
}
}
}
post {
failure {
postSlackNotif()
}
cleanup {
sh 'make clean'
}
always {
// Store build result in a format parsable for our Elastic stack
logKibana()
}
}
}