ci: parametrize publishing, make BUILD_TYPE a choice

This changes the behavior of mobile combined builds to not publish
the results of `nightly` or `release` builds unless `PUBLISH`
parameter is set to `true`.

It also makes the `BUILD_TYPE` into a dropdown choice field with
pre-defined values, like `manual` or `e2e`.

Changes:
- Add parameter definitions for `BUILD_TYPE` and `PUBLISH`
- Move uploading of `latest.json` to `Publish` stage
- Make `Publish` stage optional based on the `PUBLISH` parameter

Requires: https://github.com/status-im/status-react-jenkins/pull/21

Signed-off-by: Jakub Sokołowski <jakub@status.im>
Signed-off-by: Andrea Maria Piana <andrea.maria.piana@gmail.com>
This commit is contained in:
Jakub Sokołowski 2021-01-07 10:57:25 +01:00 committed by Andrea Maria Piana
parent e0e497d3d0
commit 9889e80bbd
No known key found for this signature in database
GPG Key ID: AA6CCA6DE0E06424
6 changed files with 40 additions and 13 deletions

View File

@ -1,4 +1,4 @@
library 'status-react-jenkins@v1.2.8'
library 'status-react-jenkins@v1.2.9'
pipeline {
agent { label 'linux' }

View File

@ -1,4 +1,4 @@
library 'status-react-jenkins@v1.2.8'
library 'status-react-jenkins@v1.2.9'
pipeline {
agent { label 'linux' }
@ -16,6 +16,20 @@ pipeline {
))
}
/* 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 {
@ -65,18 +79,20 @@ pipeline {
]
/* add URLs to the build description */
jenkins.setBuildDesc(urls)
/* Create JSON file with newest build URLs */
switch (btype) {
/* legacy naming, should have named it nightly.json */
case 'nightly': s3.updateBucketJSON(urls, 'latest.json'); break
}
} }
}
stage('Publish') {
when { expression { params.PUBLISH } }
steps { script {
switch (btype) {
case 'nightly': build(job: 'misc/status.im', wait: false); break
case 'release': github.publishReleaseMobile(); break
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;
}
} }
}
@ -93,3 +109,14 @@ pipeline {
}
}
}
/* 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
}

View File

@ -1,4 +1,4 @@
library 'status-react-jenkins@v1.2.8'
library 'status-react-jenkins@v1.2.9'
pipeline {
agent { label 'macos-xcode-11.5' }

View File

@ -1,4 +1,4 @@
library 'status-react-jenkins@v1.2.8'
library 'status-react-jenkins@v1.2.9'
pipeline {
agent { label params.AGENT_LABEL }

View File

@ -1,4 +1,4 @@
library 'status-react-jenkins@v1.2.8'
library 'status-react-jenkins@v1.2.9'
pipeline {
agent { label 'macos' }

View File

@ -1,4 +1,4 @@
library 'status-react-jenkins@v1.2.8'
library 'status-react-jenkins@v1.2.9'
pipeline {
agent { label 'linux' }