status-react/ci/Jenkinsfile.combined

123 lines
3.5 KiB
Plaintext

library 'status-react-jenkins@v1.2.9'
pipeline {
agent { label 'linux' }
options {
timestamps()
disableConcurrentBuilds()
/* Prevent Jenkins jobs from running forever */
timeout(time: 40, unit: 'MINUTES')
/* Limit builds retained */
buildDiscarder(logRotator(
numToKeepStr: '10',
daysToKeepStr: '30',
artifactNumToKeepStr: '10',
))
}
/* WARNING: Defining parameters here with the ?: trick causes them to remember last value. */
parameters {
choice(
name: 'BUILD_TYPE',
description: 'Makefile target to build. Optional Parameter.',
choices: genChoices(params.BUILD_TYPE, ['manual', 'nightly', 'release', 'pr', 'e2e']),
)
booleanParam(
name: 'PUBLISH',
description: 'Trigger publishing of build results for nightly or release.',
defaultValue: params.PUBLISH ?: false,
)
}
stages {
stage('Prep') {
steps { script {
println "Current JOB: ${env.JOB_NAME}"
/* just for a shorter access */
btype = utils.getBuildType()
} }
}
stage('Build') {
parallel {
stage('iOS') { steps { script {
ios = jenkins.Build('status-react/combined/mobile-ios')
} } }
stage('Android') { steps { script {
apk = jenkins.Build('status-react/combined/mobile-android')
} } }
stage('Android e2e') { steps { script {
apke2e = jenkins.Build('status-react/combined/mobile-android-e2e')
} } }
}
}
stage('Archive') {
steps { script {
sh('rm -f pkg/*')
jenkins.copyArts(ios)
//jenkins.copyArts(iose2e)
jenkins.copyArts(apk)
jenkins.copyArts(apke2e)
sha = "pkg/${utils.pkgFilename('sha256')}"
dir('pkg') {
/* generate sha256 checksums for upload */
sh "sha256sum * | tee ../${sha}"
archiveArtifacts('*')
}
} }
}
stage('Upload') {
steps { script {
/* object for easier URLs handling */
urls = [
/* mobile */
Apk: utils.pkgUrl(apk), Apke2e: utils.pkgUrl(apke2e),
iOS: utils.pkgUrl(ios), /*iOSe2e: utils.pkgUrl(iose2e),*/
Diawi: utils.utils.getEnv(ios, 'DIAWI_URL'),
/* upload the sha256 checksums file too */
SHA: s3.uploadArtifact(sha),
]
/* add URLs to the build description */
jenkins.setBuildDesc(urls)
} }
}
stage('Publish') {
when { expression { params.PUBLISH } }
steps { script {
switch (btype) {
case 'nightly':
/* Create JSON file with newest build URLs */
s3.updateBucketJSON(urls, 'latest.json');
build(job: 'misc/status.im', wait: false);
break;
case 'release':
github.publishReleaseMobile();
break;
}
} }
}
stage('Run e2e') {
when { expression { btype == 'nightly' } }
steps { script {
e2eApk = utils.getEnv(apke2e, 'SAUCE_URL')
build(
job: 'end-to-end-tests/status-app-nightly',
parameters: [string(name: 'APK_NAME', value: e2eApk)],
wait: false
)
} }
}
}
}
/* Helper that generates list of available choices for a parameter
* but re-orders them based on the currently set value. First is default. */
def List genChoices(String previousChoice, List defaultChoices) {
if (previousChoice == null) {
return defaultChoices
}
choices = defaultChoices.minus(previousChoice)
choices.add(0, previousChoice)
return choices
}