Jenkins: Fall back to stashed data if the node can't reach github
This commit is contained in:
29
.ci/Jenkinsfile
vendored
29
.ci/Jenkinsfile
vendored
@@ -98,15 +98,18 @@ def gitClone(repository, branch) {
|
|||||||
/* Clean workspace. */
|
/* Clean workspace. */
|
||||||
cleanWs()
|
cleanWs()
|
||||||
|
|
||||||
/* Use stashes to pass the repository around debian.citadel, as it's known to be faster than git clone there. */
|
/* Perform git clone if stashed data isn't available yet, or if
|
||||||
if (env.NODE_NAME != 'debian.citadel' || env.GIT_STASHED != 'true') {
|
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
|
/* Perform clone/checkout, making sure to update the changelog only once
|
||||||
to avoid inaccurate entries from new commits pushed inbetween clones. */
|
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',
|
changelog: env.GIT_STASHED != 'true',
|
||||||
scm: [$class: 'GitSCM',
|
scm: [$class: 'GitSCM',
|
||||||
branches: [[name: branch]],
|
branches: [[name: branch]],
|
||||||
userRemoteConfigs: [[url: repository]]]
|
userRemoteConfigs: [[url: repository]]])
|
||||||
|
|
||||||
if (env.GIT_COMMIT == null) {
|
if (env.GIT_COMMIT == null) {
|
||||||
/* Save the current HEAD commit. */
|
/* Save the current HEAD commit. */
|
||||||
@@ -120,15 +123,23 @@ def gitClone(repository, branch) {
|
|||||||
}
|
}
|
||||||
println "[-] Using git commit [${env.GIT_COMMIT}]"
|
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') {
|
if (env.GIT_STASHED != 'true') {
|
||||||
stash name: 'git', useDefaultExcludes: false
|
stash(name: 'git', useDefaultExcludes: false)
|
||||||
env.GIT_STASHED = 'true'
|
env.GIT_STASHED = 'true'
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
/* Unstash data. */
|
/* No need to use stashed data. */
|
||||||
unstash name: 'git'
|
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) {
|
def removeDir(dir) {
|
||||||
|
Reference in New Issue
Block a user