forked from aidenkeating/aerogear-digger-apb
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Jenkinsfile
52 lines (39 loc) · 1.47 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
#!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
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:canary test --registry-route docker-registry.default.svc:5000',
returnStdout: true
).trim()
}
stage('Watch the logs') {
pod_container_id = sh (
script: "sleep 30 ; docker ps --filter since=${apb_container_id} | grep 'entrypoint.sh test' | awk '{print \$1}'",
returnStdout: true
).trim()
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.")
}
}
}