-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathJenkinsfile
188 lines (161 loc) · 6.31 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
#!/usr/bin/env groovy
pipeline {
/* Agent directive is required. */
agent { node { label 'imce-infr-dev-01.jpl.nasa.gov' } }
/* The following is NOT supported currently! (see below for a workaround) */
// tools {
// sbt 'default-sbt' // Even specifying the suggested org.jvnet.hudson.plugins.SbtPluginBuilder$SbtInstallation does not work
// }
parameters {
string(name: 'VERSION_ONTOLOGIES', defaultValue: '1.+', description: '')
/* Unfortunately, SCM environment variables are currently not available in Jenkinsfile. */
string(name: 'VERSION_PROFILES', defaultValue: '{env.BUILD_TAG}', description: 'The version of the profile resource to produce.')
/* What to perform during build */
string(name: 'BOOTSTRAP_BUILDS', defaultValue: 'TRUE', description: 'Whether or not to bootstrap subsequent builds and calculate dependencies. It makes no sense to skip this step.')
string(name: 'VALIDATE_ONTOLOGIES', defaultValue: 'TRUE', description: 'Whether or not to validate ontologies. It has a side effect of loading ontologies into Fuseki.')
string(name: 'BUILD_DIGESTS', defaultValue: 'TRUE', description: 'Whether or not to build digests. This may be forced if not done previously before other, dependent steps (i.e., profile generation).')
string(name: 'BUILD_PROFILES', defaultValue: 'TRUE', description: 'Whether or not to generate profiles and build the profile resource.')
string(name: 'OML_REPO', defaultValue: 'undefined', description: 'Repository where OML data to be converted is stored.')
}
environment {
GEM_HOME = '/home/jenkins/.rvm/gems/jruby-1.7.19'
PATH = '$PATH:/home/jenkins/.rvm/gems/jruby-1.7.19/bin:/home/jenkins/.rvm/gems/jruby-1.7.19@global/bin:/home/jenkins/.rvm/rubies/jruby-1.7.19/bin:/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/jenkins/.rvm/bin'
SBT_OPTIONS = '-batch -no-colors'
VNC_OUT = './vnc.out'
}
stages {
stage('Setup') {
steps {
echo "Setting up environment..."
sh "env"
sh "sbt $SBT_OPTIONS clean cleanFiles"
sh "sbt $SBT_OPTIONS -Dproject.version=${params.VERSION_PROFILES} setupTools setupOntologies"
// Decrypt files
// TODO Add OpenSSL installation as prerequisite to readme?
// TODO Add environment variable?
withCredentials([string(credentialsId: 'ENCRYPTION_PASSWORD', variable: 'ENCRYPTION_PASSWORD')]) {
sh "scripts/jenkins-decode.sh"
}
// setup Fuseki, ontologies, tools, environment
}
}
stage('OML to OWL') {
when {
expression { params.OML_REPO != 'undefined' }
}
steps {
echo "Converting OML to OWL..."
// TODO Move cloning to checkout stage?
sh "rm -rf target/ontologies" // Need to make sure it's empty before cloning
sh "mkdir -p target/ontologies; cd target/ontologies; git clone ${OML_REPO} ."
// Invoke the convertOntologies SBT task
//sh "sbt $SBT_OPTIONS -Dproject.version=${params.VERSION_PROFILES} setupOMLConverter"
//sh "sbt $SBT_OPTIONS -Dproject.version=${params.VERSION_PROFILES} convertOntologies"
}
}
stage('Bootstrap Builds') {
when {
expression { params.BOOTSTRAP_BUILDS == 'TRUE' }
}
steps {
echo "Bootstrapping builds..."
sh "cd workflow; source ./env.sh; /usr/bin/make bootstrap"
sh "cd workflow; source ./env.sh; /usr/bin/make validation-dependencies"
// run makefile command, same for others below
}
}
stage('Validate Ontologies') {
when {
expression { params.VALIDATE_ONTOLOGIES == 'TRUE' }
}
steps {
echo "Validating ontologies and loading into Fuseki..."
sh "cd workflow; source ./env.sh; /usr/bin/make validate-xml"
sh "cd workflow; source ./env.sh; /usr/bin/make validate-owl"
sh "cd workflow; source ./env.sh; /usr/bin/make validate-groups"
sh "cd workflow; source ./env.sh; /usr/bin/make validate-bundles"
// run makefile command, same for others below
}
}
stage('Build Digests') {
when {
expression { params.BUILD_DIGESTS == 'TRUE' }
}
steps {
echo "Generating digests..."
sh "cd workflow; source ./env.sh; /usr/bin/make digests"
}
}
stage('Compile Profile Generator') {
when {
expression { params.BUILD_PROFILES == 'TRUE' }
}
steps {
echo "Compiling workflow unit..."
// Thanks to https://gist.github.com/muuki88/e2824008b653ac0fc5ba749fdf249616 for this one!
sh "sbt $SBT_OPTIONS -Dproject.version=${params.VERSION_PROFILES} compile test:compile"
//archiveArtifacts artifacts: '**/target/*.jar', fingerprint: true
}
}
stage('Build Profiles') {
/*
* Note: this step requires digests to exist already!
*/
when {
expression { params.BUILD_PROFILES == 'TRUE' }
}
post {
always {
// Kill vnc display
sh "test -f $VNC_OUT && vncserver -kill `sed -n 's/^New.*\\(:[0-9][0-9]*\\)/\\1/p' $VNC_OUT`"
}
}
steps {
echo "Building profiles..."
// Kill old display and start VNC Server for headless MD
sh "vncserver -SecurityTypes None 2>&1 | tee $VNC_OUT"
/*
* The following inline shell conditional ensures that the shell
* step always sees a zero exit code, giving the later junit step
* an opportunity to capture and process the test reports.
*/
//sh ' || true'
sh "sbt $SBT_OPTIONS -Dproject.version=${params.VERSION_PROFILES} setupProfileGenerator"
sh "cd workflow; source ./env.sh; export DISPLAY=`sed -n 's/^New.*\\(:[0-9][0-9]*\\)/\\1/p' $VNC_OUT`;/usr/bin/make profiles"
}
}
stage('Build Profile Resource') {
when {
expression { params.BUILD_PROFILES == 'TRUE' }
}
steps {
echo "Building profile resource..."
sh "sbt $SBT_OPTIONS -Dproject.version=${params.VERSION_PROFILES} packageProfiles"
}
}
stage('Deploy') {
/*
* In addition to the below guard, jenkins-deploy.sh will check whether
* or not a tag is associated with the current commit. *Note*:
* unfortunately, Jenkins currently does not make any parameters for git
* available within pipeline scripts - hence the externalization of the
* logic.
*/
when {
expression {
currentBuild.result == null || currentBuild.result == 'SUCCESS'
}
}
steps {
sh 'scripts/jenkins-deploy.sh'
//sh "sbt $SBT_OPTIONS -Dproject.version=${params.VERSION_PROFILES} publish"
//sh 'scripts/jenkins-publish.sh'
}
}
}
post {
always {
junit 'target/**/*.xml'
}
}
}