This commit is contained in:
Dan Hawkins 2019-08-01 10:59:49 +01:00
commit 79966de50d
4 changed files with 36 additions and 7 deletions

View file

@ -8,8 +8,10 @@ def registerPipelineScriptConfiguration(meta) {
registerConfigurationInfo(meta, 'pipeline script', '-', '-', gh.getGitInfo("${autobuilder.getautobuildpath()}"))
}
def gitCheckoutAndRegister(meta, String tool, String gitURL, String revision, String targetDir, String repoRoot = "", int cloneDepth = 1, boolean shallowClone = true) {
def gitCheckoutAndRegister(meta, String tool, String gitURL, String revision, String targetDir, String repoRoot = "", int cloneDepth = 1, boolean shallowClone = true, String filter = '') {
def ArrayList<String> sparseitemlist = gh.convertSparseItemsString(filter)
gh.gitCheckoutAlt(gitURL, revision, targetDir, repoRoot, cloneDepth, shallowClone)
registerConfigurationInfo(meta, tool, gitURL, revision, gh.getGitInfo(targetDir))
}

View file

@ -28,11 +28,16 @@ def Map artifactsImporter(meta, artifactDetails, installerDetails) {
def importer = load("${autobuilder.commonscripts()}/import/importer.groovy")
for (installer in toBuild) {
def artifactKey = installerDetails.get(installer)[1]
(sourceProject, sourceselector, destFolder, incrementversionnumber, toCopy, notToCopy, binariesFolders) = artifactDetails.get(artifactKey)
if (artifactFetched.get(artifactKey) == null) {
def importmeta = importer.artifactimport(meta, sourceProject, sourceselector, destFolder, incrementversionnumber, toCopy, notToCopy)
artifactFetched.put(artifactKey, importmeta)
def artifactKeys = installerDetails.get(installer)[1]
if (artifactKeys instanceof java.lang.String) {
artifactKeys = [ artifactKeys ]
}
for (artifactKey in artifactKeys) {
(sourceProject, sourceselector, destFolder, incrementversionnumber, toCopy, notToCopy, binariesFolders) = artifactDetails.get(artifactKey)
if (artifactFetched.get(artifactKey) == null) {
def importmeta = importer.artifactimport(meta, sourceProject, sourceselector, destFolder, incrementversionnumber, toCopy, notToCopy)
artifactFetched.put(artifactKey, importmeta)
}
}
}
return artifactFetched

View file

@ -4,6 +4,21 @@ import hudson.plugins.git.extensions.impl.*
clh = load("${autobuilder.commonscripts()}/commandline/commandline.groovy")
def boolean isShallowClonedRepo(String gitrootpath) {
def boolean isshallowclone = true
dir( gitrootpath) {
if (isUnix()) {
isshallowclone = sh(returnStdout: true, script: "git rev-parse --is-shallow-repository").trim().toBoolean()
}
else {
isshallowclone = bat(returnStdout: true, script: "@git rev-parse --is-shallow-repository").trim().toBoolean()
}
echo "Repo at ${gitrootpath} is shallow cloned: ${isshallowclone}"
}
return isshallowclone
}
String getGitInfo(String workingSetRootPath) {
dir(workingSetRootPath) {
return clh.getCommandOutput('git rev-parse HEAD')

View file

@ -1,4 +1,5 @@
gh = load("${autobuilder.commonscripts()}/versioncontrol/git.groovy")
def int maxversionnumber() {
def int MAXVERSIONNUMBER = 65535
return MAXVERSIONNUMBER
@ -15,6 +16,12 @@ def getGitRevision(String gitrootpath, int basebuildnumber) {
def String gitrevision
def String remoteinfo
def String remoteurl
def boolean isShallowCloned = gh.isShallowClonedRepo(gitrootpath)
if (isShallowCloned) {
error("Cannot generate a version number from a shallow cloned repo at ${gitrootpath}")
}
dir( gitrootpath) {
def int changecount = 0
if (isUnix()) {