forked from jenkinsci/docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
73 lines (60 loc) · 2.08 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
#!/usr/bin/env groovy
properties([
buildDiscarder(logRotator(numToKeepStr: '50', artifactNumToKeepStr: '5')),
pipelineTriggers([cron('H H/6 * * *')]),
])
timeout(20) {
node('docker') {
deleteDir()
stage('Checkout') {
checkout scm
}
if (!infra.isTrusted()) {
stage('shellcheck') {
// newer versions of the image don't have cat installed and docker pipeline fails
docker.image('koalaman/shellcheck:v0.4.6').inside('--entrypoint=') {
// run shellcheck ignoring error SC1091
// Not following: /usr/local/bin/jenkins-support was not specified as input
sh "shellcheck -e SC1091 *.sh"
}
}
/* Outside of the trusted.ci environment, we're building and testing
* the Dockerfile in this repository, but not publishing to docker hub
*/
stage('Build') {
docker.build('jenkins')
docker.build('jenkins:alpine', '--file Dockerfile-alpine .')
}
stage('Test') {
sh """
git submodule update --init --recursive
git clone https://github.com/sstephenson/bats.git
"""
}
def labels = ['debian', 'slim', 'alpine']
def builders = [:]
for (x in labels) {
def label = x
// Create a map to pass in to the 'parallel' step so we can fire all the builds at once
builders[label] = {
stage("Test ${label}") {
def dockerfile = label == 'debian' ? 'Dockerfile' : "Dockerfile-${label}"
sh "DOCKERFILE=${dockerfile} bats/bin/bats tests"
}
}
}
parallel builders
} else {
/* In our trusted.ci environment we only want to be publishing our
* containers from artifacts
*/
stage('Publish') {
infra.withDockerCredentials {
sh './publish.sh'
sh './publish.sh --variant alpine'
sh './publish.sh --variant slim'
}
}
}
}
}