Rather than check out a release repo to see if it exists or not use git ls-remote to establish if it exists

This commit is contained in:
Dan Hawkins 2019-05-03 15:13:08 +01:00
commit d55d2a24c4
2 changed files with 23 additions and 1 deletions

View file

@ -4,7 +4,7 @@ vc = load("${autobuilder.commonscripts()}/versioncontrol/git.groovy")
// Prove the existence of the release repo - otherwise there is a large wait to cycle the build to correct the meta data
def registerrepo(meta, String releaserepo, String repoRootSuffix = "") {
if (releaserepo?.trim()) {
vc.gitCheckout(releaserepo, "origin/master", "tmp/releaserepo", repoRootSuffix)
vc.checkRepoExists(releaserepo)
}
meta.releaseinfo.set(releaserepo)
}

View file

@ -114,6 +114,28 @@ def gitCheckout(String gitURL, String revision, String targetDir, String repoRoo
])
}
def checkRepoExists(String gitURL) {
def boolean result = false
if (isUnix()) {
result = sh( script: """
git ls-remote "${gitURL}" CHECK_GIT_REMOTE_URL_REACHABILITY
if [ \$? -ne 0 ]; then exit 1; fi
""",
returnStatus: true
)
} else {
result = bash( script: """
git ls-remote "${gitURL}" CHECK_GIT_REMOTE_URL_REACHABILITY
if errorlevel 1 EXIT /b 1
""",
returnStatus: true
)
}
if (!result) {
error("The release repo: ${gitURL} cannot be found. Please ensure this exists before building")
}
}
String getSHAFromVersion(String versionFolder) {
dir (versionFolder) {
srcRevision = readFile("gitrevision.txt").trim()