From c104f7d4039a4c1e5ea431c3a06da7897b2e4053 Mon Sep 17 00:00:00 2001 From: Tom Blench Date: Fri, 8 Sep 2017 08:39:55 +0100 Subject: [PATCH] Jenkinsfile fixes: - Fix regex for getting version string - More robust logic for extracting tag message --- Jenkinsfile | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index e0d165653..ab09370a8 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -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') { @@ -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 } }