-
Notifications
You must be signed in to change notification settings - Fork 8
/
Jenkinsfile
65 lines (54 loc) · 1.97 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
properties([
parameters([
string(name: 'JENNY_DOCKER_UID', defaultValue: '1000:1000',
description: 'Should correspond to the uid:gid of the user running docker.'),
string(name: 'JENNY_DOCKER_GID', defaultValue: '999',
description: 'Should be the group ID of the docker installation.')
])
])
JENNY_DOCKER_UID = params.JENNY_DOCKER_UID ?: '1000:1000'
JENNY_DOCKER_GID = params.JENNY_DOCKER_GID ?: '999'
stage('Build Test Container') {
node {
deleteDir()
checkout scm
docker.build('jenny_test_junit',
'features/junit-support')
// jenny needs access to the workFolder to mount it inside the containers,
// and the tests output is checked against /tmp
def jennyParentIsInDocker = sh([
script: "cat /proc/1/cgroup | grep docker",
returnStatus: true
]) == 0
def jennyParentIsInKubernetes = sh([
script: "cat /proc/1/cgroup | grep kubepods",
returnStatus: true
]) == 0
sh """
cat /proc/1/cgroup
"""
echo "in docker: $jennyParentIsInDocker"
echo "in kubernetes: $jennyParentIsInKubernetes"
def extraMount = (jennyParentIsInDocker || jennyParentIsInKubernetes) ? " -v /tmp:/tmp" : ""
docker.build('jenny_test_container')
.inside("-v /var/run/docker.sock:/var/run/docker.sock:rw -u $JENNY_DOCKER_UID --group-add $JENNY_DOCKER_GID${extraMount}") {
checkout scm
try {
sh """
bin/test_jenny.py
"""
} finally {
sh "cat /tmp/jenny_*.log"
}
}
}
}
if (isMasterBranch()) {
stage('Publish on github') {
node {
deleteDir()
checkout scm
publishGit repo: "git@github.com:bmustiata/jenny.git"
}
}
}