-
Notifications
You must be signed in to change notification settings - Fork 39
/
Jenkinsfile
93 lines (90 loc) · 2.95 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
92
93
#!groovy
pipeline {
agent any
stages {
stage('FetchCode') {
steps {
checkout scm
dir('cloud-automation') {
git(
url: 'https://github.com/uc-cdis/cloud-automation.git',
branch: 'master'
)
}
script {
env.GEN3_HOME=env.WORKSPACE+'/cloud-automation'
env.GEN3_NOPROXY='true'
env.KLOCK_USER = "jenkins" + new Random().nextInt()
}
}
}
stage('docker pull') {
steps {
sh('sudo docker-compose pull')
}
}
stage('AcquireLock') {
steps {
script {
// acquire global lock to launch docker services on Jenkins host node
def lockStatus = sh( script: "bash cloud-automation/gen3/bin/klock.sh lock dockerTest ${env.KLOCK_USER} 3600 -w 600", returnStatus: true)
if (lockStatus != 0) {
error("unable to acquire dockerTest lock")
}
}
}
}
stage('docker up') {
steps {
sh 'sudo docker-compose down || true'
sh 'sudo docker-compose config'
//sh 'sudo docker-compose up -d' // see note below - this fails on k8s node
}
}
stage('smoke test') {
when {
expression {
return false // docker-compose -up above fails, because k8s owns the host node networking
// + sudo docker-compose up -d
// Creating network "ithub_org_compose-services_pr-20_devnet" with the default driver
// Failed to program FILTER chain: iptables failed: iptables --wait -I FORWARD -o br-fa829e600aec -j DOCKER: iptables v1.4.21: Couldn't load target `DOCKER':No such file or directory
}
}
steps {
dir('testResults') {
script {
// get the IP address of the node Jenkins is running on
def ipAddress = sh(script: "kubectl describe pod -l app=jenkins | grep Node: | sed 's@^.*/@@'", returnStdout: true)
retry(10) { // retry smoke_test up to 10 times
sleep(60) // give the services some time to start up
sh(script: "bash ./smoke_test.sh ${ipAddress}")
}
}
}
}
}
}
post {
success {
echo "https://jenkins.planx-pla.net/ $env.JOB_NAME pipeline succeeded"
}
failure {
echo "Failure!"
//archiveArtifacts artifacts: '**/output/*.png', fingerprint: true
//slackSend color: 'bad', message: "https://jenkins.planx-pla.net $env.JOB_NAME pipeline failed"
}
unstable {
echo "Unstable!"
//slackSend color: 'bad', message: "https://jenkins.planx-pla.net $env.JOB_NAME pipeline unstable"
}
always {
script {
uid = env.service+"-"+env.quaySuffix+"-"+env.BUILD_NUMBER
withEnv(['GEN3_NOPROXY=true', "GEN3_HOME=$env.WORKSPACE/cloud-automation"]) {
sh("bash cloud-automation/gen3/bin/klock.sh unlock dockerTest ${env.KLOCK_USER} || true")
}
}
echo "done"
}
}
}