-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
231 lines (214 loc) · 8.89 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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
#!groovy
/**
* This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v2.0 which accompanies
* this distribution, and is available at https://www.eclipse.org/legal/epl-v20.html
*
* SPDX-License-Identifier: EPL-2.0
*
* Copyright Contributors to the Zowe Project.
*/
properties([
buildDiscarder(logRotator(numToKeepStr: "25")),
disableConcurrentBuilds(),
parameters([
string(
name: "BUILD_SERVER_HOST",
description: "z/OS server host name to build",
defaultValue: "zzow01.zowe.marist.cloud",
trim: true,
required: true
),
string(
name: "BUILD_SERVER_SSH_PORT",
description: "SSH port of build server.",
defaultValue: "22",
trim: true,
required: true
),
credentials(
name: "BUILD_SERVER_SSH_CREDENTIAL",
description: "The SSH credential used to connect to build server",
credentialType: "com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl",
defaultValue: "ssh-marist-server-zzow01",
required: true
),
string(
name: "BUILD_SERVER_TMPDIR",
description: "z/OS server tmp folder",
defaultValue: "/ZOWE/tmp",
trim: true,
required: true
),
string(
name: "JAVA_HOME",
description: "Java installation directory",
defaultValue: "/usr/lpp/java/J8.0_64",
trim: true,
required: true
),
string(
name: "ANT_HOME",
description: "Ant installation directory",
defaultValue: "/ZOWE/apache-ant-1.10.5",
trim: true,
required: true
),
string(
name: "XLC_DATASET",
description: "z/OS XL C/C++ installation dataset",
defaultValue: "CBC.SCCNCMP",
trim: true,
required: true
),
string(
name: "ARTIFACTORY_SERVER",
description: "Artifactory server",
defaultValue: "gizaArtifactory",
trim: true,
required: true
),
string(
name: "ARTIFACTORY_REPO",
description: "Artifactory repository to deploy ZSS",
defaultValue: "libs-snapshot-local/org/zowe/zss",
trim: true,
required: true
),
string(
name: "ZOWE_MANIFEST_URL",
description: "Zowe template manifest URL",
defaultValue: "https://raw.githubusercontent.com/zowe/zowe-install-packaging/master/manifest.json.template",
trim: true,
required: true
)
])
])
def getZoweVersion() {
def response = httpRequest url: params.ZOWE_MANIFEST_URL
echo "Zowe manifest template:\n${response.content}"
return (response.content =~ /"version"\s*:\s*"(.*)"/)[0][1]
}
withCredentials([usernamePassword(
credentialsId: params.BUILD_SERVER_SSH_CREDENTIAL,
usernameVariable: "BUILD_SERVER_USERNAME",
passwordVariable: "BUILD_SERVER_PASSWORD"
)]) {
node("ibm-jenkins-slave-nvm") {
try {
currentBuild.result = "SUCCESS"
def buildDir = "${params.BUILD_SERVER_TMPDIR}/~${env.BUILD_TAG}"
def buildServer = [
name : params.BUILD_SERVER_HOST,
host : params.BUILD_SERVER_HOST,
port : params.BUILD_SERVER_SSH_PORT.toInteger(),
user : BUILD_SERVER_USERNAME,
password : BUILD_SERVER_PASSWORD,
allowAnyHosts: true
]
def zoweVersion = getZoweVersion()
stage("Checkout") {
dir("zss") {
checkout scm
}
sh "cd zss && git submodule update --init --recursive"
}
stage("Prepare") {
def (majorVersion, minorVersion, microVersion) = zoweVersion.tokenize(".")
sh \
"""
cd zss/build
sed -i "s/MAJOR_VERSION=0/MAJOR_VERSION=${majorVersion}/" version.properties
sed -i "s/MINOR_VERSION=0/MINOR_VERSION=${minorVersion}/" version.properties
sed -i "s/REVISION=0/REVISION=${microVersion}/" version.properties
"""
sh "tar cf source.tar zss"
sshCommand remote: buildServer, command: "rm -rf ${buildDir} && mkdir -p ${buildDir}"
sshPut remote: buildServer, from: "source.tar", into: buildDir
sshCommand remote: buildServer, command: \
"""
cd ${buildDir} &&
pax -r -x tar -o to=IBM-1047 -f source.tar
"""
}
stage("Build") {
sshCommand remote: buildServer, command: \
"""
export JAVA_HOME=${params.JAVA_HOME} &&
export ANT_HOME=${params.ANT_HOME} &&
export STEPLIB=${params.XLC_DATASET} &&
cd ${buildDir}/zss/build &&
${params.ANT_HOME}/bin/ant
"""
}
stage("Package") {
sshCommand remote: buildServer, command: \
"""
cd ${buildDir} &&
mkdir LOADLIB &&
mkdir SAMPLIB &&
cp -X "//DEV.LOADLIB(ZWESIS01)" LOADLIB/ZWESIS01 &&
cp -X "//DEV.LOADLIB(ZWESAUX)" LOADLIB/ZWESAUX &&
cp zss/samplib/zis/* SAMPLIB/ &&
cp zss/bin/zssServer ./ &&
extattr +p zssServer &&
pax -x os390 -w -f zss.pax SAMPLIB LOADLIB zssServer
"""
sshGet remote: buildServer, from: "${buildDir}/zss.pax", into: "zss.pax"
sshCommand remote: buildServer, command: "rm -rf ${buildDir}"
}
stage("Publish") {
def target = "${params.ARTIFACTORY_REPO}/" +
"${zoweVersion}-${getReleaseIdentifier()}/" +
"zss-${zoweVersion}-${getBuildIdentifier(true, '__EXCLUDE__', true)}.pax"
def uploadSpec = \
"""
{"files":
[
{
"pattern": "zss.pax",
"target": "${target}"
}
]
}
"""
echo "Artifactory upload spec:"
echo uploadSpec
def artifactoryServer = Artifactory.server params.ARTIFACTORY_SERVER
def buildInfo = Artifactory.newBuildInfo()
artifactoryServer.upload spec: uploadSpec, buildInfo: buildInfo
artifactoryServer.publishBuildInfo buildInfo
}
} catch (e) {
currentBuild.result = "FAILURE"
throw e
} finally {
stage("Report") {
def prettyParams = ""
params.each{ key, value -> prettyParams += "<br/> ${key} = '${value}'"}
emailext \
subject: """${env.JOB_NAME} [${env.BUILD_NUMBER}]: ${currentBuild.result}""",
attachLog: true,
mimeType: "text/html",
recipientProviders: [
[$class: "RequesterRecipientProvider"],
[$class: "CulpritsRecipientProvider"],
[$class: "DevelopersRecipientProvider"],
[$class: "UpstreamComitterRecipientProvider"]
],
body: \
"""
<p><b>${currentBuild.result}</b></p>
<hr/>
<ul>
<li>Duration: ${currentBuild.durationString[0..-14]}</li>
<li>Build link: <a href="${env.RUN_DISPLAY_URL}">
${env.JOB_NAME} [${env.BUILD_NUMBER}]</a></li>
<li>Parameters: ${prettyParams}</li>
</ul>
<hr/>
"""
}
}
}
}