diff --git a/Jenkinsfile b/Jenkinsfile index 2226d3c..bba4108 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -75,7 +75,7 @@ ], inLabels: [ 'ubuntu-16', 'centos-7' ], onLabels: [ default: 'master', docker: 'docker', mac: 'mac', android: 'android', ], - noPoll: "(${releaseBranch}|.+_.+)", // Don't poll release and private branches + noPoll: "(.+_.+)", // Don't poll or automatically trigger private branches ) lazyStage { @@ -115,62 +115,6 @@ ] } -// Release stage only if criteria are met -lazyStage { - name = 'release' - onlyif = ( lazyConfig['branch'] != releaseBranch && ! lazyConfig.env.RELEASE ) - // Dummy stage to conserve history when not releasing - // Not needed if we always release for release branch - tasks = [ - run: { - echo('Nothing to do since not releasing') - } - ] -} - -lazyStage { - name = 'release' - onlyif = ( lazyConfig['branch'] == releaseBranch || lazyConfig.env.RELEASE ) - // Ask version if release flag and set and we are in the branch to fork release from - input = [ - message: 'Version string', - parameters: [string( - defaultValue: '', - description: "Version to be release: 'build', 'micro', 'minor', 'major' or a specific string (i.e.: 1.2.3-4)", - name: 'VERSION' - )] - ] - tasks = [ - run: { - gitAuth(env.GIT_CRED, { - // Define next version based on optional input - def currentVersion = readFile(encoding: 'UTF8', file: 'version.txt') - def nextVersion = null - if (env.lazyInput) { - if (env.lazyInput ==~ /[a-z]+/) { - nextVersion = bumpVersion(env.lazyInput, currentVersion) - } else { - nextVersion = env.lazyInput - } - } else { - nextVersion = bumpVersion('build', currentVersion) - } - // Merge changes from working branch into release branch - gitMerge(workingBranch, releaseBranch) - // Bump version and tag before deploying - writeFile(encoding: 'UTF-8', file: 'version.txt', text: nextVersion) - gitCommit("Update version to ${nextVersion}", 'version.txt') - // Uncomment the following to merge version bump back into the working branch - //gitMerge(releaseBranch, workingBranch) - //gitPush(remote, workingBranch) - gitPush(remote, releaseBranch) - gitTag("${nextVersion}", remote) - }) - }, - // Can not be done in parallel - ] -} - // Generate packages lazyStage { name = 'package' @@ -205,10 +149,55 @@ ] } +// Release stage only if criteria are met +lazyStage { + name = 'release' + onlyif = ( lazyConfig['branch'] == workingBranch && lazyConfig.env.RELEASE ) + // Ask version if release flag and set and we are in the branch to fork release from + input = [ + message: 'Version string', + parameters: [string( + defaultValue: '', + description: "Version to be release: 'build' (default), 'micro', 'minor', 'major' or a specific string (i.e.: 1.2.3-4)", + name: 'VERSION' + )] + ] + tasks = [ + run: { + gitAuth(env.GIT_CRED, { + // Define next version based on optional input + def currentVersion = readFile(encoding: 'UTF8', file: 'version.txt') + def nextVersion = null + if (env.lazyInput) { + if (env.lazyInput ==~ /[a-z]+/) { + nextVersion = bumpVersion(env.lazyInput, currentVersion) + } else { + nextVersion = env.lazyInput + } + } else { + nextVersion = bumpVersion('build', currentVersion) + } + // Merge changes from working into release branch + gitMerge(workingBranch, releaseBranch) + // Bump version into release branch + writeFile(encoding: 'UTF-8', file: 'version.txt', text: nextVersion) + gitCommit("Update version to ${nextVersion}", 'version.txt') + // Uncomment the following to merge version bump back into the working branch + //gitMerge(releaseBranch, workingBranch) + //gitPush(remote, workingBranch) + // Publish changes in release branch and tag the release + gitPush(remote, releaseBranch) + gitTag("${nextVersion}", remote) + }) + }, + // Can not be done in parallel + ] +} + // Deliver the site on each environment lazyStage { name = 'systemtest' - onlyif = ( env.LAZY_BRANCH == releaseBranch || lazyConfig.env.RELEASE ) + onlyif = ( env.LAZY_BRANCH == releaseBranch ) tasks = [ pre: { unarchive(mapping:["${env.BUILD_DIR}/" : '.']) @@ -249,7 +238,7 @@ lazyStage { name = 'production' - onlyif = ( lazyConfig['branch'] == releaseBranch || lazyConfig.env.RELEASE ) + onlyif = ( lazyConfig['branch'] == releaseBranch ) input = 'Deploy to production?' tasks = [ pre: {