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

Commit

Permalink
Jenkinsfile fixes:
Browse files Browse the repository at this point in the history
- Fix regex for getting version string
- More robust logic for extracting tag message
  • Loading branch information
Tom Blench committed Sep 8, 2017
1 parent 7341678 commit c104f7d
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,13 @@ def buildAndTest(nodeLabel, target, rakeEnv, encrypted) {
}

@NonCPS
def isReleaseVersion(versionFile) {
def versionMatcher = versionFile =~ /#define CLOUDANT_SYNC_VERSION \"(.*)\"/
return versionMatcher.matches() && !versionMatcher.group(1).toUpperCase(Locale.ENGLISH).contains("SNAPSHOT")
def getVersion(versionFile) {
def versionMatcher = versionFile =~ /#define CLOUDANT_SYNC_VERSION "(.*)"/
return versionMatcher[0][1]
}

def isReleaseVersion(version) {
return !version.toUpperCase(Locale.ENGLISH).contains("SNAPSHOT")
}

stage('Checkout') {
Expand Down Expand Up @@ -121,20 +125,29 @@ stage('Publish') {
node {
checkout scm // re-checkout to be able to git tag

// read the version name
// read the version string
def versionFile = readFile('CDTDatastore/Version.h').trim()
def version = getVersion(versionFile)

// if it is a release build then do the git tagging
if (isReleaseVersion(versionFile)) {
if (isReleaseVersion(version)) {

def inMessage = false
// Read the CHANGELOG.md to get the tag message
tagMessage = ''
// find the message following the first "##" header
for (line in readFile('CHANGELOG.md').readLines()) {
if (!''.equals(line)) {
if (line =~ /^##/) {
if (!inMessage) {
inMessage = true
continue
} else {
break
}
}
if (inMessage) {
// append the line to the tagMessage
tagMessage = "${tagMessage}${line}\n"
} else {
break
}
}

Expand Down

0 comments on commit c104f7d

Please sign in to comment.