From d55d2a24c4ea87e35a3ebae26f402807f7b10819 Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Fri, 3 May 2019 15:13:08 +0100 Subject: [PATCH 1/7] Rather than check out a release repo to see if it exists or not use git ls-remote to establish if it exists --- release/registerrepo.groovy | 2 +- versioncontrol/git.groovy | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) 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..96fa571 100644 --- a/versioncontrol/git.groovy +++ b/versioncontrol/git.groovy @@ -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() From c13ba0d6289bd14c0a76198ca7125cfa859b3328 Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Fri, 3 May 2019 15:15:34 +0100 Subject: [PATCH 2/7] Rather than check out a release repo to see if it exists or not use git ls-remote to establish if it exists --- versioncontrol/git.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/versioncontrol/git.groovy b/versioncontrol/git.groovy index 96fa571..cea31fc 100644 --- a/versioncontrol/git.groovy +++ b/versioncontrol/git.groovy @@ -124,7 +124,7 @@ def checkRepoExists(String gitURL) { returnStatus: true ) } else { - result = bash( script: """ + result = bat( script: """ git ls-remote "${gitURL}" CHECK_GIT_REMOTE_URL_REACHABILITY if errorlevel 1 EXIT /b 1 """, From 9af654fb28e93396c128a571be4ab365fbd2bd45 Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Fri, 3 May 2019 15:20:36 +0100 Subject: [PATCH 3/7] Rather than check out a release repo to see if it exists or not use git ls-remote to establish if it exists --- versioncontrol/git.groovy | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/versioncontrol/git.groovy b/versioncontrol/git.groovy index cea31fc..36f4c64 100644 --- a/versioncontrol/git.groovy +++ b/versioncontrol/git.groovy @@ -119,14 +119,12 @@ def checkRepoExists(String gitURL) { 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 = bat( script: """ - git ls-remote "${gitURL}" CHECK_GIT_REMOTE_URL_REACHABILITY - if errorlevel 1 EXIT /b 1 + @git ls-remote "${gitURL}" CHECK_GIT_REMOTE_URL_REACHABILITY """, returnStatus: true ) From a42acef027fd7fb3b8c4b47c9fb470584a27b75b Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Fri, 3 May 2019 15:26:22 +0100 Subject: [PATCH 4/7] Rather than check out a release repo to see if it exists or not use git ls-remote to establish if it exists --- versioncontrol/git.groovy | 1 + 1 file changed, 1 insertion(+) diff --git a/versioncontrol/git.groovy b/versioncontrol/git.groovy index 36f4c64..12d5bc6 100644 --- a/versioncontrol/git.groovy +++ b/versioncontrol/git.groovy @@ -130,6 +130,7 @@ def checkRepoExists(String gitURL) { ) } if (!result) { + echo "git ls-remote return result: ${result}" error("The release repo: ${gitURL} cannot be found. Please ensure this exists before building") } } From 7a62550a07890fc69f415e36dcaf5c4f22627dd8 Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Fri, 3 May 2019 15:29:15 +0100 Subject: [PATCH 5/7] Rather than check out a release repo to see if it exists or not use git ls-remote to establish if it exists --- versioncontrol/git.groovy | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/versioncontrol/git.groovy b/versioncontrol/git.groovy index 12d5bc6..ee7e99a 100644 --- a/versioncontrol/git.groovy +++ b/versioncontrol/git.groovy @@ -115,7 +115,7 @@ def gitCheckout(String gitURL, String revision, String targetDir, String repoRoo } def checkRepoExists(String gitURL) { - def boolean result = false + def int result = 0 if (isUnix()) { result = sh( script: """ git ls-remote "${gitURL}" CHECK_GIT_REMOTE_URL_REACHABILITY @@ -129,7 +129,7 @@ def checkRepoExists(String gitURL) { returnStatus: true ) } - if (!result) { + if (result > 0) { echo "git ls-remote return result: ${result}" error("The release repo: ${gitURL} cannot be found. Please ensure this exists before building") } From 0216685c99d3ce9c564a6c88fc61fd1f8bb99c22 Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Fri, 3 May 2019 15:31:49 +0100 Subject: [PATCH 6/7] Rather than check out a release repo to see if it exists or not use git ls-remote to establish if it exists --- versioncontrol/git.groovy | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/versioncontrol/git.groovy b/versioncontrol/git.groovy index ee7e99a..f72fc5a 100644 --- a/versioncontrol/git.groovy +++ b/versioncontrol/git.groovy @@ -129,9 +129,11 @@ def checkRepoExists(String gitURL) { returnStatus: true ) } + echo "git ls-remote return result: ${result}" if (result > 0) { - echo "git ls-remote return result: ${result}" error("The release repo: ${gitURL} cannot be found. Please ensure this exists before building") + } else { + echo "The release repo: ${gitURL} exists" } } From 55a2e2a03444ed9e942316f3785667ba4f338375 Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Tue, 7 May 2019 10:28:39 +0100 Subject: [PATCH 7/7] Warn of git stripping not being supported in Windows --- versioncontrol/git.groovy | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/versioncontrol/git.groovy b/versioncontrol/git.groovy index f72fc5a..b639c91 100644 --- a/versioncontrol/git.groovy +++ b/versioncontrol/git.groovy @@ -170,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" + } } }