-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
199 lines (195 loc) · 8.94 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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
pipeline {
agent { label 'docker' }
environment {
COLLECTOR_IMAGE = "gros-data-analysis-dashboard"
PREDICTOR_TAG = env.BRANCH_NAME.replaceFirst('^master$', 'latest')
PREDICTOR_NAME = "gros-prediction"
PREDICTOR_IMAGE = "${env.PREDICTOR_NAME}:${env.PREDICTOR_TAG}"
GITLAB_TOKEN = credentials('prediction-gitlab-token')
SCANNER_HOME = tool name: 'SonarQube Scanner 3', type: 'hudson.plugins.sonar.SonarRunnerInstallation'
}
parameters {
string(name: 'PREDICTION_ARGS', defaultValue: '--label num_not_done_points+num_removed_points+num_added_points --binary --roll-sprints --roll-validation --roll-labels --replace-na --model dnn --test-interval 200 --num-epochs 1000', description: 'Prediction arguments')
string(name: 'PREDICTION_ORGANIZATIONS', defaultValue: "${env.PREDICTION_ORGANIZATIONS}", description: 'Organizations to include in prediction')
}
options {
gitLabConnection('gitlab')
buildDiscarder(logRotator(numToKeepStr: '10'))
}
triggers {
gitlab(triggerOnPush: true, triggerOnMergeRequest: true, branchFilterType: 'All', secretToken: env.GITLAB_TOKEN)
cron(env.PREDICTION_CRON)
}
post {
success {
archiveArtifacts artifacts: 'output/**/*.json,output/sprint_features.arff,schema/**/*.json', onlyIfSuccessful: true
updateGitlabCommitStatus name: env.JOB_NAME, state: 'success'
}
failure {
updateGitlabCommitStatus name: env.JOB_NAME, state: 'failed'
}
aborted {
updateGitlabCommitStatus name: env.JOB_NAME, state: 'canceled'
}
}
stages {
stage('Build') {
steps {
checkout scm
sh 'docker build -t $DOCKER_REPOSITORY/$PREDICTOR_IMAGE . --build-arg TENSORFLOW_VERSION=$TENSORFLOW_VERSION'
}
}
stage('Push') {
steps {
withDockerRegistry(credentialsId: 'docker-credentials', url: env.DOCKER_URL) {
sh 'docker push $DOCKER_REPOSITORY/$PREDICTOR_IMAGE'
}
}
}
stage('SonarQube Analysis') {
when {
not {
triggeredBy 'TimerTrigger'
}
}
steps {
withPythonEnv('System-CPython-3.6') {
pysh 'python -m pip install pylint tensorflow==1.10.1 -r requirements.txt'
pysh 'python -m pylint prediction files.py tensor.py --exit-zero --reports=n --msg-template="{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}" -d duplicate-code > pylint-report.txt'
}
withSonarQubeEnv('SonarQube') {
sh '${SCANNER_HOME}/bin/sonar-scanner -Dsonar.projectKey=prediction:$BRANCH_NAME -Dsonar.projectName="Prediction $BRANCH_NAME"'
}
}
}
stage('Early exit') {
when {
not {
triggeredBy 'TimerTrigger'
}
not {
triggeredBy 'UserIdCause'
}
branch pattern: ".*time-machine\$", comparator: "REGEXP"
}
steps {
script {
currentBuild.getRawBuild().getExecutor().interrupt(Result.UNSTABLE)
sleep(1)
}
}
}
stage('Collect') {
agent {
docker {
image "${env.COLLECTOR_IMAGE}"
registryUrl "${env.DOCKER_URL}"
registryCredentialsId 'docker-credentials'
reuseNode true
}
}
steps {
withCredentials([file(credentialsId: 'data-analysis-config', variable: 'ANALYSIS_CONFIGURATION')]) {
sh "/bin/bash -cex \"rm -rf \$WORKSPACE/output; mkdir \$WORKSPACE/output; cd /home/docker; for org in ${params.PREDICTION_ORGANIZATIONS}; do Rscript features.r --core --log INFO --config $ANALYSIS_CONFIGURATION $REPORT_PARAMS --output \$WORKSPACE/output --filename sprint_features.${env.BUILD_TAG}.arff --append --org \\\$org; done\""
}
}
}
stage('Upload') {
when {
beforeAgent true
environment name: 'PREDICTOR_REMOTE', value: 'true'
}
agent {
docker {
image "${env.PREDICTOR_IMAGE}"
registryUrl "${env.DOCKER_URL}"
registryCredentialsId 'docker-credentials'
args '-v /usr/local/share/ca-certificates/:/usr/local/share/ca-certificates/'
label 'master'
reuseNode true
}
}
steps {
withCredentials([file(credentialsId: 'prediction-config', variable: 'PREDICTOR_CONFIGURATION')]) {
sh "python files.py --upload output/sprint_features.${env.BUILD_TAG}.arff --config $PREDICTOR_CONFIGURATION"
}
}
}
stage('Predict') {
when {
beforeAgent true
not { environment name: 'PREDICTOR_REMOTE', value: 'true' }
}
agent {
docker {
image "${env.PREDICTOR_IMAGE}"
registryUrl "${env.DOCKER_URL}"
registryCredentialsId 'docker-credentials'
reuseNode true
}
}
steps {
sh "python tensor.py --filename output/sprint_features.${env.BUILD_TAG}.arff --log INFO --seed 123 --clean ${params.PREDICTION_ARGS} --results output/sprint_labels.${env.BUILD_TAG}.json"
}
}
stage('Predict remote GPU') {
when {
beforeAgent true
environment name: 'PREDICTOR_REMOTE', value: 'true'
}
agent {
docker {
image "${env.PREDICTOR_IMAGE}"
registryUrl "${env.DOCKER_URL}"
registryCredentialsId 'docker-credentials'
args '--runtime=nvidia -v /usr/local/share/ca-certificates/:/usr/local/share/ca-certificates/'
label 'gpu'
alwaysPull true
}
}
steps {
withCredentials([file(credentialsId: 'prediction-config', variable: 'PREDICTOR_CONFIGURATION')]) {
sh "CUDA_VISIBLE_DEVICES=${env.EXECUTOR_NUMBER} python tensor.py --filename output/sprint_features.${env.BUILD_TAG}.arff --log INFO --seed 123 --clean ${params.PREDICTION_ARGS} --results output/sprint_labels.${env.BUILD_TAG}.json --store owncloud --device /gpu:${env.EXECUTOR_NUMBER} --config $PREDICTOR_CONFIGURATION"
}
}
}
stage('Download') {
when {
beforeAgent true
environment name: 'PREDICTOR_REMOTE', value: 'true'
}
agent {
docker {
image "${env.PREDICTOR_IMAGE}"
registryUrl "${env.DOCKER_URL}"
registryCredentialsId 'docker-credentials'
args '-v /usr/local/share/ca-certificates/:/usr/local/share/ca-certificates/'
label 'master'
reuseNode true
}
}
steps {
withCredentials([file(credentialsId: 'prediction-config', variable: 'PREDICTOR_CONFIGURATION')]) {
sh "python files.py --download output/sprint_labels.${env.BUILD_TAG}.json --remove output/sprint_features.${env.BUILD_TAG}.arff output/sprint_labels.${env.BUILD_TAG}.json --config $PREDICTOR_CONFIGURATION"
}
}
}
stage('Format') {
agent {
docker {
image "${env.COLLECTOR_IMAGE}"
registryUrl "${env.DOCKER_URL}"
registryCredentialsId 'docker-credentials'
reuseNode true
}
}
steps {
withCredentials([file(credentialsId: 'data-analysis-config', variable: 'ANALYSIS_CONFIGURATION')]) {
sh "/bin/bash -cex \"cd /home/docker; for org in ${params.PREDICTION_ORGANIZATIONS}; do Rscript sprint_results.r --file \$WORKSPACE/output/sprint_labels.${env.BUILD_TAG}.json --features \$WORKSPACE/output/sprint_features.${env.BUILD_TAG}.arff --config $ANALYSIS_CONFIGURATION --output \$WORKSPACE/output $REPORT_PARAMS --org \\\$org; if [ -e \$WORKSPACE/output/\\\$org/descriptions.json ]; then cp \$WORKSPACE/output/\\\$org/descriptions.json \$WORKSPACE/output/; fi; done\""
sh "mv output/sprint_labels.${env.BUILD_TAG}.json output/sprint_labels.json"
sh "mv output/sprint_features.${env.BUILD_TAG}.arff output/sprint_features.arff"
}
}
}
}
}