-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathJenkinsfile
More file actions
218 lines (192 loc) · 6.44 KB
/
Copy pathJenkinsfile
File metadata and controls
218 lines (192 loc) · 6.44 KB
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
/*
* 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.
*
*/
/**
* List of people who will get all emails for master builds
*/
def MASTER_RECIPIENTS_LIST = "cc:Pavel.Zlatnik@broadcom.com"
/**
* The name of the master branch
*/
def MASTER_BRANCH = "master"
/**
* Is this a release branch? Temporary workaround that won't break everything horribly if we merge.
*/
def RELEASE_BRANCH = false
/**
* The result string for a successful build
*/
def BUILD_SUCCESS = 'SUCCESS'
/**
* The result string for an unstable build
*/
def BUILD_UNSTABLE = 'UNSTABLE'
/**
* The result string for a failed build
*/
def BUILD_FAILURE = 'FAILURE'
/**
* The user's name for git commits
*/
def GIT_USER_NAME = 'zowe-robot'
/**
* The user's email address for git commits
*/
def GIT_USER_EMAIL = 'zowe.robot@gmail.com'
/**
* The base repository url for github
*/
def GIT_REPO_URL = 'https://github.com/zowe/vtl-cli.git'
/**
* The credentials id field for the authorization token for GitHub stored in Jenkins
*/
def GIT_CREDENTIALS_ID = 'zowe-robot-github'
/**
* A command to be run that gets the current revision pulled down
*/
def GIT_REVISION_LOOKUP = 'git log -n 1 --pretty=format:%h'
/**
* The credentials id field for the artifactory username and password
*/
def ARTIFACTORY_CREDENTIALS_ID = 'zowe.jfrog.io'
/**
* The email address for the artifactory
*/
def ARTIFACTORY_EMAIL = GIT_USER_EMAIL
/**
* The VTL CLI Bundle Version to deploy to Artifactory
*/
def VTL_CLI_BUNDLE_VERSION = "1.0.7-SNAPSHOT"
/**
* The Artifactory Server to deploy to.
*/
//*def ARTIFACTORY_SERVER = "gizaArtifactory"*/
def ARTIFACTORY_SERVER = "zoweArtifactory"
/**
* The target repository for VTL CLI Package SNAPSHOTs
*/
def ARTIFACTORY_SNAPSHOT_REPO = "libs-snapshot-local"
/**
* Target Repository for VTL CLI Package Releases
*/
def ARTIFACTORY_RELEASE_REPO = "libs-release-local"
// Setup conditional build options. Would have done this in the options of the declarative pipeline, but it is pretty
// much impossible to have conditional options based on the branch :/
def opts = []
if (BRANCH_NAME == MASTER_BRANCH) {
// Only keep 20 builds
opts.push(buildDiscarder(logRotator(numToKeepStr: '20')))
// Concurrent builds need to be disabled on the master branch because
// it needs to actively commit and do a build. There's no point in publishing
// twice in quick succession
opts.push(disableConcurrentBuilds())
} else {
if (BRANCH_NAME.equals("1.0.5")){
RELEASE_BRANCH = true
}
// Only keep 5 builds on other branches
opts.push(buildDiscarder(logRotator(numToKeepStr: '5')))
}
properties(opts)
pipeline {
agent {
label 'apiml-jenkins-agent'
}
options {
timestamps ()
}
stages {
// Stage 1
stage ('Build') {
steps {
timeout(time: 10, unit: 'MINUTES') {
sh 'chmod -R 777 ./gradle'
sh 'chmod +x ./gradle/bootstrap/bootstrap_gradlew.sh'
sh 'chmod +x ./gradlew'
sh './gradlew build'
}
}
}
// Stage 2
stage ('Create executable scripts') {
steps {
timeout(time: 10, unit: 'MINUTES') {
sh 'chmod +x scripts/create_executable_jars.sh'
sh 'scripts/create_executable_jars.sh'
}
}
}
// Stage 3
stage ('Zip/tar files') {
steps {
timeout(time: 10, unit: 'MINUTES') {
sh 'cd build; tar -czvf vtl.tar.gz vtl-cli.jar vtl zos/vtl; cd ..'
}
}
}
// Stage 4
stage ('Archive artifact') {
steps {
timeout(time: 10, unit: 'MINUTES') {
archiveArtifacts artifacts: 'build/vtl.tar.gz'
}
}
}
// Stage 5
stage('Publish snapshot version to Artifactory for master') {
when {
expression {
return BRANCH_NAME.equals(MASTER_BRANCH);
}
}
steps {
timeout(time: 5, unit: 'MINUTES' ) {
script {
def server = Artifactory.server ARTIFACTORY_SERVER
def targetVersion = VTL_CLI_BUNDLE_VERSION
def targetRepository = targetVersion.contains("-SNAPSHOT") ? ARTIFACTORY_SNAPSHOT_REPO : ARTIFACTORY_RELEASE_REPO
def uploadSpec = """{
"files": [{
"pattern": "build/vtl.tar.gz",
"target": "${targetRepository}/org/zowe/vtl-cli/zowe-cli-package/${targetVersion}/"
}]
}"""
def buildInfo = Artifactory.newBuildInfo()
server.upload spec: uploadSpec, buildInfo: buildInfo
server.publishBuildInfo buildInfo
}
}
}
}
// Stage 6
stage ('Codecov') {
steps {
withCredentials([usernamePassword(credentialsId: 'Codecov', usernameVariable: 'CODECOV_USERNAME', passwordVariable: 'CODECOV_TOKEN')]) {
sh 'curl -s https://codecov.io/bash | bash -s'
}
}
}
}
post {
always{
script {
def buildStatus = currentBuild.currentResult
echo "Build status for current build is ${buildStatus} ."
def subject = "${currentBuild.currentResult}: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'"
echo "Subject is ${subject} ."
def consoleOutput = """
<p>Branch: <b>${BRANCH_NAME}</b></p>
<p>Check console output at "<a href="${RUN_DISPLAY_URL}">${env.JOB_NAME} [${env.BUILD_NUMBER}]</a>"</p>
"""
echo "Console output is ${subject} ."
}
}
}
}