Skip to content

Commit

Permalink
chore: building params jenkins branch adj (#1886)
Browse files Browse the repository at this point in the history
* fix: jenkins build by branch, missing param

* fix: jenkins build by branch, missing param
  • Loading branch information
yamilmedina authored Jun 26, 2023
1 parent 70f17ec commit c39c892
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,18 @@ def postGithubComment(String changeId, String body) {

}

/**
* Checks if the parameter is defined, otherwise sets it to the BRANCH_NAME env var
*
* @param changeBranch env var to use as the branch name if the changeBranch is not empty
*/
String handleChangeBranch(String changeBranch) {
if (changeBranch?.trim()) {
return changeBranch
}
return env.BRANCH_NAME
}

pipeline {
agent {
node {
Expand All @@ -86,14 +98,15 @@ pipeline {
String flavor = x
String buildType = defineBuildType(flavor)
String stageName = "Build $flavor$buildType"
String definedChangeBranch = handleChangeBranch(env.CHANGE_BRANCH)
dynamicStages[stageName] = {
node {
stage(stageName) {
build(
job: 'AR-build-pipeline',
parameters: [
string(name: 'SOURCE_BRANCH', value: env.BRANCH_NAME),
string(name: 'CHANGE_BRANCH', value: env.CHANGE_BRANCH),
string(name: 'CHANGE_BRANCH', value: definedChangeBranch),
string(name: 'BUILD_TYPE', value: buildType),
string(name: 'FLAVOR', value: flavor),
booleanParam(name: 'UPLOAD_TO_S3', value: true),
Expand Down

0 comments on commit c39c892

Please sign in to comment.