-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathJenkinsfile
More file actions
136 lines (131 loc) · 4.48 KB
/
Jenkinsfile
File metadata and controls
136 lines (131 loc) · 4.48 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
#!/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=processing_library --cov=processing_components --cov=workflows --cov-report=html:coverage tests
'''
//Make coverage report
//coverage html --include=processing_library/*,processing_components/*,workflows/* -d coverage
}
}
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'
slackSend baseUrl: 'https://sdp-execution-engine.slack.com/services/hooks/jenkins-ci/',
channel: '#jenkins',
color: 'good',
message: "Pipeline ${currentBuild.fullDisplayName} ${env.JOB_NAME} ${env.BUILD_NUMBER} completed with Status: ${env.BUILD_STATUS} (<${env.BUILD_URL}|Open>)",
tokenCredentialId: 'a06474f9-0c86-4dc7-a477-42d7d1a1cc71'
}
failure {
mail to: 'pw410@cam.ac.uk, realtimcornwell@gmail.com F.Wang@skatelescope.org',
subject: "Failed Jenkins Pipeline: ${currentBuild.fullDisplayName} Status:${env.BUILD_STATUS} ",
body: "Something is wrong with ${env.BUILD_URL} Status: ${env.BUILD_STATUS} "
}
fixed {
mail to: 'pw410@cam.ac.uk, realtimcornwell@gmail.com F.Wang@skatelescope.org',
subject: "Jenkins Pipeline is back to normal: ${currentBuild.fullDisplayName} Status:${env.BUILD_STATUS} ",
body: "See ${env.BUILD_URL}"
}
success {
sshPublisher alwaysPublishFromMaster: true,
publishers: [sshPublisherDesc(configName: 'vm12',
transfers: [sshTransfer(excludes: '',
execCommand: '', execTimeout: 120000,
flatten: false,
makeEmptyDirs: false,
noDefaultExcludes: false,
patternSeparator: '[, ]+',
remoteDirectory: 'algorithm-reference-library',
remoteDirectorySDF: false,
removePrefix: '',
sourceFiles: 'docs/build/**'),
sshTransfer(excludes: '',
execCommand: '', execTimeout: 120000,
flatten: false,
makeEmptyDirs: false,
noDefaultExcludes: false,
patternSeparator: '[, ]+',
remoteDirectory: 'algorithm-reference-library',
remoteDirectorySDF: false,
removePrefix: '',
sourceFiles: 'coverage/**')],
usePromotionTimestamp: false,
useWorkspaceInPromotion: false,
verbose: false)]
}
}
}