Skip to content

Commit 96a3326

Browse files
committed
Update jenkinsfile
1 parent b6618c2 commit 96a3326

File tree

2 files changed

+49
-9
lines changed

2 files changed

+49
-9
lines changed

Jenkinsfile

Lines changed: 48 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
def releaseStatus = 3 // Not a release branch
2+
def officialReleaseFileFound = 1
3+
def releaseCmdPath = 'tmp/simple-relmgt'
24

35
pipeline {
46
agent any
@@ -11,6 +13,34 @@ pipeline {
1113
create-go-build-env.sh''')
1214
}
1315
}
16+
17+
stage('prepare deployment environment') {
18+
steps {
19+
sh('''#!/bin/bash -xv
20+
mkdir -p tmp
21+
rm -f tmp/simple-relmgt
22+
curl -L -s -O tmp/simple-relmgt https://github.com/forj-oss/simple-relmgt/releases/download/latest/simple-relmgt
23+
if [[ -f tmp/simple-relmgt ]]
24+
then
25+
chmod +x tmp/simple-relmgt
26+
tmp/simple-relmgt -- version
27+
else
28+
echo "No official simple-relmgt found. Using local built one."
29+
exit 0
30+
fi
31+
''')
32+
33+
script {
34+
officialReleaseFileFound = sh(script: '[ -f ' + releaseCmdPath + ' ]', returnStatus: true)
35+
echo("$officialReleaseFileFound")
36+
if (officialReleaseFileFound == 0) {
37+
releaseStatus = sh(script: releaseCmdPath + ' check', returnStatus: true)
38+
} else {
39+
releaseCmdPath = "./simple-relmgt"
40+
}
41+
}
42+
}
43+
}
1444
stage('Install dependencies') {
1545
steps {
1646
sh('''#!/bin/bash -e
@@ -36,37 +66,47 @@ pipeline {
3666
go test simple-relmgt simple-relmgt/cmds/draftcmd simple-relmgt/cmds/checkcmd simple-relmgt/cmds/releasecmd simple-relmgt/cmds/statecmd simple-relmgt/cmds/tagcmd'''
3767
)
3868
script {
39-
releaseStatus = sh(script: './simple-relmgt check', returnStatus: true)
69+
if (!officialReleaseFileFound) {
70+
echo('Using built simple-relmgt...')
71+
releaseStatus = sh(script: releaseCmdPath + ' check', returnStatus: true)
72+
}
73+
4074
}
4175
}
4276
}
43-
/* stage('Release PR status') {
77+
78+
stage('Release PR status') {
4479
when {
4580
changeRequest target: 'master'
4681
}
4782
steps {
48-
sh('./simple-relmgt status')
83+
sh(releaseCmdPath + ' status')
4984
}
5085
}
51-
/* stage('tag it') {
86+
87+
stage('tag it') {
5288
when {
5389
branch 'master'
54-
environment name: 'RELEASE_STATUS', value: '0'
90+
expression { return returnStatus == 0 }
5591
}
5692
steps {
57-
sh('simple-relmgt tag-it') // git tag, push it and create a draft github release
93+
sh(releaseCmdPath + ' tag-it') // git tag, push it and create a draft github release
5894
}
59-
}*/
95+
}
6096

6197
stage('Deploy') {
62-
when { branch 'master' }
98+
when {
99+
branch 'master'
100+
expression { return returnStatus == 0 }
101+
}
63102
steps {
64103
withCredentials([
65104
usernamePassword(credentialsId: 'github-jenkins-cred', usernameVariable: 'GITHUB_USER', passwordVariable: 'GITHUB_TOKEN')
66105
]) {
67106
sh('''#!/bin/bash -e
68107
source ./build-env.sh
69108
publish.sh latest''')
109+
sh(releaseCmdPath + ' release-it') // release the draft github release
70110
}
71111
}
72112
}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ pipeline {
9999
returnStatus: true
100100
)
101101
}
102-
/* optional */
103102
stages {
103+
/* optional */
104104
stage('Release PR status') {
105105
when {
106106
changeRequest target: 'master'

0 commit comments

Comments
 (0)