-
Notifications
You must be signed in to change notification settings - Fork 118
/
Copy pathJenkinsfile
177 lines (164 loc) · 8.88 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
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
168
169
170
171
172
173
174
175
176
177
#!groovy
def getRepoURL() {
sh "git config --get remote.origin.url > .git/remote-url"
return readFile(".git/remote-url").trim()
}
def getCommitSha() {
sh "git rev-parse HEAD > .git/current-commit"
return readFile(".git/current-commit").trim()
}
void setBuildStatus(String message, String state) {
step([
$class: "GitHubCommitStatusSetter",
reposSource: [$class: "ManuallyEnteredRepositorySource", url: getRepoURL()],
contextSource: [$class: "ManuallyEnteredCommitContextSource", context: "ci/jenkins/build-status"],
errorHandlers: [[$class: "ChangingBuildStatusErrorHandler", result: "UNSTABLE"]],
statusResultSource: [ $class: "ConditionalStatusResultSource", results: [[$class: "AnyBuildResult", message: message, state: state]] ]
]);
}
pipeline {
triggers { pollSCM('*/1 * * * *') }
options {
// Keep the 30 most recent builds
buildDiscarder(logRotator(numToKeepStr: '30'))
timestamps()
disableConcurrentBuilds()
// skipDefaultCheckout(true) // rather do the checkout in all stages
}
environment {
REDPITAYA_HOSTNAME = "192.168.178.26"
//REDPITAYA_HOSTNAME = "rp-f03f3a"
//REDPITAYA_HOSTNAME = "nobody.justdied.com"
DOCKER_ARGS = '-u root -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=:0 --net=host'
//NOSETESTS_COMMAND = 'nosetests pyrpl/test/test_ipython_notebook/test_ipython_kernel.py'
NOSETESTS_COMMAND = 'nosetests'
PYPI = credentials('f63335ce-493d-4caf-8ebe-d7e2629f79f3')
SOURCEFORGE = credentials('1a9396cd-6bb7-42f3-a14a-9e4a1bc82650')
REDPITAYA = credentials('2bf38f88-833a-4624-9682-3a6f0a145d30')
REDPITAYA_USER = "$REDPITAYA_USR"
REDPITAYA_PASSWORD = "$REDPITAYA_PSW"
}
agent any
stages {
stage('Notify github that a build was started') {
agent any
steps { setBuildStatus("Jenkins build started...", "PENDING") }}
stage('Unit tests') { stages {
stage('Python 3.7') {
agent { dockerfile { args "$DOCKER_ARGS"
additionalBuildArgs '--build-arg PYTHON_VERSION=3.7' }}
steps { lock('redpitaya') {
sh ''' which python
python -V
echo $PYTHON_VERSION
conda list
# use a custom global configfile adapted to the hardware for unit tests
cp ./jenkins_global_config.yml ./pyrpl/config/global_config.yml
python setup.py install
'''
sh "$NOSETESTS_COMMAND" }}
post { always { junit allowEmptyResults: true, testResults: 'unit_test_results.xml' }}}
stage('Python 3.6') {
agent { dockerfile { args "$DOCKER_ARGS"
additionalBuildArgs '--build-arg PYTHON_VERSION=3.6' }}
steps { lock('redpitaya') {
sh ''' which python
python -V
echo $PYTHON_VERSION
conda list
# use a custom global configfile adapted to the hardware for unit tests
cp ./jenkins_global_config.yml ./pyrpl/config/global_config.yml
python setup.py install
'''
sh "$NOSETESTS_COMMAND"}}
post { always { junit allowEmptyResults: true, testResults: 'unit_test_results.xml' }}}
/*stage('Python 3.5') {
agent { dockerfile { args "$DOCKER_ARGS"
additionalBuildArgs '--build-arg PYTHON_VERSION=3.5' }}
steps {
sh ''' which python
python -V
echo $PYTHON_VERSION
conda list
# use a custom global configfile adapted to the hardware for unit tests
cp ./jenkins_global_config.yml ./pyrpl/config/global_config.yml
python setup.py install
'''
sh "$NOSETESTS_COMMAND"}
post { always { junit allowEmptyResults: true, testResults: 'unit_test_results.xml' }}}*/
stage('Python 2.7') {
agent { dockerfile { args "$DOCKER_ARGS"
additionalBuildArgs '--build-arg PYTHON_VERSION=2.7' }}
steps { lock('redpitaya') {
sh ''' which python
python -V
echo $PYTHON_VERSION
conda list
# use a custom global configfile adapted to the hardware for unit tests
cp ./jenkins_global_config.yml ./pyrpl/config/global_config.yml
python setup.py install
'''
sh "$NOSETESTS_COMMAND"}}
post { always { junit allowEmptyResults: true, testResults: 'unit_test_results.xml' }}}
stage('Linux binary') {
agent { dockerfile { args '-u root -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=:0 --net=host'
additionalBuildArgs '--build-arg PYTHON_VERSION=3.7' }}
steps { lock('fake_redpitaya') {
sh ''' apt-get install psmisc
python setup.py install
pip install https://github.com/lneuhaus/pyinstaller/tarball/develop
pyinstaller pyrpl.spec
mv dist/pyrpl ./pyrpl-linux-jenkins
chmod 755 pyrpl-linux-jenkins
(./pyrpl-linux-jenkins config=test_linux_jenkins hostname=_FAKE_ &)
PYRPL_PID=$!
sleep 30
kill -9 $PYRPL_PID
'''
sh 'python .deploy_to_sourceforge.py pyrpl-linux /home/frs/project/pyrpl/branches/$GIT_BRANCH/'
}}
post { always { archiveArtifacts allowEmptyArchive: true, artifacts: 'pyrpl-linux', fingerprint: true }}}
stage('pip wheel') {
agent { dockerfile { args '-u root -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=:0 --net=host'
additionalBuildArgs '--build-arg PYTHON_VERSION=3.7' }}
steps { lock('fake_redpitaya') {
sh ''' python setup.py install
# convert readme file to rst for PyPI
conda install pandoc
pandoc --from=markdown --to=rst --output=README.rst README.md
# make distributions for PyPI
python setup.py sdist
python setup.py bdist_wheel --universal
# upload to PyPI
# twine upload dist/**/*.*
'''}}
post { always { archiveArtifacts allowEmptyArchive: true, artifacts: 'dist/**/*.*', fingerprint: true}}}
}}
stage('Deploy') {
agent { dockerfile { args '-u root -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=:0 --net=host'
additionalBuildArgs '--build-arg PYTHON_VERSION=3.7' }}
when { buildingTag() }
steps {
sh ''' mkdir $TAG_NAME
cp pyrpl-linux-jenkins $TAG_NAME/
python .deploy_to_sourceforge.py $TAG_NAME /home/frs/project/pyrpl
python .deploy_to_sourceforge.py pyrpl-linux-jenkins /home/frs/project/pyrpl/current-release/
'''}}
}
post {
failure {
emailext (
attachLog: true,
subject: "FAILED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'",
body: """<p>FAILED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]':</p>
<p>Check console output at <a href='${env.BUILD_URL}'>${env.JOB_NAME} [${env.BUILD_NUMBER}]</a></p>""",
compressLog: false,
recipientProviders: [requestor(), developers(), brokenTestsSuspects(), brokenBuildSuspects(), upstreamDevelopers(), culprits()],
replyTo: 'pyrpl.readthedocs.io@gmail.com',
to: 'pyrpl.readthedocs.io@gmail.com')
setBuildStatus("Build failed!", "FAILURE")
}
success { setBuildStatus("Build successful!", "SUCCESS") }
unstable { setBuildStatus("Build erroneous!", "ERROR") }
}
}