-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
118 lines (115 loc) · 3.64 KB
/
Jenkinsfile
File metadata and controls
118 lines (115 loc) · 3.64 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
#!/usr/bin/env groovy
// Jenkinsfile (Declarative pipeline)
//
// https://jenkins.io/doc/book/pipeline/jenkinsfile/
//
// Stages section:
// - Setup
// - Build
// - Test
// - Deploy
//
// Post section: (https://jenkins.io/doc/book/pipeline/syntax/#post)
pipeline {
agent {label 'sdp-ci-01'}
environment {
MPLBACKEND='agg'
ARLROOT="${env.WORKSPACE}"
}
stages {
// We can skip checkout step if Jenkinsfile is in same repo as the source code (the checkout is configured in Jenkins server, note that we need to enable git-lfs!
// stage('Checkout'){
// steps {
// echo 'Checking out repository'
// checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'CleanBeforeCheckout'], [$class: 'GitLFSPull']], submoduleCfg: [], userRemoteConfigs: [[credentialsId: '2ca2f96d-f272-46d1-accf-8b64a4a0a48e', url: 'https://github.com/mfarrera/algorithm-reference-library']]])
//checkout scm
// }
// }
stage('Setup') {
steps {
echo "Running ${env.BUILD_ID} on ${env.JENKINS_URL}"
echo 'Setting up a fresh Python virtual environment...'
sh '''
virtualenv -p `which python3` _build
echo 'Activating virtual environment...'
source _build/bin/activate
echo 'Installing requirements'
pip install -U pip setuptools
pip install coverage numpy
pip install virtualenvwrapper
pip install -r requirements.txt
echo 'Adding the arl and ffiwrappers path to the virtual environment'
echo '(equivalent to setting up PYTHONPATH environment variable'
source virtualenvwrapper.sh
add2virtualenv $WORKSPACE
add2virtualenv $WORKSPACE/ffiwrappers/src
'''
}
}
stage('Build'){
steps {
echo 'Building..'
sh '''
source _build/bin/activate
export LDFLAGS="$(python3-config --ldflags) -lcfitsio"
python setup.py install
'''
}
}
stage('TestARL') {
steps {
echo 'Testing ARL..'
sh '''
source _build/bin/activate
export MPLBACKEND=agg
pip install pytest pytest-xdist pytest-cov
py.test tests -n 4 --verbose --cov=libs --cov=processing_components --cov=workflows --cov-report=html:coverage tests
'''
//Make coverage report
//coverage html --include=libs/*,processing_components/*,workflows/* -d coverage
}
}
stage('TestFfiwrappers') {
steps {
echo 'Testing ffiwrappers..'
sh '''
source _build/bin/activate
export ARLROOT=$WORKSPACE
source tests/ffiwrapped/run-tests.sh
'''
}
}
stage('Deploy') {
steps {
echo 'Make documentation....'
sh '''
source _build/bin/activate
export MPLBACKEND=agg
make -k -j -C docs html
'''
// make -C docs latexpdf # Broken currently?
}
}
}
post {
always {
echo 'FINISHED'
}
failure {
mail to: 'mf582@mrao.cam.ac.uk, pw410@cam.ac.uk, realtimcornwell@gmail.com',
subject: "Failed Jenkins Pipeline: ${currentBuild.fullDisplayName}",
body: "Something is wrong with ${env.BUILD_URL}"
}
fixed {
mail to: 'mf582@mrao.cam.ac.uk, pw410@cam.ac.uk, realtimcornwell@gmail.com',
subject: "Jenkins Pipeline is back to normal: ${currentBuild.fullDisplayName}",
body: "See ${env.BUILD_URL}"
}
// We could send slack notifications but pluggin needs to be installed and configured at server
// success {
// slackSend channel: '#ops-room',
// color: 'good',
// message: "The pipeline ${currentBuild.fullDisplayName} completed successfully."
// }
}
}