diff --git a/Jenkinsfile b/Jenkinsfile index 0ccfe22..93e2d41 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -57,6 +57,9 @@ 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', @@ -67,7 +70,7 @@ // Define lazyStages lazyStage { name = 'validate' - onlyif = (!( lazyConfig.branch ==~ /^release-.+/ )) + onlyif = (!( lazyConfig['branch'] ==~ /^release-.+/ )) tasks = [ run: { fastlane('android', 'test') @@ -83,7 +86,7 @@ fastlane('android', 'build') }, post: { - archiveArtifacts(artifacts: 'app/build/outputs/apk/**', allowEmptyArchive: false) + archiveArtifacts(artifacts: "${buildDir}/**", allowEmptyArchive: false) }, on: 'android', ] @@ -92,11 +95,11 @@ // 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: { @@ -105,18 +108,18 @@ lazyGitPass('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}") + androidChangeLogs(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,11 +129,11 @@ // 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() @@ -138,12 +141,12 @@ if ( !lazyConfig.env.DRYRUN ) fastlane('android', 'alpha') lazyGitPass('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,12 +155,12 @@ 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')/* @@ -168,12 +171,12 @@ 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')*/ @@ -181,9 +184,9 @@ echo("currentVersion = ${currentVersion.toString()}") lazyGitPass('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']) })