mirror of
https://github.com/status-im/status-mobile.git
synced 2025-01-13 18:25:45 +00:00
modify .env settings using Jenkins params
Signed-off-by: Jakub Sokołowski <jakub@status.im> Signed-off-by: Igor Mandrigin <i@mandrigin.ru>
This commit is contained in:
parent
316a50b032
commit
55abf20645
@ -80,7 +80,7 @@ pipeline {
|
|||||||
}
|
}
|
||||||
stage('Bundle') {
|
stage('Bundle') {
|
||||||
steps {
|
steps {
|
||||||
script { apk = mobile.android.bundle(btype) }
|
script { apk = mobile.android.bundle() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage('Archive') {
|
stage('Archive') {
|
||||||
|
@ -14,7 +14,6 @@ pipeline {
|
|||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
stages {
|
stages {
|
||||||
stage('Prep') {
|
stage('Prep') {
|
||||||
steps { script {
|
steps { script {
|
||||||
|
@ -65,7 +65,7 @@ pipeline {
|
|||||||
}
|
}
|
||||||
stage('Bundle') {
|
stage('Bundle') {
|
||||||
steps {
|
steps {
|
||||||
script { api = mobile.ios.bundle(btype) }
|
script { api = mobile.ios.bundle() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage('Archive') {
|
stage('Archive') {
|
||||||
|
@ -1,14 +1,15 @@
|
|||||||
utils = load 'ci/utils.groovy'
|
utils = load 'ci/utils.groovy'
|
||||||
|
|
||||||
def bundle(type = 'nightly') {
|
def bundle() {
|
||||||
|
def btype = utils.getBuildType()
|
||||||
/* Disable Gradle Daemon https://stackoverflow.com/questions/38710327/jenkins-builds-fail-using-the-gradle-daemon */
|
/* Disable Gradle Daemon https://stackoverflow.com/questions/38710327/jenkins-builds-fail-using-the-gradle-daemon */
|
||||||
def gradleOpt = "-PbuildUrl='${currentBuild.absoluteUrl}' -Dorg.gradle.daemon=false "
|
def gradleOpt = "-PbuildUrl='${currentBuild.absoluteUrl}' -Dorg.gradle.daemon=false "
|
||||||
def target = "release"
|
def target = "release"
|
||||||
|
|
||||||
if (type in ['pr', 'e2e']) {
|
if (btype in ['pr', 'e2e']) {
|
||||||
/* PR builds shouldn't replace normal releases */
|
/* PR builds shouldn't replace normal releases */
|
||||||
target = 'pr'
|
target = 'pr'
|
||||||
} else if (type == 'release') {
|
} else if (btype == 'release') {
|
||||||
gradleOpt += "-PreleaseVersion='${utils.getVersion('mobile_files')}'"
|
gradleOpt += "-PreleaseVersion='${utils.getVersion('mobile_files')}'"
|
||||||
}
|
}
|
||||||
dir('android') {
|
dir('android') {
|
||||||
@ -28,7 +29,7 @@ def bundle(type = 'nightly') {
|
|||||||
}
|
}
|
||||||
sh 'find android/app/build/outputs/apk'
|
sh 'find android/app/build/outputs/apk'
|
||||||
def outApk = "android/app/build/outputs/apk/${target}/app-${target}.apk"
|
def outApk = "android/app/build/outputs/apk/${target}/app-${target}.apk"
|
||||||
def pkg = utils.pkgFilename(type, 'apk')
|
def pkg = utils.pkgFilename(btype, 'apk')
|
||||||
/* rename for upload */
|
/* rename for upload */
|
||||||
sh "cp ${outApk} ${pkg}"
|
sh "cp ${outApk} ${pkg}"
|
||||||
/* necessary for Fastlane */
|
/* necessary for Fastlane */
|
||||||
|
@ -53,22 +53,15 @@ def prepNixEnvironment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def prep(type = 'nightly') {
|
def prep(type = 'nightly') {
|
||||||
|
/* build/downloads all nix deps in advance */
|
||||||
prepNixEnvironment()
|
prepNixEnvironment()
|
||||||
|
/* rebase unless this is a release build */
|
||||||
utils.doGitRebase()
|
utils.doGitRebase()
|
||||||
/* ensure that we start from a known state */
|
/* ensure that we start from a known state */
|
||||||
sh 'make clean'
|
sh 'make clean'
|
||||||
/* select type of build */
|
/* pick right .env and update from params */
|
||||||
switch (type) {
|
utils.updateEnv(type)
|
||||||
case 'nightly':
|
|
||||||
sh 'cp .env.nightly .env'; break
|
|
||||||
case 'release':
|
|
||||||
sh 'cp .env.prod .env'; break
|
|
||||||
case 'e2e':
|
|
||||||
sh 'cp .env.e2e .env'; break
|
|
||||||
default:
|
|
||||||
sh 'cp .env.jenkins .env'; break
|
|
||||||
}
|
|
||||||
if (env.TARGET_PLATFORM == 'android' || env.TARGET_PLATFORM == 'ios') {
|
if (env.TARGET_PLATFORM == 'android' || env.TARGET_PLATFORM == 'ios') {
|
||||||
/* Run at start to void mismatched numbers */
|
/* Run at start to void mismatched numbers */
|
||||||
utils.genBuildNumber()
|
utils.genBuildNumber()
|
||||||
|
@ -6,12 +6,10 @@ def plutil(name, value) {
|
|||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
|
|
||||||
def bundle(type) {
|
def bundle() {
|
||||||
if (!type) {
|
def btype = utils.getBuildType()
|
||||||
type = utils.getBuildType()
|
|
||||||
}
|
|
||||||
def target
|
def target
|
||||||
switch (type) {
|
switch (btype) {
|
||||||
case 'release': target = 'release'; break;
|
case 'release': target = 'release'; break;
|
||||||
case 'testflight': target = 'release'; break;
|
case 'testflight': target = 'release'; break;
|
||||||
case 'e2e': target = 'e2e'; break;
|
case 'e2e': target = 'e2e'; break;
|
||||||
@ -39,14 +37,14 @@ def bundle(type) {
|
|||||||
}
|
}
|
||||||
/* rename built file for uploads and archivization */
|
/* rename built file for uploads and archivization */
|
||||||
def pkg = ''
|
def pkg = ''
|
||||||
if (type == 'release') {
|
if (btype == 'release') {
|
||||||
pkg = utils.pkgFilename('release', 'ipa')
|
pkg = utils.pkgFilename('release', 'ipa')
|
||||||
sh "cp status_appstore/StatusIm.ipa ${pkg}"
|
sh "cp status_appstore/StatusIm.ipa ${pkg}"
|
||||||
} else if (type == 'e2e') {
|
} else if (btype == 'e2e') {
|
||||||
pkg = utils.pkgFilename('e2e', 'app.zip')
|
pkg = utils.pkgFilename('e2e', 'app.zip')
|
||||||
sh "cp status-e2e/StatusIm.app.zip ${pkg}"
|
sh "cp status-e2e/StatusIm.app.zip ${pkg}"
|
||||||
} else if (type != 'testflight') {
|
} else if (btype != 'testflight') {
|
||||||
pkg = utils.pkgFilename(type, 'ipa')
|
pkg = utils.pkgFilename(btype, 'ipa')
|
||||||
sh "cp status-adhoc/StatusIm.ipa ${pkg}"
|
sh "cp status-adhoc/StatusIm.ipa ${pkg}"
|
||||||
}
|
}
|
||||||
/* necessary for Diawi upload */
|
/* necessary for Diawi upload */
|
||||||
|
@ -28,21 +28,35 @@ def abortPreviousRunningBuilds() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def Build(name = null, buildType = null) {
|
def Build(name = null) {
|
||||||
|
/**
|
||||||
|
* Generate parameters to pass from current params
|
||||||
|
* This allows utils.updateEnv() to work in sub-jobs
|
||||||
|
**/
|
||||||
|
parameters = params.keySet().collectEntries { key ->
|
||||||
|
[(key): [
|
||||||
|
name: key,
|
||||||
|
value: params.get(key),
|
||||||
|
$class: 'StringParameterValue'
|
||||||
|
]]
|
||||||
|
}
|
||||||
/* default to current build type */
|
/* default to current build type */
|
||||||
buildType = buildType ? buildType : utils.getBuildType()
|
parameters['BUILD_TYPE'].value = utils.getBuildType()
|
||||||
/* need to drop origin/ to match definitions of child jobs */
|
/* need to drop origin/ to match definitions of child jobs */
|
||||||
def branchName = utils.branchName()
|
parameters['BRANCH'].value = utils.branchName()
|
||||||
|
/* necessary for updating GitHub PRs */
|
||||||
|
parameters['CHANGE_ID'] = [
|
||||||
|
name: 'CHANGE_ID',
|
||||||
|
value: env.CHANGE_ID,
|
||||||
|
$class: 'StringParameterValue'
|
||||||
|
]
|
||||||
/* always pass the BRANCH and BUILD_TYPE params with current branch */
|
/* always pass the BRANCH and BUILD_TYPE params with current branch */
|
||||||
def b = build(
|
def b = build(
|
||||||
job: name,
|
job: name,
|
||||||
/* this allows us to analize the job even after failure */
|
/* this allows us to analize the job even after failure */
|
||||||
propagate: false,
|
propagate: false,
|
||||||
parameters: [
|
parameters: parameters.values()
|
||||||
[name: 'BRANCH', value: branchName, $class: 'StringParameterValue'],
|
)
|
||||||
[name: 'BUILD_TYPE', value: buildType, $class: 'StringParameterValue'],
|
|
||||||
[name: 'CHANGE_ID', value: env.CHANGE_ID, $class: 'StringParameterValue'],
|
|
||||||
])
|
|
||||||
/* BlueOcean seems to not show child-build links */
|
/* BlueOcean seems to not show child-build links */
|
||||||
println "Build: ${b.getAbsoluteUrl()} (${b.result})"
|
println "Build: ${b.getAbsoluteUrl()} (${b.result})"
|
||||||
if (b.result != 'SUCCESS') {
|
if (b.result != 'SUCCESS') {
|
||||||
|
@ -154,7 +154,7 @@ def getBuildType() {
|
|||||||
if (jobName.contains('e2e')) {
|
if (jobName.contains('e2e')) {
|
||||||
return 'e2e'
|
return 'e2e'
|
||||||
}
|
}
|
||||||
if (jobName.startsWith('status-react/pull requests')) {
|
if (jobName.startsWith('status-react/prs')) {
|
||||||
return 'pr'
|
return 'pr'
|
||||||
}
|
}
|
||||||
if (jobName.startsWith('status-react/nightly')) {
|
if (jobName.startsWith('status-react/nightly')) {
|
||||||
@ -185,4 +185,29 @@ def changeId() {
|
|||||||
return changeId
|
return changeId
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def updateEnv(type) {
|
||||||
|
def envFile = "${env.WORKSPACE}/.env"
|
||||||
|
/* select .env based on type of build */
|
||||||
|
def selectedEnv = '.env.jenkins'
|
||||||
|
switch (type) {
|
||||||
|
case 'nightly': selectedEnv = '.env.nightly'; break
|
||||||
|
case 'release': selectedEnv = '.env.prod'; break
|
||||||
|
case 'e2e': selectedEnv = '.env.e2e'; break
|
||||||
|
}
|
||||||
|
sh "cp ${selectedEnv} .env"
|
||||||
|
/* find a list of .env settings to check for them in params */
|
||||||
|
def envContents = readFile(envFile)
|
||||||
|
def envLines = envContents.split()
|
||||||
|
def envVars = envLines.collect { it.split('=').first() }
|
||||||
|
/* for each var available in params modify the .env file */
|
||||||
|
envVars.each { var ->
|
||||||
|
if (params.get(var)) { /* var exists in params and is not empty */
|
||||||
|
println("Changing setting: ${var}=${params.get(var)}")
|
||||||
|
sh "sed -i'.bkp' 's/${var}=.*/${var}=${params.get(var)}/' ${envFile}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* show contents for debugging purposes */
|
||||||
|
sh "cat ${envFile}"
|
||||||
|
}
|
||||||
|
|
||||||
return this
|
return this
|
||||||
|
Loading…
x
Reference in New Issue
Block a user