Jenkins: Fall back to stashed data if the node can't reach github

This commit is contained in:
richardg867
2022-07-29 13:03:43 -03:00
committed by GitHub
parent d674b4cf49
commit 2869f114c2

29
.ci/Jenkinsfile vendored
View File

@@ -98,15 +98,18 @@ def gitClone(repository, branch) {
/* Clean workspace. */
cleanWs()
/* Use stashes to pass the repository around debian.citadel, as it's known to be faster than git clone there. */
if (env.NODE_NAME != 'debian.citadel' || env.GIT_STASHED != 'true') {
/* Perform git clone if stashed data isn't available yet, or if
this is not debian.citadel where stash is faster than clone. */
if (env.GIT_STASHED != 'true' || env.NODE_NAME != 'debian.citadel') {
/* Catch network issues in clone. */
try {
/* Perform clone/checkout, making sure to update the changelog only once
to avoid inaccurate entries from new commits pushed inbetween clones. */
def scmVars = checkout poll: true,
def scmVars = checkout(poll: true,
changelog: env.GIT_STASHED != 'true',
scm: [$class: 'GitSCM',
branches: [[name: branch]],
userRemoteConfigs: [[url: repository]]]
userRemoteConfigs: [[url: repository]]])
if (env.GIT_COMMIT == null) {
/* Save the current HEAD commit. */
@@ -120,15 +123,23 @@ def gitClone(repository, branch) {
}
println "[-] Using git commit [${env.GIT_COMMIT}]"
/* Stash data and mark it as stashed if required. */
/* Stash data if required, marking it as stashed. */
if (env.GIT_STASHED != 'true') {
stash name: 'git', useDefaultExcludes: false
stash(name: 'git', useDefaultExcludes: false)
env.GIT_STASHED = 'true'
}
} else {
/* Unstash data. */
unstash name: 'git'
/* No need to use stashed data. */
return;
} catch (e) {
/* If clone fails, use stashed data if available, or re-throw exception otherwise. */
if (env.GIT_STASHED != 'true')
throw e;
}
}
/* Unstash data. */
unstash(name: 'git')
}
def removeDir(dir) {