-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
91 lines (90 loc) · 3.14 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
#!groovy
pipeline {
agent {
label "docker"
}
options {
timestamps()
timeout(time: 2, unit: 'HOURS')
buildDiscarder(logRotator(numToKeepStr: '30', artifactNumToKeepStr: '5'))
disableConcurrentBuilds()
}
environment {
// In case another branch beside master or develop should be deployed, enter it here
BRANCH_TO_DEPLOY = 'xyz'
}
stages {
stage('Build image') {
when {
not {
anyOf { branch 'develop'; branch 'master'; branch "${BRANCH_TO_DEPLOY}" }
}
}
//noinspection GroovyAssignabilityCheck
parallel {
stage('Debian') {
steps {
script {
withDockerRegistry(credentialsId: 'Docker-Registry') {
sh "docker build -f Debian/Dockerfile --rm -t starwarsfan/cmake-builder-debian:latest ."
}
}
}
}
stage('Fedora') {
agent {
label "docker"
}
steps {
script {
withDockerRegistry(credentialsId: 'Docker-Registry') {
sh "docker build -f Fedora/Dockerfile --rm -t starwarsfan/cmake-builder-fedora:latest ."
}
}
}
}
}
}
stage('Build and upload image') {
when {
anyOf { branch 'develop'; branch "${BRANCH_TO_DEPLOY}" }
}
//noinspection GroovyAssignabilityCheck
parallel {
stage('Debian') {
steps {
script {
withDockerRegistry(credentialsId: 'Docker-Registry') {
sh "docker build -f Debian/Dockerfile --rm -t starwarsfan/cmake-builder-debian:latest ."
sh "docker push starwarsfan/cmake-builder-debian:latest"
}
}
}
}
stage('Fedora') {
agent {
label "docker"
}
steps {
script {
withDockerRegistry(credentialsId: 'Docker-Registry') {
sh "docker build -f Fedora/Dockerfile --rm -t starwarsfan/cmake-builder-fedora:latest ."
sh "docker push starwarsfan/cmake-builder-fedora:latest"
}
}
}
}
}
}
stage('Info') {
when {
branch 'master'
}
steps {
script {
sh "echo 'No build steps on master branch performed, use Job 'tagBuilderImage' to perform image releases'"
}
}
}
}
}