-
Notifications
You must be signed in to change notification settings - Fork 45
/
.cico.pipeline
84 lines (69 loc) · 3 KB
/
.cico.pipeline
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
import groovy.json.JsonOutput
def notifyPagurePR(repo, msg, status, phase, credentials = 'pagure-auth'){
def json = JsonOutput.toJson([name: 'pagure', url: env.JOB_NAME, build: [full_url: currentBuild.absoluteUrl, status: status, number: currentBuild.number, phase: phase]])
println json
withCredentials([string(credentialsId: credentials, variable: "PAGURE_PUSH_SECRET")]) {
/* We need to notify pagure that jenkins finished but then pagure will
wait for jenkins to be done, so if we wait for pagure's answer we're
basically stuck in a loop where both jenkins and pagure are waiting
for each other */
sh "timeout 1 curl -X POST -d \'$json\' https://pagure.io/api/0/ci/jenkins/$repo/\${PAGURE_PUSH_SECRET}/build-finished -H \"Content-Type: application/json\" | true"
}
}
def onmyduffynode(script){
ansiColor('xterm'){
timestamps{
sh 'ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -l root ${DUFFY_NODE} -t \"export REPO=${REPO}; export BRANCH=${BRANCH};\" "' + script + '"'
}
}
}
def syncfromduffynode(rsyncpath){
sh 'rsync -e "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -l root " -Ha --include=' + rsyncpath + " ${DUFFY_NODE}:~/ ./"
}
node('cico-workspace') {
properties([
parameters([
string(defaultValue: "", description: "", name: "REPO"),
string(defaultValue: "", description: "", name: "BRANCH"),
])
])
stage('Allocate Node'){
duffy_rtn=sh(
script: 'duffy client --url https://duffy.ci.centos.org/api/v1 --auth-name pagure --auth-key $CICO_API_KEY request-session pool=virt-ec2-t2-centos-9s-x86_64,quantity=1',
returnStdout: true
)
def jsonObj = readJSON text: duffy_rtn
env.DUFFY_NODE=jsonObj.session.nodes[0].hostname
env.SSID=jsonObj.session.id
env.BRANCH=params.BRANCH
env.REPO=params.REPO
}
try {
stage('Pre Setup Node'){
// Install EPEL
onmyduffynode 'yum -y install epel-release git'
}
stage('Notify PR'){
notifyPagurePR("pagure", "Tests running ", "BUILDING", "STARTED")
}
stage('Clone Test Suite') {
onmyduffynode "GIT_TRACE=1 GIT_CURL_VERBOSE=1 git clone --single-branch --depth 1 https://pagure.io/pagure.git"
}
stage('Run Test Suite') {
timeout(time: 6, unit: 'HOURS') {
onmyduffynode 'cd pagure && sh ./run_ci_tests_containers.sh'
}
}
} catch (e) {
currentBuild.result = "FAILURE"
throw e
} finally {
stage('Deallocate Node'){
sh 'duffy client --url https://duffy.ci.centos.org/api/v1 --auth-name pagure --auth-key $CICO_API_KEY retire-session ${SSID}'
}
stage('Notify PR'){
res = currentBuild.currentResult
notifyPagurePR("pagure", "Build " + res + "! ", res, "FINALIZED")
}
}
}