Skip to content

Commit 61d624a

Browse files
jeffmauryadietish
authored andcommitted
chore: Auto archive Jenkins release builds and report errors
Signed-off-by: Jeff MAURY <[email protected]>
1 parent 9b94caa commit 61d624a

File tree

1 file changed

+56
-46
lines changed

1 file changed

+56
-46
lines changed

Jenkinsfile

Lines changed: 56 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,62 @@
11
#!/usr/bin/env groovy
22

33
node('rhel7'){
4-
stage('Checkout repo') {
5-
deleteDir()
6-
git url: 'https://github.com/redhat-developer/intellij-redhat-telemetry',
7-
branch: "${sha1}"
8-
}
9-
10-
def props = readProperties file: 'gradle.properties'
11-
def isSnapshot = props['projectVersion'].contains('-SNAPSHOT')
12-
def version = isSnapshot?props['projectVersion'].replace('-SNAPSHOT', ".${env.BUILD_NUMBER}"):props['projectVersion'] + ".${env.BUILD_NUMBER}"
13-
14-
stage('Build') {
15-
sh "./gradlew assemble -PprojectVersion=${version}"
16-
}
4+
def recipientList = '[email protected]'
175

18-
stage('Package') {
19-
sh "./gradlew buildPlugin -PprojectVersion=${version}"
20-
}
21-
22-
if(params.UPLOAD_LOCATION) {
23-
stage('Upload') {
24-
def filesToPush = findFiles(glob: '**/*.zip')
25-
sh "rsync -Pzrlt --rsh=ssh --protocol=28 \"${filesToPush[0].path}\" ${UPLOAD_LOCATION}/snapshots/intellij-redhat-telemetry/"
26-
stash name:'zip', includes:filesToPush[0].path
6+
try {
7+
stage('Checkout repo') {
8+
deleteDir()
9+
git url: 'https://github.com/redhat-developer/intellij-redhat-telemetry',
10+
branch: "${sha1}"
2711
}
28-
}
29-
30-
if(publishToMarketPlace.equals('true')){
31-
timeout(time:5, unit:'DAYS') {
32-
input message:'Approve deployment?', submitter: 'jmaury'
33-
}
34-
35-
def channel = isSnapshot?"nightly":"stable"
36-
37-
stage("Publish to Marketplace") {
38-
unstash 'zip'
39-
withCredentials([[$class: 'StringBinding', credentialsId: 'JetBrains marketplace token', variable: 'TOKEN']]) {
40-
sh "./gradlew publishPlugin -PjetBrainsToken=${TOKEN} -PprojectVersion=${version} -PjetBrainsChannel=${channel}"
41-
}
42-
archive includes:"**.zip"
43-
44-
if (!isSnapshot) {
45-
stage("Promote the build to stable") {
46-
def zip = findFiles(glob: '**/*.zip')
47-
sh "rsync -Pzrlt --rsh=ssh --protocol=28 \"${zip[0].path}\" ${UPLOAD_LOCATION}/stable/intellij-redhat-telemetry/"
48-
}
49-
}
50-
}
51-
}
12+
13+
def props = readProperties file: 'gradle.properties'
14+
def isSnapshot = props['projectVersion'].contains('-SNAPSHOT')
15+
def version = isSnapshot?props['projectVersion'].replace('-SNAPSHOT', ".${env.BUILD_NUMBER}"):props['projectVersion'] + ".${env.BUILD_NUMBER}"
16+
17+
stage('Build') {
18+
sh "./gradlew assemble -PprojectVersion=${version}"
19+
}
20+
21+
stage('Package') {
22+
sh "./gradlew buildPlugin -PprojectVersion=${version}"
23+
}
24+
25+
if(params.UPLOAD_LOCATION) {
26+
stage('Upload') {
27+
def filesToPush = findFiles(glob: '**/*.zip')
28+
sh "rsync -Pzrlt --rsh=ssh --protocol=28 \"${filesToPush[0].path}\" ${UPLOAD_LOCATION}/snapshots/intellij-redhat-telemetry/"
29+
stash name:'zip', includes:filesToPush[0].path
30+
}
31+
}
32+
33+
if(publishToMarketPlace.equals('true')){
34+
timeout(time:5, unit:'DAYS') {
35+
input message:'Approve deployment?', submitter: 'jmaury'
36+
}
37+
38+
def channel = isSnapshot?"nightly":"stable"
39+
40+
stage("Publish to Marketplace") {
41+
unstash 'zip'
42+
withCredentials([[$class: 'StringBinding', credentialsId: 'JetBrains marketplace token', variable: 'TOKEN']]) {
43+
sh "./gradlew publishPlugin -PjetBrainsToken=${TOKEN} -PprojectVersion=${version} -PjetBrainsChannel=${channel}"
44+
}
45+
archive includes:"**.zip"
46+
47+
if (!isSnapshot) {
48+
stage("Promote the build to stable") {
49+
def zip = findFiles(glob: '**/*.zip')
50+
sh "rsync -Pzrlt --rsh=ssh --protocol=28 \"${zip[0].path}\" ${UPLOAD_LOCATION}/stable/intellij-redhat-telemetry/"
51+
currentBuild.keepLog = true
52+
currentBuild.description = "${version}"
53+
}
54+
}
55+
}
56+
}
57+
} catch (any) {
58+
currentBuild.result = 'FAILURE'
59+
step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${recipientList}", sendToIndividuals: true])
60+
throw any
61+
}
5262
}

0 commit comments

Comments
 (0)