diff --git a/Jenkinsfile b/Jenkinsfile index 7985e2a..8132ccf 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -10,7 +10,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -21,36 +21,36 @@ // Load Jenkins shared libraries common to all projects def libLazy = [ - remote: 'https://github.com/digital-me/jenkins-lib-lazy.git', - branch: 'stable', - credentialsId: null, + remote: 'https://github.com/digital-me/jenkins-lib-lazy.git', + branch: 'stable', + credentialsId: null, ] library( - identifier: "libLazy@${libLazy.branch}", - retriever: modernSCM([ - $class: 'GitSCMSource', - remote: libLazy.remote, - credentialsId: libLazy.credentialsId - ]), - changelog: false, + identifier: "libLazy@${libLazy.branch}", + retriever: modernSCM([ + $class: 'GitSCMSource', + remote: libLazy.remote, + credentialsId: libLazy.credentialsId + ]), + changelog: false, ) // Load Jenkins shared libraries to customize this project def libCustom = [ - remote: 'ssh://git@code.in.digital-me.nl:2222/DEVops/JenkinsLibCustom.git', - branch: 'stable', - credentialsId: 'bot-ci-dgm-rsa', + remote: 'ssh://git@code.in.digital-me.nl:2222/DEVops/JenkinsLibCustom.git', + branch: 'stable', + credentialsId: 'bot-ci-dgm-rsa', ] library( - identifier: "libCustom@${libCustom.branch}", - retriever: modernSCM([ - $class: 'GitSCMSource', - remote: libCustom.remote, - credentialsId: libCustom.credentialsId - ]), - changelog: false, + identifier: "libCustom@${libCustom.branch}", + retriever: modernSCM([ + $class: 'GitSCMSource', + remote: libCustom.remote, + credentialsId: libCustom.credentialsId + ]), + changelog: false, ) // Define the remotes and the working and deploy branches @@ -63,218 +63,218 @@ // Initialize lazyConfig for this pipeline lazyConfig( - name: 'dummy-and', - env: [ - RELEASE: true, - JAVA_HOME: '/usr/java/latest', - ANDROID_HOME: '/opt/android/sdk', - GRADLE_USER_HOME: '/opt/android/gradle', - GRADLE_OPTS: '-XX:MaxMetaspaceSize=256m -Xmx1792m -Dfile.encoding=UTF-8 -Duser.country=US -Duser.language=en -Duser.variant -Dme.jenkins -Dorg.gradle.daemon=false -Dkotlin.compiler.execution.strategy=in-process', - GOOGLE_API_CID: 'dappre-google-api', - ], - noIndex: '(.+_.+|production)', // Avoid automatic indexing for release and private branches - xmppTargets: 'noise@conference.qiy.nl', + name: 'dummy-and', + env: [ + RELEASE: true, + JAVA_HOME: '/usr/java/latest', + ANDROID_HOME: '/opt/android/sdk', + GRADLE_USER_HOME: '/opt/android/gradle', + GRADLE_OPTS: '-XX:MaxMetaspaceSize=256m -Xmx1792m -Dfile.encoding=UTF-8 -Duser.country=US -Duser.language=en -Duser.variant -Dme.jenkins -Dorg.gradle.daemon=false -Dkotlin.compiler.execution.strategy=in-process', + GOOGLE_API_CID: 'dappre-google-api', + ], + noIndex: '(.+_.+|production)', // Avoid automatic indexing for release and private branches + xmppTargets: 'noise@conference.qiy.nl', ) // Define lazyStages lazyStage { - name = 'validate' - onlyif = (! deployBranches.contains(lazyConfig['branch']) ) - tasks = [ - pre: { - def currentVersion = androidVersion() - currentBuild.displayName = "#${env.BUILD_NUMBER} ${currentVersion.string}-${currentVersion.number}" - // Try to see if we can still merge the deploy branches - deployBranches.each { deployBranch -> - gitMerge(workingBranch, deployBranch) - } - // Go back to working branch for validation - sh("git checkout ${lazyConfig['branch']}") - }, - run: { - fastLane('android', 'test', '', 'rh-ruby26') - }, - args: "-v /opt/android:/opt/android" - + " -e JAVA_HOME=${env.JAVA_HOME}" - + " -e ANDROID_HOME=${env.ANDROID_HOME}" - + " -e GRADLE_USER_HOME=${env.GRADLE_USER_HOME}", - in: [ 'centos7' ], - on: 'android', - ] + name = 'validate' + onlyif = (! deployBranches.contains(lazyConfig['branch']) ) + tasks = [ + pre: { + def currentVersion = androidVersion() + currentBuild.displayName = "#${env.BUILD_NUMBER} ${currentVersion.string}-${currentVersion.number}" + // Try to see if we can still merge the deploy branches + deployBranches.each { deployBranch -> + gitMerge(workingBranch, deployBranch) + } + // Go back to working branch for validation + sh("git checkout ${lazyConfig['branch']}") + }, + run: { + fastLane('android', 'test', '', 'rh-ruby26') + }, + args: "-v /opt/android:/opt/android" + + " -e JAVA_HOME=${env.JAVA_HOME}" + + " -e ANDROID_HOME=${env.ANDROID_HOME}" + + " -e GRADLE_USER_HOME=${env.GRADLE_USER_HOME}", + in: [ 'centos7' ], + on: 'android', + ] } lazyStage { - name = 'package' - tasks = [ - pre: { - def currentVersion = androidVersion() - currentBuild.displayName = "#${env.BUILD_NUMBER} ${currentVersion.string}-${currentVersion.number}" - }, - run: { - fastLane('android', 'build', '', 'rh-ruby26') - }, - args: "-v /opt/android:/opt/android" - + " -v /opt/certificates:/opt/certificates" - + " -e JAVA_HOME=${env.JAVA_HOME}" - + " -e ANDROID_HOME=${env.ANDROID_HOME}" - + " -e GRADLE_USER_HOME=${env.GRADLE_USER_HOME}", - in: [ 'centos7' ], - on: 'android', - post: { - archiveArtifacts(artifacts: "${buildDir}/**", allowEmptyArchive: false) - }, - ] + name = 'package' + tasks = [ + pre: { + def currentVersion = androidVersion() + currentBuild.displayName = "#${env.BUILD_NUMBER} ${currentVersion.string}-${currentVersion.number}" + }, + run: { + fastLane('android', 'build', '', 'rh-ruby26') + }, + args: "-v /opt/android:/opt/android" + + " -v /opt/certificates:/opt/certificates" + + " -e JAVA_HOME=${env.JAVA_HOME}" + + " -e ANDROID_HOME=${env.ANDROID_HOME}" + + " -e GRADLE_USER_HOME=${env.GRADLE_USER_HOME}", + in: [ 'centos7' ], + on: 'android', + post: { + archiveArtifacts(artifacts: "${buildDir}/**", allowEmptyArchive: false) + }, + ] } // Release stage only 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 string to be release NEXT (no build number)', name: 'VERSION')] - ] - tasks = [ - run: { - def currentVersion = androidVersion() + 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 string to be release NEXT (no build number)', name: 'VERSION')] + ] + tasks = [ + run: { + def currentVersion = androidVersion() - // Define next version based on optional input - def nextVersion = [ string: currentVersion.string, number: currentVersion.number + 1 ] - if (env.lazyInput) { - nextVersion = [ string: env.lazyInput, number: nextVersion.number ] - } + // Define next version based on optional input + def nextVersion = [ string: currentVersion.string, number: currentVersion.number + 1 ] + if (env.lazyInput) { + nextVersion = [ string: env.lazyInput, number: nextVersion.number ] + } - gitAuth('bot-ci-dgm', { - // Refresh latest changelogs before releasing - sh("git checkout ${workingBranch}") - fastChangeLogs(nextVersion.number, 'android') - gitCommit("Provide changelogs for version ${currentVersion.number}", 'fastlane/metadata/android') - gitPush(remote, workingBranch) + gitAuth('bot-ci-dgm', { + // Refresh latest changelogs before releasing + sh("git checkout ${workingBranch}") + fastChangeLogs(nextVersion.number, 'android') + gitCommit("Provide changelogs for version ${currentVersion.number}", 'fastlane/metadata/android') + gitPush(remote, workingBranch) - // Refresh each deploy branches with changes from the working branch - deployBranches.each { deployBranch -> - gitMerge(workingBranch, deployBranch) - gitPush(remote, deployBranch) - } + // Refresh each deploy branches with changes from the working branch + deployBranches.each { deployBranch -> + gitMerge(workingBranch, deployBranch) + gitPush(remote, deployBranch) + } - // Tag the working branch - sh("git checkout ${workingBranch}") - gitTag("${currentVersion.string}-${currentVersion.number}", remote) + // Tag the working branch + sh("git checkout ${workingBranch}") + gitTag("${currentVersion.string}-${currentVersion.number}", remote) - // Refresh latest changelogs and bump version in working branch before deploying - androidVersion(nextVersion) - gitCommit("Update version to ${nextVersion.string}-${nextVersion.number}", 'app/build.gradle') + // Refresh latest changelogs and bump version in working branch before deploying + androidVersion(nextVersion) + gitCommit("Update version to ${nextVersion.string}-${nextVersion.number}", 'app/build.gradle') - // Publish working branch with latest changelogs and next version - gitPush(remote, workingBranch) - }) - }, - on: 'android', - ] + // Publish working branch with latest changelogs and next version + gitPush(remote, workingBranch) + }) + }, + on: 'android', + ] } // From alpha to beta, only for deploy branches lazyStage { - name = 'alpha' - onlyif = ( deployBranches.contains(lazyConfig['branch']) ) - input = 'Deploy to alpha users?' - tasks = [ - pre: { - unarchive(mapping:["${buildDir}/" : '.']) - }, - run: { - if ( !lazyConfig.env.DRYRUN ) { - withCredentials([file(credentialsId: env.GOOGLE_API_CID, variable: 'GOOGLE_API_FILE')]) { - sh('cp $GOOGLE_API_FILE ~/GoogleAPICredentials.json') - fastLane('android', 'alpha', '', 'rh-ruby24') - } - } - }, - args: "-v /opt/android:/opt/android" - + " -e JAVA_HOME=${env.JAVA_HOME}" - + " -e ANDROID_HOME=${env.ANDROID_HOME}" - + " -e GRADLE_USER_HOME=${env.GRADLE_USER_HOME}", - in: [ 'centos7' ], - on: 'android', - ] + name = 'alpha' + onlyif = ( deployBranches.contains(lazyConfig['branch']) ) + input = 'Deploy to alpha users?' + tasks = [ + pre: { + unarchive(mapping:["${buildDir}/" : '.']) + }, + run: { + if ( !lazyConfig.env.DRYRUN ) { + withCredentials([file(credentialsId: env.GOOGLE_API_CID, variable: 'GOOGLE_API_FILE')]) { + sh('cp $GOOGLE_API_FILE ~/GoogleAPICredentials.json') + fastLane('android', 'alpha', '', 'rh-ruby24') + } + } + }, + args: "-v /opt/android:/opt/android" + + " -e JAVA_HOME=${env.JAVA_HOME}" + + " -e ANDROID_HOME=${env.ANDROID_HOME}" + + " -e GRADLE_USER_HOME=${env.GRADLE_USER_HOME}", + in: [ 'centos7' ], + on: 'android', + ] } lazyStage { - name = 'beta' - onlyif = ( deployBranches.contains(lazyConfig['branch']) ) - input = 'Promote to beta users?' - tasks = [ - pre: { - unarchive(mapping:["${buildDir}/" : '.']) - }, - run: { - if ( !lazyConfig.env.DRYRUN ) { - withCredentials([file(credentialsId: env.GOOGLE_API_CID, variable: 'GOOGLE_API_FILE')]) { - sh('cp $GOOGLE_API_FILE ~/GoogleAPICredentials.json') - def currentVersion = androidVersion() - withEnv(["VERSION=${currentVersion.string}-${currentVersion.number}"],) { - fastLane('android', 'beta', '', 'rh-ruby24') - } - } - } - }, - args: "-v /opt/android:/opt/android" - + " -e JAVA_HOME=${env.JAVA_HOME}" - + " -e ANDROID_HOME=${env.ANDROID_HOME}" - + " -e GRADLE_USER_HOME=${env.GRADLE_USER_HOME}", - in: [ 'centos7' ], - on: 'android', - ] + name = 'beta' + onlyif = ( deployBranches.contains(lazyConfig['branch']) ) + input = 'Promote to beta users?' + tasks = [ + pre: { + unarchive(mapping:["${buildDir}/" : '.']) + }, + run: { + if ( !lazyConfig.env.DRYRUN ) { + withCredentials([file(credentialsId: env.GOOGLE_API_CID, variable: 'GOOGLE_API_FILE')]) { + sh('cp $GOOGLE_API_FILE ~/GoogleAPICredentials.json') + def currentVersion = androidVersion() + withEnv(["VERSION=${currentVersion.string}-${currentVersion.number}"],) { + fastLane('android', 'beta', '', 'rh-ruby24') + } + } + } + }, + args: "-v /opt/android:/opt/android" + + " -e JAVA_HOME=${env.JAVA_HOME}" + + " -e ANDROID_HOME=${env.ANDROID_HOME}" + + " -e GRADLE_USER_HOME=${env.GRADLE_USER_HOME}", + in: [ 'centos7' ], + on: 'android', + ] } lazyStage { - name = 'beta_crash' - onlyif = (! deployBranches.contains(lazyConfig['branch']) && lazyConfig['branch'] != workingBranch && lazyConfig.env.RELEASE ) - input = 'Promote to Crashlytics Beta users?' - tasks = [ - pre: { - unarchive(mapping:["${buildDir}/" : '.']) - }, - run: { - if ( !lazyConfig.env.DRYRUN ) { - fastLane('android', 'beta_crash', "fl_branch:\"${lazyConfig['branch']}\"", 'rh-ruby24') - } - }, - args: "-v /opt/android:/opt/android" - + " -e JAVA_HOME=${env.JAVA_HOME}" - + " -e ANDROID_HOME=${env.ANDROID_HOME}" - + " -e GRADLE_USER_HOME=${env.GRADLE_USER_HOME}", - in: [ 'centos7' ], - on: 'android', - ] + name = 'beta_crash' + onlyif = (! deployBranches.contains(lazyConfig['branch']) && lazyConfig['branch'] != workingBranch && lazyConfig.env.RELEASE ) + input = 'Promote to Crashlytics Beta users?' + tasks = [ + pre: { + unarchive(mapping:["${buildDir}/" : '.']) + }, + run: { + if ( !lazyConfig.env.DRYRUN ) { + fastLane('android', 'beta_crash', "fl_branch:\"${lazyConfig['branch']}\"", 'rh-ruby24') + } + }, + args: "-v /opt/android:/opt/android" + + " -e JAVA_HOME=${env.JAVA_HOME}" + + " -e ANDROID_HOME=${env.ANDROID_HOME}" + + " -e GRADLE_USER_HOME=${env.GRADLE_USER_HOME}", + in: [ 'centos7' ], + on: 'android', + ] } /* lazyStage { - name = 'production' - onlyif = ( deployBranches.contains(lazyConfig['branch']) ) - input = 'Promote to production users?' - tasks = [ - pre: { - unarchive(mapping:["${buildDir}/" : '.']) - }, - run: { - if ( !lazyConfig.env.DRYRUN ) { - withCredentials([file(credentialsId: env.GOOGLE_API_CID, variable: 'GOOGLE_API_FILE')]) { - sh('cp $GOOGLE_API_FILE ~/GoogleAPICredentials.json') - def currentVersion = androidVersion() - withEnv(["VERSION=${currentVersion.string}-${currentVersion.number}"],) { - fastLane('android', 'production', '', 'rh-ruby24') - } - } - } - }, - args: "-v /opt/android:/opt/android" - + " -e JAVA_HOME=${env.JAVA_HOME}" - + " -e ANDROID_HOME=${env.ANDROID_HOME}" - + " -e GRADLE_USER_HOME=${env.GRADLE_USER_HOME}", - in: [ 'centos7' ], - on: 'android', - ] + name = 'production' + onlyif = ( deployBranches.contains(lazyConfig['branch']) ) + input = 'Promote to production users?' + tasks = [ + pre: { + unarchive(mapping:["${buildDir}/" : '.']) + }, + run: { + if ( !lazyConfig.env.DRYRUN ) { + withCredentials([file(credentialsId: env.GOOGLE_API_CID, variable: 'GOOGLE_API_FILE')]) { + sh('cp $GOOGLE_API_FILE ~/GoogleAPICredentials.json') + def currentVersion = androidVersion() + withEnv(["VERSION=${currentVersion.string}-${currentVersion.number}"],) { + fastLane('android', 'production', '', 'rh-ruby24') + } + } + } + }, + args: "-v /opt/android:/opt/android" + + " -e JAVA_HOME=${env.JAVA_HOME}" + + " -e ANDROID_HOME=${env.ANDROID_HOME}" + + " -e GRADLE_USER_HOME=${env.GRADLE_USER_HOME}", + in: [ 'centos7' ], + on: 'android', + ] } */ \ No newline at end of file diff --git a/lazyDir/enable-scl.sh b/lazyDir/enable-scl.sh index 6cbf23b..a1547e9 100755 --- a/lazyDir/enable-scl.sh +++ b/lazyDir/enable-scl.sh @@ -13,11 +13,11 @@ # Execute arguments as command if requested if [ "$(basename "${0}")" == "$(basename ${BASH_SOURCE[0]})" -a ${#} -gt 0 ]; then - # Configure bash behavior - set -o errexit # exit on failed command - set -o nounset # exit on undeclared variables - set -o pipefail # exit on any failed command in pipes + # Configure bash behavior + set -o errexit # exit on failed command + set -o nounset # exit on undeclared variables + set -o pipefail # exit on any failed command in pipes - # Expand arguments as command + # Expand arguments as command exec "${@}" fi