diff --git a/vars/getCheckoutInfo.groovy b/vars/getCheckoutInfo.groovy deleted file mode 100644 index 3d63c5b0ee492..0000000000000 --- a/vars/getCheckoutInfo.groovy +++ /dev/null @@ -1,31 +0,0 @@ -def call() { - - def repoInfo = [ - branch: env.ghprbSourceBranch ?: params.branch_specifier ?: null, - targetBranch: env.ghprbTargetBranch, - ] - - repoInfo.commit = sh( - script: "git rev-parse HEAD", - label: "determining checked out sha", - returnStdout: true - ).trim() - - if (repoInfo.targetBranch) { - sh( - script: "git fetch origin ${repoInfo.targetBranch}", - label: "fetch latest from '${repoInfo.targetBranch}' at origin" - ) - repoInfo.mergeBase = sh( - script: "git merge-base HEAD FETCH_HEAD", - label: "determining merge point with '${repoInfo.targetBranch}' at origin", - returnStdout: true - ).trim() - } - - print "repoInfo: ${repoInfo}" - - return repoInfo -} - -return this diff --git a/vars/workers.groovy b/vars/workers.groovy index 9ddcecfde99c0..b4e4a115f2011 100644 --- a/vars/workers.groovy +++ b/vars/workers.groovy @@ -51,24 +51,33 @@ def base(Map params, Closure closure) { } } - def checkoutInfo = [:] + def scmVars = [:] if (config.scm) { // Try to clone from Github up to 8 times, waiting 15 secs between attempts retryWithDelay(8, 15) { - checkout scm - } + scmVars = checkout scm + + def mergeBase + if (env.ghprbTargetBranch) { + sh( + script: "cd kibana && git fetch origin ${env.ghprbTargetBranch}", + label: "update reference to target branch 'origin/${env.ghprbTargetBranch}'" + ) + mergeBase = sh( + script: "cd kibana && git merge-base HEAD FETCH_HEAD", + label: "determining merge point with target branch 'origin/${env.ghprbTargetBranch}'", + returnStdout: true + ).trim() + } - dir("kibana") { - checkoutInfo = getCheckoutInfo() + ciStats.reportGitInfo( + env.ghprbSourceBranch ?: scmVars.GIT_LOCAL_BRANCH ?: scmVars.GIT_BRANCH, + scmVars.GIT_COMMIT, + env.ghprbTargetBranch, + mergeBase + ) } - - ciStats.reportGitInfo( - checkoutInfo.branch, - checkoutInfo.commit, - checkoutInfo.targetBranch, - checkoutInfo.mergeBase - ) } withEnv([ @@ -78,7 +87,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=${scmVars.GIT_BRANCH ?: ''}", ]) { withCredentials([ string(credentialsId: 'vault-addr', variable: 'VAULT_ADDR'),