#!groovy
/*
* This work is protected under copyright law in the Kingdom of
* The Netherlands. The rules of the Berne Convention for the
* Protection of Literary and Artistic Works apply.
* Digital Me B.V. is the copyright owner.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* 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
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Load Jenkins shared libraries common to all projects
def libCmn = [
remote: 'https://code.in.digital-me.nl/git/DEVops/JenkinsLibLazy.git',
branch: env.BRANCH_NAME,
credentialsId: null,
]
library(
identifier: "libCmn@${libCmn.branch}",
retriever: modernSCM([
$class: 'GitSCMSource',
remote: libCmn.remote,
credentialsId: libCmn.credentialsId
])
)
// Initialize lazyConfig for this pipeline
lazyConfig(
name: 'DummyAnd',
)
// Define a method to run Fastlane from the later lazyStages
def fastlane(platform, lane) {
// Lookup the relevant credentials first
if (platform == 'android') {
usernamePasswordMap = [
credentialsId: 'dappre-google',
passwordVariable: 'ANDROID_KEYPASSWORD',
usernameVariable: 'ANDROID_KEYALIAS'
]
} else {
error "Unknown platform '${plateform}'"
}
// With the credentials, prepare the relevant environment
withCredentials([usernamePassword(usernamePasswordMap)]){
if (platform == 'android' ) {
envMap = [
'SKIP_SLOW_FASTLANE_WARNING=YES',
'FASTLANE_SKIP_UPDATE_CHECK=YES',
'FASTLANE_OPT_OUT_USAGE=YES',
"ANDROID_STOREFILE=/opt/certificates/${ANDROID_KEYALIAS}.jks",
"ANDROID_STOREPASSWORD=${ANDROID_KEYPASSWORD}",
'JAVA_HOME=/usr/java/latest',
'SLAVE_AAPT_TIMEOUT=15',
]
} else {
error "Unknown platform '${plateform}'"
}
// Now only calling Fastlane
withEnv(envMap) {
sh "bundle install"
sh "bundle exec fastlane ${platform} ${lane}"
}
}
}
// Define lazyStages
lazyStage {
name = 'validate'
tasks = [
run: {
fastlane('android', 'test')
},
on: 'android',
]
}
lazyStage {
name = 'build'
tasks = [
run: {
fastlane('android', 'build')
},
post: {
archiveArtifacts(artifacts: 'app/build/outputs/apk/**', allowEmptyArchive: false)
},
on: 'android',
]
}
//lazyStage {
// name = 'release'
// tasks = [ [ run: [ 'fastlane_alpha.sh' ], on: 'android' ] ]
//}
//
//lazyStage {
// name = 'publish'
// tasks = [ [ run: [ 'fastlane_beta.sh' ], on: 'android' ] ]
//}