-
Notifications
You must be signed in to change notification settings - Fork 207
Expand file tree
/
Copy pathcico.pipeline
More file actions
167 lines (142 loc) · 5 KB
/
Copy pathcico.pipeline
File metadata and controls
167 lines (142 loc) · 5 KB
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
/**
* This is Bodhi's Jenkins Pipeline Jenkinsfile.
*
* You can read documentation about this file at https://jenkins.io/doc/book/pipeline/jenkinsfile/.
* A useful list of plugins can be found here: https://jenkins.io/doc/pipeline/steps/.
*/
/**
* Run the given script on the Duffy node.
*
* @param script The script to run on the node.
*/
def onmyduffynode(String script) {
timestamps {
sh 'ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -l root ${DUFFY_NODE}.ci.centos.org "' + script + '"'
}
}
/**
* rsync the given path from the Duffy node back to the control host.
*
* @param rsyncpath The path to be rsync'd back to the control host.
*/
def syncfromduffynode(rsyncpath) {
sh 'rsync -e "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -l root " -Ha --include=' + " ${DUFFY_NODE}.ci.centos.org:~/payload/" + rsyncpath + " ./"
}
/**
* rsync the given path from the control host to the Duffy node.
*
* @param rsyncpath The path to be rsync'd to the Duffy node.
*/
def synctoduffynode(rsyncpath) {
sh 'rsync -e "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -l root " -Ha --include=' + rsyncpath + " ./ ${DUFFY_NODE}.ci.centos.org:~/payload/"
}
/**
* Install test dependencies on the Duffy node.
*/
def configure_node = {
onmyduffynode 'yum -y install epel-release'
onmyduffynode 'yum install -y docker python36 rsync'
onmyduffynode 'systemctl start docker'
// We need this until https://src.fedoraproject.org/rpms/python-click/pull-request/2 is merged.
onmyduffynode 'python3.6 -m ensurepip'
onmyduffynode 'python3.6 -m pip install click'
}
/**
* Run the given function up to 5 times (if it fails), with 60 seconds of sleeping in between tries.
*
* @param f The function to retry.
*/
def retry_with_sleep = { f ->
try {
f()
} catch (error) {
retry(4) {
sleep(60)
f()
}
}
}
/**
* Run bodhi-ci on the Duffy node for the given arguments.
*
* @param release The release to pass to bodhi-ci's -r flag.
* @param command The subcommand of bodhi-ci to use.
* @param context This parameter is appended to the release and a dash to form the GitHub context.
* @param args Any extra arguments to be passed to the command.
*/
def bodhi_ci = { String release, String command, String context, String args ->
githubNotify context: release + '-' + context, description: 'running', status: 'PENDING'
try {
stage(release + '-' + context) {
timeout(time: 16, unit: 'MINUTES') {
onmyduffynode 'cd payload && python36 ./devel/ci/bodhi-ci ' + command + ' --no-tty -r ' + release + ' ' + args
}
}
githubNotify context: release + '-' + context, status: 'SUCCESS'
} catch(error) {
githubNotify context: release + '-' + context, status: 'FAILURE'
throw error
}
}
/**
* Build and test the given release.
*
* @param release The release to test.
*/
def test_release = { String release ->
bodhi_ci(release, 'build', 'build', '')
parallel(
docs: {bodhi_ci(release, 'docs', 'docs', '--no-build --no-init')},
flake8: {bodhi_ci(release, 'flake8', 'flake8', '--no-build --no-init')},
pydocstyle: {bodhi_ci(release, 'pydocstyle', 'pydocstyle', '--no-build --no-init')},
unitpy2: {
bodhi_ci(release, 'unit', 'python2-unit', '--no-build --no-init -p 2')
bodhi_ci(release, 'diff-cover', 'python2-diff-cover', '--no-build --no-init -p 2')
},
unitpy3: {
bodhi_ci(release, 'unit', 'python3-unit', '--no-build --no-init -p 3')
bodhi_ci(release, 'diff-cover', 'python3-diff-cover', '--no-build --no-init -p 3')
}
)
}
node('bodhi') {
checkout scm
stage('Allocate Duffy node') {
env.CICO_API_KEY = readFile("${env.HOME}/duffy.key").trim()
// Get a duffy node and set the DUFFY_NODE and SSID environment variables.
duffy_rtn=sh(
script: 'cico --debug node get -f value -c hostname -c comment --retry-count 4 --retry-interval 60',
returnStdout: true
).trim().tokenize(' ')
env.DUFFY_NODE=duffy_rtn[0]
env.SSID=duffy_rtn[1]
}
try {
stage('Configure node'){
retry_with_sleep(configure_node)
}
stage('Sync pull request to node') {
synctoduffynode('bodhi')
}
parallel(
f27: {test_release('f27')},
f28: {test_release('f28')},
f29: {test_release('f29')},
pip: {test_release('pip')},
rawhide: {test_release('rawhide')}
)
} catch (e) {
currentBuild.result = "FAILURE"
throw e
} finally {
stage('Deallocate node'){
sh 'cico node done ${SSID}'
}
stage('Sync Artifacts'){
syncfromduffynode('test_results')
}
stage('junit'){
junit(testResults: 'test_results/**/nosetests.xml', allowEmptyResults: true)
}
}
}