Skip to content
This repository was archived by the owner on Mar 11, 2022. It is now read-only.

Commit e29a01d

Browse files
authored
Merge pull request #440 from cloudant/release-tagging
Added gitTagAndPublish step to Jenkinsfile
2 parents b558110 + 590d9e4 commit e29a01d

File tree

1 file changed

+7
-49
lines changed

1 file changed

+7
-49
lines changed

Jenkinsfile

Lines changed: 7 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -198,54 +198,12 @@ stage('BuildAndTest') {
198198
parallel(axes)
199199
}
200200

201-
// Publish the master branch
201+
// Publish if needed (e.g. for master branch release build)
202202
stage('Publish') {
203-
if (env.BRANCH_NAME == "master") {
204-
node {
205-
checkout scm // re-checkout to be able to git tag
206-
207-
// read the version string
208-
def versionFile = readFile('CDTDatastore/Version.h').trim()
209-
def version = getVersion(versionFile)
210-
211-
// if it is a release build then do the git tagging
212-
if (isReleaseVersion(version)) {
213-
214-
def inMessage = false
215-
// Read the CHANGELOG.md to get the tag message
216-
tagMessage = ''
217-
// find the message following the first "##" header
218-
for (line in readFile('CHANGELOG.md').readLines()) {
219-
if (line =~ /^##/) {
220-
if (!inMessage) {
221-
inMessage = true
222-
continue
223-
} else {
224-
break
225-
}
226-
}
227-
if (inMessage) {
228-
// append the line to the tagMessage
229-
tagMessage = "${tagMessage}${line}\n"
230-
}
231-
}
232-
233-
// Use git to tag the release at the version
234-
try {
235-
// Awkward workaround until resolution of https://issues.jenkins-ci.org/browse/JENKINS-28335
236-
withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'github-token', usernameVariable: 'GIT_USERNAME', passwordVariable: 'GIT_PASSWORD']]) {
237-
sh "git config user.email \"nomail@hursley.ibm.com\""
238-
sh "git config user.name \"Jenkins CI\""
239-
sh "git config credential.username ${env.GIT_USERNAME}"
240-
sh "git config credential.helper '!echo password=\$GIT_PASSWORD; echo'"
241-
sh "git tag -a ${version} -m '${tagMessage}'"
242-
sh "git push origin ${version}"
243-
}
244-
} finally {
245-
sh "git config --unset credential.username"
246-
sh "git config --unset credential.helper"
247-
}
248-
}
249-
}
250-
}
203+
gitTagAndPublish {
204+
versionFile='CDTDatastore/Version.h'
205+
changesFile='CHANGELOG.md'
206+
isDraft=true
207+
releaseApiUrl='https://api.github.com/repos/cloudant/CDTDatastore/releases'
208+
}
251209
}

0 commit comments

Comments
 (0)