forked from user-cont/release-bot
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Jenkinsfile
65 lines (56 loc) · 2.17 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
def test_targets = ["test_bot.py", "test_changelog.py", "test_fedora.py", "test_github.py", "test_load_release_conf.py", "test_pypi.py", "test_specfile.py"]
def tests = [:]
def onmyduffynode(script){
ansiColor('xterm'){
timestamps{
sh 'ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -l root ${DUFFY_NODE}.ci.centos.org -t \"export REPO=${REPO}; export BRANCH=${BRANCH};\" "' + script + '"'
}
}
}
def synctoduffynode(source)
{
sh 'scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -r ' + source + " " + "root@" + "${DUFFY_NODE}.ci.centos.org:~/"
}
node('userspace-containerization'){
stage('Checkout'){
checkout scm
}
stage('Build'){
try{
stage ("Allocate node"){
env.CICO_API_KEY = readFile("${env.HOME}/duffy.key").trim()
duffy_rtn=sh(
script: "cico --debug node get --arch x86_64 -f value -c hostname -c comment",
returnStdout: true
).trim().tokenize(' ')
env.DUFFY_NODE=duffy_rtn[0]
env.DUFFY_SSID=duffy_rtn[1]
}
stage ("setup"){
onmyduffynode "yum -y install docker make"
synctoduffynode "*" // copy all source files
onmyduffynode "systemctl start docker"
}
stage("build test image"){
onmyduffynode "make image-test"
}
stage("Run test suite in parallel") {
test_targets.each { test_target ->
tests["$test_target"] = {
stage("Test target: $test_target"){
onmyduffynode "docker run -v /root:/usr/src/app:Z -e GITHUB_USER= -e GITHUB_TOKEN= release-bot-tests make test TEST_TARGET=tests/$test_target"
}
}
}
parallel tests
}
} catch (e) {
currentBuild.result = "FAILURE"
throw e
} finally {
stage("Cleanup"){
sh 'cico node done ${DUFFY_SSID}'
}
}
}
}