2023-06-29 13:40:43 +00:00
|
|
|
#!/usr/bin/env groovy
|
2024-10-23 07:15:59 +00:00
|
|
|
library 'status-jenkins-lib@v1.9.13'
|
2020-03-06 15:43:04 +00:00
|
|
|
|
2024-07-03 10:07:18 +00:00
|
|
|
import groovy.json.JsonBuilder
|
|
|
|
|
2018-08-14 18:09:52 +00:00
|
|
|
pipeline {
|
2020-02-27 14:16:09 +00:00
|
|
|
agent { label 'linux' }
|
2018-08-14 18:09:52 +00:00
|
|
|
|
|
|
|
options {
|
2018-12-11 14:27:21 +00:00
|
|
|
timestamps()
|
2018-08-14 18:09:52 +00:00
|
|
|
disableConcurrentBuilds()
|
2018-10-30 09:38:52 +00:00
|
|
|
/* Prevent Jenkins jobs from running forever */
|
2020-07-02 09:58:45 +00:00
|
|
|
timeout(time: 40, unit: 'MINUTES')
|
2018-10-30 09:38:52 +00:00
|
|
|
/* Limit builds retained */
|
2018-08-14 18:09:52 +00:00
|
|
|
buildDiscarder(logRotator(
|
|
|
|
numToKeepStr: '10',
|
|
|
|
daysToKeepStr: '30',
|
2024-02-28 14:50:47 +00:00
|
|
|
artifactNumToKeepStr: '1',
|
2018-08-14 18:09:52 +00:00
|
|
|
))
|
|
|
|
}
|
2018-08-29 07:43:21 +00:00
|
|
|
|
2021-01-07 09:57:25 +00:00
|
|
|
/* WARNING: Defining parameters here with the ?: trick causes them to remember last value. */
|
2023-04-12 09:55:19 +00:00
|
|
|
parameters {
|
2021-01-07 09:57:25 +00:00
|
|
|
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.',
|
2021-02-17 14:16:27 +00:00
|
|
|
defaultValue: getPublishDefault(params.PUBLISH),
|
2021-01-07 09:57:25 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2018-08-14 18:09:52 +00:00
|
|
|
stages {
|
2018-08-29 07:43:21 +00:00
|
|
|
stage('Prep') {
|
2018-08-14 18:09:52 +00:00
|
|
|
steps { script {
|
2022-09-14 10:16:55 +00:00
|
|
|
println("Current JOB: ${env.JOB_NAME}")
|
2018-08-14 18:09:52 +00:00
|
|
|
} }
|
|
|
|
}
|
|
|
|
stage('Build') {
|
|
|
|
parallel {
|
2019-08-08 17:15:13 +00:00
|
|
|
stage('iOS') { steps { script {
|
2022-07-17 12:37:46 +00:00
|
|
|
ios = jenkins.Build('status-mobile/platforms/ios')
|
2019-08-08 17:15:13 +00:00
|
|
|
} } }
|
2018-08-21 15:17:25 +00:00
|
|
|
stage('Android') { steps { script {
|
2022-07-17 12:37:46 +00:00
|
|
|
apk = jenkins.Build('status-mobile/platforms/android')
|
2018-08-21 15:17:25 +00:00
|
|
|
} } }
|
2022-08-26 13:18:45 +00:00
|
|
|
stage('Tests') { steps { script {
|
2022-09-01 13:08:26 +00:00
|
|
|
jenkins.Build('status-mobile/platforms/tests')
|
2022-08-26 13:18:45 +00:00
|
|
|
} } }
|
2018-08-14 18:09:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
stage('Archive') {
|
2018-08-21 15:17:25 +00:00
|
|
|
steps { script {
|
2018-08-14 18:09:52 +00:00
|
|
|
sh('rm -f pkg/*')
|
2020-03-06 15:43:04 +00:00
|
|
|
jenkins.copyArts(ios)
|
|
|
|
jenkins.copyArts(apk)
|
2021-09-28 11:55:14 +00:00
|
|
|
sha = "pkg/${utils.pkgFilename(ext: 'sha256')}"
|
2018-11-29 14:23:51 +00:00
|
|
|
dir('pkg') {
|
|
|
|
/* generate sha256 checksums for upload */
|
2020-07-08 14:08:51 +00:00
|
|
|
sh "sha256sum * | tee ../${sha}"
|
2018-11-29 14:23:51 +00:00
|
|
|
archiveArtifacts('*')
|
|
|
|
}
|
2018-08-21 15:17:25 +00:00
|
|
|
} }
|
2018-08-14 18:09:52 +00:00
|
|
|
}
|
|
|
|
stage('Upload') {
|
|
|
|
steps { script {
|
2018-12-11 14:27:21 +00:00
|
|
|
/* object for easier URLs handling */
|
|
|
|
urls = [
|
|
|
|
/* mobile */
|
2023-08-07 09:29:55 +00:00
|
|
|
Apk: utils.pkgUrl(apk),
|
|
|
|
iOS: utils.pkgUrl(ios),
|
2022-09-08 07:43:39 +00:00
|
|
|
Diawi: utils.getEnv(ios, 'DIAWI_URL'),
|
2018-12-11 14:27:21 +00:00
|
|
|
/* upload the sha256 checksums file too */
|
2024-07-01 07:54:54 +00:00
|
|
|
SHA: s5cmd.upload(sha),
|
2018-12-11 14:27:21 +00:00
|
|
|
]
|
2018-10-02 20:40:36 +00:00
|
|
|
/* add URLs to the build description */
|
2020-03-06 15:43:04 +00:00
|
|
|
jenkins.setBuildDesc(urls)
|
2018-08-14 18:09:52 +00:00
|
|
|
} }
|
|
|
|
}
|
|
|
|
stage('Publish') {
|
2021-01-07 09:57:25 +00:00
|
|
|
when { expression { params.PUBLISH } }
|
2018-09-19 13:35:38 +00:00
|
|
|
steps { script {
|
2024-04-04 09:35:39 +00:00
|
|
|
switch (utils.getBuildType()) {
|
2024-02-21 17:18:30 +00:00
|
|
|
case 'nightly': /* Create JSON file with newest build URLs */
|
2024-07-01 07:54:54 +00:00
|
|
|
updateBucketJSON(urls, 'latest.json');
|
2021-01-07 09:57:25 +00:00
|
|
|
break;
|
|
|
|
case 'release':
|
2022-07-17 12:37:46 +00:00
|
|
|
github.publishReleaseFiles(repo: 'status-mobile');
|
2021-01-07 09:57:25 +00:00
|
|
|
break;
|
2019-02-05 09:35:14 +00:00
|
|
|
}
|
2018-09-19 13:35:38 +00:00
|
|
|
} }
|
2018-08-14 18:09:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-01-07 09:57:25 +00:00
|
|
|
|
|
|
|
/* 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
|
|
|
|
}
|
2021-02-17 14:16:27 +00:00
|
|
|
|
|
|
|
/* Helper that makes PUBLISH default to 'false' unless:
|
|
|
|
* - The build is for a release branch
|
|
|
|
* - A user explicitly specified a value
|
|
|
|
* Since release builds create and re-create GitHub drafts every time. */
|
|
|
|
def Boolean getPublishDefault(Boolean previousValue) {
|
2022-07-17 12:37:46 +00:00
|
|
|
if (env.JOB_NAME.startsWith('status-mobile/release')) { return true }
|
2021-02-17 14:16:27 +00:00
|
|
|
if (previousValue != null) { return previousValue }
|
|
|
|
return false
|
|
|
|
}
|
2024-07-01 07:54:54 +00:00
|
|
|
|
|
|
|
/* Helper for updating JSON with newest builds. */
|
|
|
|
def updateBucketJSON(urls, fileName) {
|
|
|
|
/* latest.json has slightly different key names */
|
|
|
|
def content = [
|
|
|
|
DIAWI: urls.Diawi,
|
|
|
|
APK: urls.Apk, IOS: urls.iOS,
|
|
|
|
APP: urls.App, MAC: urls.Mac,
|
|
|
|
WIN: urls.Win, SHA: urls.SHA
|
|
|
|
]
|
|
|
|
def filePath = "${pwd()}/pkg/${fileName}"
|
|
|
|
/* it might not exist */
|
|
|
|
sh "mkdir -p ${pwd()}/pkg"
|
|
|
|
def contentJson = new JsonBuilder(content).toPrettyString()
|
|
|
|
println "${filePath}:\n${contentJson}"
|
|
|
|
writeFile(file: filePath, text: contentJson)
|
|
|
|
return s5cmd.upload(filePath)
|
|
|
|
}
|
|
|
|
|