diff --git a/Jenkinsfile b/Jenkinsfile index c31977b..69cd8bb 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -51,11 +51,10 @@ ]) ) -// Define the remotes and the branches used to release from and to -// Using master for both since we don't want a devel branch -// And wecan rely on tagging for production state -def releaseFrom = [ remote: 'origin', branch: 'master' ] -def releaseTo = [ remote: 'origin', branch: 'master' ] +// Define the remotes and the working and deploy branches +def remote = 'origin' +def workingBranch = 'master' +def deployBranches = [ 'acceptance', 'production', ] // Define the directory where the package will be build def buildDir = 'app/build/outputs/apk' @@ -64,13 +63,12 @@ lazyConfig( name: 'DummyAnd', env: [ RELEASE: false, ], - noPoll: '(.+_|release-).+', + noPoll: '(.+_.+|acceptance|production)', // Don't poll private branches ) // Define lazyStages lazyStage { name = 'validate' - onlyif = (!( lazyConfig['branch'] ==~ /^release-.+/ )) tasks = [ run: { fastLane('android', 'test') @@ -95,7 +93,7 @@ // Release stage only only if criteria are met lazyStage { name = 'release' - onlyif = ( lazyConfig['branch'] == releaseFrom['branch'] && lazyConfig.env.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', @@ -112,14 +110,24 @@ if (env.lazyInput) { nextVersion = [ string: env.lazyInput, number: nextVersion.number ] } - sh("git checkout -b release-${nextVersion.string}") - androidVersion(nextVersion) - nextVersion = androidVersion() // Just to catch any problem - echo("nextVersion = ${nextVersion.toString()}" ) - fastChangeLogs(nextVersion.number) + + // Refresh latest changelogs and bump version in working branch before deploying + sh("git checkout ${workingBranch}") + fastChangeLogs(nextVersion.number, 'android') + iosVersion(nextVersion) gitCommit("Provide changelogs for version ${nextVersion.number}", 'fastlane/metadata/android') gitCommit("Update version to ${nextVersion.string}-${nextVersion.number}", 'app/build.gradle') - gitPush(releaseFrom['remote'], "release-${nextVersion.string}") + + // Refresh each deploy branches with changes from the working branch + try { + deployBranches.each { deployBranch -> + gitMerge(workingBranch, deployBranch) + gitPush(remote, deployBranch) + } + } finally { // Publish and tag the working branch with latest changelogs and version anyway + gitPush(remote, workingBranch) + gitTag("${currentVersion.string}-${currentVersion.number}", remote) + } }) }, on: 'android', @@ -128,8 +136,8 @@ // From systemtest to production, only for release branches lazyStage { - name = 'systemtest' - onlyif = ( lazyConfig['branch'] ==~ /^release-.+/ ) + name = 'alpha' + onlyif = ( deployBranches.contains(lazyConfig['branch']) ) tasks = [ pre: { unarchive(mapping:["${buildDir}/" : '.']) @@ -139,23 +147,14 @@ def currentVersion = androidVersion() echo("currentVersion = ${currentVersion.toString()}") if ( !lazyConfig.env.DRYRUN ) fastLane('android', 'alpha') - gitAuth('bot-ci-dgm', { - gitMerge( - "${lazyConfig['branch']}", - "${releaseFrom['branch']}", - "Merge changes from ${currentVersion.string}-${currentVersion.number} back into ${releaseFrom['branch']}" - ) - gitPush(releaseFrom['remote'], releaseFrom['branch']) - gitTag("${currentVersion.string}-${currentVersion.number}", releaseTo['remote']) - }) }, on: 'android', ] } lazyStage { - name = 'acceptance' - onlyif = ( lazyConfig['branch'] ==~ /^release-.+/ ) + name = 'beta' + onlyif = ( deployBranches.contains(lazyConfig['branch']) ) input = 'Promote alpha to beta?' tasks = [ pre: { @@ -163,15 +162,15 @@ sh("ls -lA ${buildDir}") }, run: { - if ( !lazyConfig.env.DRYRUN ) fastLane('android', 'beta')/* + if ( !lazyConfig.env.DRYRUN ) fastLane('android', 'beta') }, on: 'android', ] } - +/* lazyStage { name = 'production' - onlyif = ( lazyConfig['branch'] ==~ /^release-.+/ ) + onlyif = ( deployBranches.contains(lazyConfig['branch']) ) input = 'Promote beta to production?' tasks = [ pre: { @@ -179,18 +178,9 @@ sh("ls -lA ${buildDir}") }, run: { - if ( !lazyConfig.env.DRYRUN ) fastLane('android', 'production')*/ - def currentVersion = androidVersion() - echo("currentVersion = ${currentVersion.toString()}") - gitAuth('bot-ci-dgm', { - gitMerge( - "${lazyConfig['branch']}", - "${releaseTo['branch']}", - "Merge changes from ${currentVersion.string}-${currentVersion.number} into ${releaseTo['branch']}" - ) - gitPush(releaseTo['remote'], releaseTo['branch']) - }) + if ( !lazyConfig.env.DRYRUN ) fastLane('android', 'production') }, on: 'android', ] } +*/ \ No newline at end of file