diff --git a/release/registerrepo.groovy b/release/registerrepo.groovy index 2dffdc7..bd6a528 100644 --- a/release/registerrepo.groovy +++ b/release/registerrepo.groovy @@ -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) } diff --git a/versioncontrol/git.groovy b/versioncontrol/git.groovy index b386a9a..b639c91 100644 --- a/versioncontrol/git.groovy +++ b/versioncontrol/git.groovy @@ -114,6 +114,29 @@ def gitCheckout(String gitURL, String revision, String targetDir, String repoRoo ]) } +def checkRepoExists(String gitURL) { + def int result = 0 + if (isUnix()) { + result = sh( script: """ + git ls-remote "${gitURL}" CHECK_GIT_REMOTE_URL_REACHABILITY + """, + returnStatus: true + ) + } else { + result = bat( script: """ + @git ls-remote "${gitURL}" CHECK_GIT_REMOTE_URL_REACHABILITY + """, + returnStatus: true + ) + } + echo "git ls-remote return result: ${result}" + if (result > 0) { + error("The release repo: ${gitURL} cannot be found. Please ensure this exists before building") + } else { + echo "The release repo: ${gitURL} exists" + } +} + String getSHAFromVersion(String versionFolder) { dir (versionFolder) { srcRevision = readFile("gitrevision.txt").trim() @@ -147,13 +170,17 @@ boolean checkAllVersionsAgree(java.util.LinkedHashMap versions) { def stripgithistory(String rootfolder) { echo "Stripping git history out of ${rootfolder}" dir(rootfolder) { - sh """#!/bin/bash - pwd - find . -type d -name ".git" | xargs -iXX rm -rf XX - find . -name ".gitignore" | xargs -iXX rm -rf XX - find . -name ".gitmodules" | xargs -iXX rm -rf XX - find . -iname ".gitattributes" | xargs -iXX rm -rf XX - """ + if (isUnix()) { + sh """#!/bin/bash + pwd + find . -type d -name ".git" | xargs -iXX rm -rf XX + find . -name ".gitignore" | xargs -iXX rm -rf XX + find . -name ".gitmodules" | xargs -iXX rm -rf XX + find . -iname ".gitattributes" | xargs -iXX rm -rf XX + """ + } else { + echo "Not supporting git stripping in Windows at the moment" + } } }