Skip to content
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions vars/getCheckoutInfo.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
def call() {

def repoInfo = [
branch: env.ghprbSourceBranch ?: params.branch_specifier ?: 'missing branch_specifier',
targetBranch: env.ghprbTargetBranch,
]

dir("kibana") {
repoInfo.commit = sh(
script: "git rev-parse HEAD",
label: "determining checked out sha",
returnStdout: true
).trim()

if (repoInfo.targetBranch) {
sh(
script: "git fetch https://github.com/elastic/kibana.git ${repoInfo.targetBranch}",
label: "fetch latest from '${repoInfo.targetBranch}' at https://github.com/elastic/kibana.git"
)
repoInfo.mergeBase = sh(
script: "git merge-base HEAD FETCH_HEAD",
label: "determining merge point with '${repoInfo.targetBranch}' at https://github.com/elastic/kibana.git",
returnStdout: true
).trim()
}
}

print "repoInfo: ${repoInfo}"

return repoInfo
}

return this
34 changes: 11 additions & 23 deletions vars/workers.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -51,33 +51,21 @@ def base(Map params, Closure closure) {
}
}

def scmVars = [:]
def checkoutInfo = [:]

if (config.scm) {
// Try to clone from Github up to 8 times, waiting 15 secs between attempts
retryWithDelay(8, 15) {
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()
}

ciStats.reportGitInfo(
env.ghprbSourceBranch ?: scmVars.GIT_LOCAL_BRANCH ?: scmVars.GIT_BRANCH,
scmVars.GIT_COMMIT,
env.ghprbTargetBranch,
mergeBase
)
checkout scm
}

checkoutInfo = getCheckoutInfo()
ciStats.reportGitInfo(
checkoutInfo.branch,
checkoutInfo.commit,
checkoutInfo.targetBranch,
checkoutInfo.mergeBase
)
}

withEnv([
Expand All @@ -87,7 +75,7 @@ def base(Map params, Closure closure) {
"PR_TARGET_BRANCH=${env.ghprbTargetBranch ?: ''}",
"PR_AUTHOR=${env.ghprbPullAuthorLogin ?: ''}",
"TEST_BROWSER_HEADLESS=1",
"GIT_BRANCH=${scmVars.GIT_BRANCH ?: ''}",
"GIT_BRANCH=${checkoutInfo.branch ?: ''}",
]) {
withCredentials([
string(credentialsId: 'vault-addr', variable: 'VAULT_ADDR'),
Expand Down