forked from zowe/zowe-install-packaging
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
156 lines (138 loc) · 5.23 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
#!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 IBM Corporation 2018, 2019
*/
node('ibm-jenkins-slave-nvm') {
def lib = library("jenkins-library").org.zowe.jenkins_shared_library
def pipeline = lib.pipelines.generic.GenericPipeline.new(this)
def manifest
pipeline.admins.add("jackjia", "stevenh", "joewinchester", "markackert")
// we have extra parameters for integration test
pipeline.addBuildParameters(
booleanParam(
name: 'BUILD_SMPE',
description: 'If we want to build SMP/e package.',
defaultValue: false
),
booleanParam(
name: 'KEEP_TEMP_FOLDER',
description: 'If leave the temporary packaging folder on remote server.',
defaultValue: false
)
)
pipeline.setup(
packageName: 'org.zowe',
github: [
email : lib.Constants.DEFAULT_GITHUB_ROBOT_EMAIL,
usernamePasswordCredential : lib.Constants.DEFAULT_GITHUB_ROBOT_CREDENTIAL,
],
artifactory: [
url : lib.Constants.DEFAULT_ARTIFACTORY_URL,
usernamePasswordCredential : lib.Constants.DEFAULT_ARTIFACTORY_ROBOT_CREDENTIAL,
],
pax: [
sshHost : lib.Constants.DEFAULT_PAX_PACKAGING_SSH_HOST,
sshPort : lib.Constants.DEFAULT_PAX_PACKAGING_SSH_PORT,
sshCredential : lib.Constants.DEFAULT_PAX_PACKAGING_SSH_CREDENTIAL,
remoteWorkspace : lib.Constants.DEFAULT_PAX_PACKAGING_REMOTE_WORKSPACE,
],
extraInit: {
def commitHash = sh(script: 'git rev-parse --verify HEAD', returnStdout: true).trim()
sh """
sed -e 's#{BUILD_BRANCH}#${env.BRANCH_NAME}#g' \
-e 's#{BUILD_NUMBER}#${env.BUILD_NUMBER}#g' \
-e 's#{BUILD_COMMIT_HASH}#${commitHash}#g' \
-e 's#{BUILD_TIMESTAMP}#${currentBuild.startTimeInMillis}#g' \
manifest.json.template > manifest.json
"""
echo "Current manifest.json is:"
sh "cat manifest.json"
manifest = readJSON(file: 'manifest.json')
if (!manifest || !manifest['name'] || manifest['name'] != 'Zowe' || !manifest['version']) {
error "Cannot read manifest or manifest is invalid."
}
pipeline.setVersion(manifest['version'])
}
)
pipeline.build(
timeout : [time: 5, unit: 'MINUTES'],
isSkippable : false,
operation : {
// replace templates
echo 'replacing templates...'
sh "sed -e 's/{ZOWE_VERSION}/${manifest['version']}/g' install/zowe-install.yaml.template > install/zowe-install.yaml && rm install/zowe-install.yaml.template"
// prepareing download spec
echo 'prepareing download spec ...'
def spec = pipeline.artifactory.interpretArtifactDefinitions(manifest['binaryDependencies'], [ "target": ".pax/content/zowe-${manifest['version']}/files/" as String])
writeJSON file: 'artifactory-download-spec.json', json: spec, pretty: 2
echo "================ download spec ================"
sh "cat artifactory-download-spec.json"
// download components
pipeline.artifactory.download(
spec : 'artifactory-download-spec.json',
expected : 18
)
// we want build log pulled in for SMP/e build
if (params.BUILD_SMPE) {
def buildLogSpec = readJSON(text: '{"files":[]}')
buildLogSpec['files'].push([
"target": ".pax/content/smpe/",
"flat": "true",
"pattern": pipeline.getPublishTargetPath() + "smpe-build-logs-*.pax.Z",
"sortBy": ["created"],
"sortOrder": "desc",
"limit": 1
])
writeJSON file: 'smpe-build-log-download-spec.json', json: buildLogSpec, pretty: 2
echo "================ SMP/e build log download spec ================"
sh "cat smpe-build-log-download-spec.json"
pipeline.artifactory.download(
spec : 'smpe-build-log-download-spec.json'
)
}
}
)
// FIXME: we may move smoke test into this pipeline
pipeline.test(
name : "Smoke",
operation : {
echo 'Skip until test case are embeded into this pipeline.'
},
allowMissingJunit : true
)
pipeline.packaging(
name : "zowe",
timeout : [time: 90, unit: 'MINUTES'],
operation: {
pipeline.pax.pack(
job : "zowe-packaging",
filename : 'zowe.pax',
environments : [
'ZOWE_VERSION': pipeline.getVersion(),
'BUILD_SMPE' : (params.BUILD_SMPE ? 'yes' : '')
],
extraFiles : (params.BUILD_SMPE ? 'zowe-smpe.pax,readme.txt,smpe-build-logs.pax.Z,rename-back.sh' : ''),
keepTempFolder : params.KEEP_TEMP_FOLDER
)
if (params.BUILD_SMPE) {
// rename SMP/e build with correct FMID name
sh "cd .pax && chmod +x rename-back.sh && cat rename-back.sh && ./rename-back.sh"
}
}
)
// define we need publish stage
pipeline.publish(
artifacts: [
'.pax/zowe.pax',
'.pax/AZWE*',
'.pax/smpe-build-logs.pax.Z'
]
)
pipeline.end()
}