-
Notifications
You must be signed in to change notification settings - Fork 21
/
Jenkinsfile
65 lines (54 loc) · 1.92 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
#!groovy
// https://github.com/feedhenry/fh-pipeline-library
@Library('fh-pipeline-library') _
stage('Trust') {
enforceTrustedApproval('aerogear')
}
node ("ocp-slave") {
def apb_container_id, pod_container_id, apb_pod_output
def apb_version = "sprint147.2"
stage('Cleanup') {
deleteDir()
}
stage('Cloning the repo') {
checkout scm
}
stage('Run APB test') {
apb_container_id = sh (
script: "docker run --detach --net=host --privileged -v \$PWD:/mnt -v \$HOME/.kube:/.kube -v /var/run/docker.sock:/var/run/docker.sock -u \$UID docker.io/ansibleplaybookbundle/apb-tools:${apb_version} test --registry-route docker-registry.default.svc:5000",
returnStdout: true
).trim()
}
stage('Watch the logs') {
timeout(120) {
waitUntil {
try {
pod_container_id = sh (
script: "docker ps --filter since=${apb_container_id} | grep 'entrypoint.sh test' | awk '{print \$1}'",
returnStdout: true
).trim()
if (pod_container_id != "") {
return true
} else {
sh "sleep 1"
return false
}
} catch (exception) {
return false
}
}
}
sh "docker logs -f ${pod_container_id}"
}
stage('Get APB container logs and evaluate test result') {
apb_pod_output = sh (
// We must wait for APB container to finish. Otherwise `docker logs` command does not work.
script: "sleep 10 ; docker logs -f ${apb_container_id}",
returnStdout: true
).trim()
echo apb_pod_output
if ( apb_pod_output.contains("Pod phase Failed") ) {
error("APB test failed.")
}
}
}