This repository has been archived by the owner on Nov 28, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Jenkinsfile
170 lines (113 loc) · 5.81 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
#!/usr/bin/env groovy
import groovy.json.JsonOutput
import java.util.Optional
import hudson.tasks.test.AbstractTestResultAction
import hudson.model.Actionable
import hudson.tasks.junit.CaseResult
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
author = ""
message = ""
channel = "#project-sequila"
sbtOpts = "'-XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=2G -Xmx4G'"
def getGitAuthor = {
def commit = sh(returnStdout: true, script: 'git rev-parse HEAD')
author = sh(returnStdout: true, script: "git --no-pager show -s --format='%an' ${commit}").trim()
}
def getLastCommitMessage = {
message = sh(returnStdout: true, script: 'git log -1 --pretty=%B').trim()
}
def populateGlobalVariables = {
getLastCommitMessage()
getGitAuthor()
println author
println message
}
def notifySlack = {
JSONArray attachments = new JSONArray();
JSONObject attachment = new JSONObject();
JSONArray fields = new JSONArray();
JSONObject authorField = new JSONObject();
authorField.put("title","Author")
authorField.put("value",author)
JSONObject msgField = new JSONObject();
msgField.put("title","Last commit")
msgField.put("value",message)
JSONObject jobField = new JSONObject();
jobField.put("title","Job name")
jobField.put("value",env.JOB_NAME)
JSONObject linkField = new JSONObject();
linkField.put("title","Jenkins link")
linkField.put("value",env.BUILD_URL.replace("http://","http://www."))
JSONObject statusField = new JSONObject();
statusField.put("title","Build status")
statusField.put("value",buildStatus)
fields.add(jobField)
fields.add(authorField)
fields.add(msgField)
fields.add(linkField)
fields.add(statusField)
attachment.put('text',"Another great piece of code has been tested...");
attachment.put('fallback','Hey, Vader seems to be mad at you.');
attachment.put("fields",fields)
attachment.put('color',buildColor);
attachments.add(attachment);
slackSend(bot:false, channel: channel, attachments: attachments.toString())
}
node {
stage('Checkout') {
checkout scm
}
populateGlobalVariables()
try {
stage('Package sequila-py') {
sh 'bash -c "source /sequila/bin/activate && cd python && python3.6 setup.py sdist bdist_wheel && twine check dist/* && twine upload -r zsibio dist/* && deactivate"'
}
stage('Test Scala code') {
echo 'Testing Scala code....'
sh "SBT_OPTS=${sbtOpts} ${tool name: 'sbt-0.13.15', type: 'org.jvnet.hudson.plugins.SbtPluginBuilder$SbtInstallation'}/bin/sbt clean test"
}
stage('Package scala code') {
//echo 'Building Scala code....'
//sh "${tool name: 'sbt-0.13.15', type: 'org.jvnet.hudson.plugins.SbtPluginBuilder$SbtInstallation'}/bin/sbt package"
echo "Generating documentation"
sh "SBT_OPTS=${sbtOpts} ${tool name: 'sbt-0.13.15', type: 'org.jvnet.hudson.plugins.SbtPluginBuilder$SbtInstallation'}/bin/sbt doc"
//publishHTML([allowMissing: false, alwaysLinkToLastBuild: true, keepAll: false, reportDir: 'target/scala-2.11/api/', reportFiles: 'package.html', reportName: 'Scala Doc', reportTitles: ''])
}
stage('Publish to Nexus snapshots and dopy DAGs') {
echo "branch: ${env.BRANCH_NAME}"
echo 'Publishing to ZSI-BIO snapshots repository....'
sh "SBT_OPTS=${sbtOpts} ${tool name: 'sbt-0.13.15', type: 'org.jvnet.hudson.plugins.SbtPluginBuilder$SbtInstallation'}/bin/sbt 'set test in publish := {}' publish"
}
stage('Code stats') {
echo 'Gathering code stats....'
sh "SBT_OPTS=${sbtOpts} ${tool name: 'sbt-0.13.15', type: 'org.jvnet.hudson.plugins.SbtPluginBuilder$SbtInstallation'}/bin/sbt stats"
}
stage('Readthedocs') {
echo 'Generating readthedocs....'
publishHTML([allowMissing: false, alwaysLinkToLastBuild: false, keepAll: false, reportDir: 'docs/build/html/', reportFiles: 'index.html', reportName: 'Readthedocs', reportTitles: ''])
sh './build_docs.sh'
}
// stage('Building Docker images') {
//
// echo 'Building Docker images....'
// sh './build.sh'
//
// }
stage('Performance testing') {
sh "SBT_OPTS=${sbtOpts} ${tool name: 'sbt-0.13.15', type: 'org.jvnet.hudson.plugins.SbtPluginBuilder$SbtInstallation'}/bin/sbt 'set test in assembly := {}' assembly"
sh "ssh bdg-perf@cdh00 rm -rf /tmp/bdg-sequila-assembly-*.jar"
sh "scp target/scala-2.11/bdg-sequila-assembly-*.jar bdg-perf@cdh00:/tmp"
sh "scp performance/bdg_perf/bdg_perf_sequila.scala bdg-perf@cdh00:/tmp"
sh 'ssh bdg-perf@cdh00 ". ~/.profile; spark-shell --conf spark.sql.catalogImplementation=in-memory --conf spark.hadoop.yarn.timeline-service.enabled=false --principal [email protected] --keytab /data/work/home/bdg-perf/keytabs/bdg-perf.keytab --master=yarn-client --executor-memory=3g --num-executors=40 --executor-cores=1 --driver-memory=8g -i /tmp/bdg_perf_sequila.scala --packages org.postgresql:postgresql:42.1.1 --conf spark.biodatageeks.perf.testId=$BRANCH_NAME --jars /tmp/bdg-sequila-assembly-*.jar -v"'
sh './build_perf_report.sh'
}
}
catch (e){currentBuild.result="FAIL"}
stage('Notify'){
junit '**/target/test-reports/*.xml'
buildColor = currentBuild.result == null ? "good" : "danger"
buildStatus = currentBuild.result == null ? "SUCCESS:clap:" : currentBuild.result+":cry:"
notifySlack()
}
}