diff --git a/Jenkinsfile b/Jenkinsfile index 109da68..c31977b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -57,20 +57,23 @@ def releaseFrom = [ remote: 'origin', branch: 'master' ] def releaseTo = [ remote: 'origin', branch: 'master' ] +// Define the directory where the package will be build +def buildDir = 'app/build/outputs/apk' + // Initialize lazyConfig for this pipeline lazyConfig( name: 'DummyAnd', env: [ RELEASE: false, ], - noPoll: '.+_.+', + noPoll: '(.+_|release-).+', ) // Define lazyStages lazyStage { name = 'validate' - onlyif = (!( lazyConfig.branch ==~ /^release-.+/ )) + onlyif = (!( lazyConfig['branch'] ==~ /^release-.+/ )) tasks = [ run: { - fastlane('android', 'test') + fastLane('android', 'test') }, on: 'android', ] @@ -80,10 +83,10 @@ name = 'package' tasks = [ run: { - fastlane('android', 'build') + fastLane('android', 'build') }, post: { - archiveArtifacts(artifacts: 'app/build/outputs/apk/**', allowEmptyArchive: false) + archiveArtifacts(artifacts: "${buildDir}/**", allowEmptyArchive: false) }, on: 'android', ] @@ -92,31 +95,31 @@ // Release stage only only if criteria are met lazyStage { name = 'release' - onlyif = ( lazyConfig.branch == releaseFrom['branch'] && lazyConfig.env.RELEASE ) + onlyif = ( lazyConfig['branch'] == releaseFrom['branch'] && lazyConfig.env.RELEASE ) // Ask version if release flag and set and we are in the branch to fork release from input = [ - message: 'Version name', - parameters: [string(defaultValue: '', description: 'Version name to be release (no versionCode)', name: 'VERSION')] + message: 'Version string', + parameters: [string(defaultValue: '', description: 'Version string to be release (no build number)', name: 'VERSION')] ] tasks = [ run: { def currentVersion = androidVersion() echo("currentVersion = ${currentVersion.toString()}") - lazyGitPass('bot-ci-dgm', { + gitAuth('bot-ci-dgm', { // Fork a release branch as requested echo("Git logs since last tag:\n" + gitLog()) - def nextVersion = [ name: currentVersion.name, code: currentVersion.code + 1 ] + def nextVersion = [ string: currentVersion.string, number: currentVersion.number + 1 ] if (env.lazyInput) { - nextVersion = [ name: env.lazyInput, code: nextVersion.code ] + nextVersion = [ string: env.lazyInput, number: nextVersion.number ] } - sh("git checkout -b release-${nextVersion.name}") + sh("git checkout -b release-${nextVersion.string}") androidVersion(nextVersion) nextVersion = androidVersion() // Just to catch any problem echo("nextVersion = ${nextVersion.toString()}" ) - androidChangeLogs(nextVersion.code) - gitCommit("Provide changelogs for version ${nextVersion.code}", 'fastlane/metadata/android') - gitCommit("Update version to ${nextVersion.name}-${nextVersion.code}", 'app/build.gradle') - gitPush(releaseFrom['remote'], "release-${nextVersion.name}") + fastChangeLogs(nextVersion.number) + 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}") }) }, on: 'android', @@ -126,24 +129,24 @@ // From systemtest to production, only for release branches lazyStage { name = 'systemtest' - onlyif = ( lazyConfig.branch ==~ /^release-.+/ ) + onlyif = ( lazyConfig['branch'] ==~ /^release-.+/ ) tasks = [ pre: { - unarchive(mapping:['app/build/outputs/apk/' : '.']) - sh("ls -lA app/build/outputs/apk") + unarchive(mapping:["${buildDir}/" : '.']) + sh("ls -lA ${buildDir}") }, run: { def currentVersion = androidVersion() echo("currentVersion = ${currentVersion.toString()}") - if ( env.DRYRUN != 'true' ) fastlane('android', 'alpha') - lazyGitPass('bot-ci-dgm', { + if ( !lazyConfig.env.DRYRUN ) fastLane('android', 'alpha') + gitAuth('bot-ci-dgm', { gitMerge( - "${lazyConfig.branch}", + "${lazyConfig['branch']}", "${releaseFrom['branch']}", - "Merge changes from ${currentVersion['name']}-${currentVersion['code']} back into ${releaseFrom['branch']}" + "Merge changes from ${currentVersion.string}-${currentVersion.number} back into ${releaseFrom['branch']}" ) gitPush(releaseFrom['remote'], releaseFrom['branch']) - gitTag("${currentVersion.name}-${currentVersion.code}", releaseTo['remote']) + gitTag("${currentVersion.string}-${currentVersion.number}", releaseTo['remote']) }) }, on: 'android', @@ -152,15 +155,15 @@ lazyStage { name = 'acceptance' - onlyif = ( lazyConfig.branch ==~ /^release-.+/ ) + onlyif = ( lazyConfig['branch'] ==~ /^release-.+/ ) input = 'Promote alpha to beta?' tasks = [ pre: { - unarchive(mapping:['app/build/outputs/apk/' : '.']) - sh("ls -lA app/build/outputs/apk") + unarchive(mapping:["${buildDir}/" : '.']) + sh("ls -lA ${buildDir}") }, run: { - if ( lazyConfig.env.DRYRUN ) fastlane('android', 'beta')/* + if ( !lazyConfig.env.DRYRUN ) fastLane('android', 'beta')/* }, on: 'android', ] @@ -168,22 +171,22 @@ lazyStage { name = 'production' - onlyif = ( lazyConfig.branch ==~ /^release-.+/ ) + onlyif = ( lazyConfig['branch'] ==~ /^release-.+/ ) input = 'Promote beta to production?' tasks = [ pre: { - unarchive(mapping:['app/build/outputs/apk/' : '.']) - sh("ls -lA app/build/outputs/apk") + unarchive(mapping:["${buildDir}/" : '.']) + sh("ls -lA ${buildDir}") }, run: { - if ( lazyConfig.env.DRYRUN ) fastlane('android', 'production')*/ + if ( !lazyConfig.env.DRYRUN ) fastLane('android', 'production')*/ def currentVersion = androidVersion() echo("currentVersion = ${currentVersion.toString()}") - lazyGitPass('bot-ci-dgm', { + gitAuth('bot-ci-dgm', { gitMerge( - "${lazyConfig.branch}", + "${lazyConfig['branch']}", "${releaseTo['branch']}", - "Merge changes from ${currentVersion['name']}-${currentVersion['code']} into ${releaseTo['branch']}" + "Merge changes from ${currentVersion.string}-${currentVersion.number} into ${releaseTo['branch']}" ) gitPush(releaseTo['remote'], releaseTo['branch']) })