Skip to content

Commit

Permalink
ensure that checkoutInfo.branch is defined and consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
spalger committed May 19, 2020
1 parent 9727844 commit b5e4791
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ export function runFailedTestsReporterCli() {
}

const isPr = !!process.env.ghprbPullId;
const isMasterOrVersion =
branch.match(/^(origin\/){0,1}master$/) || branch.match(/^(origin\/){0,1}\d+\.(x|\d+)$/);
const isMasterOrVersion = branch === 'master' || branch.match(/^\d+\.(x|\d+)$/);
if (!isMasterOrVersion || isPr) {
log.info('Failure issues only created on master/version branch jobs');
updateGithub = false;
Expand Down
2 changes: 1 addition & 1 deletion src/dev/ci_setup/checkout_sibling_es.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function checkout_sibling {
fi

cloneAuthor="elastic"
cloneBranch="${PR_SOURCE_BRANCH:-${GIT_BRANCH#*/}}" # GIT_BRANCH starts with the repo, i.e., origin/master
cloneBranch="$GIT_BRANCH"
if clone_target_is_valid ; then
return 0
fi
Expand Down
2 changes: 1 addition & 1 deletion src/dev/ci_setup/extract_bootstrap_cache.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -e

targetBranch="${PR_TARGET_BRANCH:-${GIT_BRANCH#*/}}"
targetBranch="${PR_TARGET_BRANCH:-$GIT_BRANCH}"
bootstrapCache="$HOME/.kibana/bootstrap_cache/$targetBranch.tar"

###
Expand Down
16 changes: 13 additions & 3 deletions vars/getCheckoutInfo.groovy
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
def call() {

def call(branchOverride) {
def repoInfo = [
branch: env.ghprbSourceBranch ?: params.branch_specifier ?: null,
branch: branchOverride ?: env.ghprbSourceBranch,
targetBranch: env.ghprbTargetBranch,
]

if (repoInfo.branch == null) {
if (!(params.branch_specifier instanceof String)) {
throw new Exception(
"Unable to determine branch automatically, either pass a branch name to getCheckoutInfo() or use the branch_specifier param."
)
}

// strip prefix from the branch specifier to make it consistent with ghprbSourceBranch
repoInfo.branch = params.branch_specifier.replaceFirst(/^(refs\/heads\/|origin\/)/, "")
}

repoInfo.commit = sh(
script: "git rev-parse HEAD",
label: "determining checked out sha",
Expand Down
2 changes: 1 addition & 1 deletion vars/workers.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def base(Map params, Closure closure) {
"PR_TARGET_BRANCH=${env.ghprbTargetBranch ?: ''}",
"PR_AUTHOR=${env.ghprbPullAuthorLogin ?: ''}",
"TEST_BROWSER_HEADLESS=1",
"GIT_BRANCH=${checkoutInfo.branch ?: ''}",
"GIT_BRANCH=${checkoutInfo.branch}",
]) {
withCredentials([
string(credentialsId: 'vault-addr', variable: 'VAULT_ADDR'),
Expand Down

0 comments on commit b5e4791

Please sign in to comment.