mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
[ci/stats] fix git metadata collection (#66840)
This commit is contained in:
parent
fcb8d2a608
commit
9eaf0c050a
2 changed files with 45 additions and 23 deletions
31
vars/getCheckoutInfo.groovy
Normal file
31
vars/getCheckoutInfo.groovy
Normal file
|
@ -0,0 +1,31 @@
|
|||
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
|
|
@ -51,33 +51,24 @@ 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
|
||||
}
|
||||
|
||||
dir("kibana") {
|
||||
checkoutInfo = getCheckoutInfo()
|
||||
}
|
||||
|
||||
ciStats.reportGitInfo(
|
||||
checkoutInfo.branch,
|
||||
checkoutInfo.commit,
|
||||
checkoutInfo.targetBranch,
|
||||
checkoutInfo.mergeBase
|
||||
)
|
||||
}
|
||||
|
||||
withEnv([
|
||||
|
@ -87,7 +78,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'),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue