diff --git a/configuration/configuration.groovy b/configuration/configuration.groovy index 1864ba9..b8c0b47 100644 --- a/configuration/configuration.groovy +++ b/configuration/configuration.groovy @@ -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 sparseitemlist = gh.convertSparseItemsString(filter) gh.gitCheckoutAlt(gitURL, revision, targetDir, repoRoot, cloneDepth, shallowClone) + registerConfigurationInfo(meta, tool, gitURL, revision, gh.getGitInfo(targetDir)) } diff --git a/install/installhelper.groovy b/install/installhelper.groovy index eebbd34..75ba5d6 100644 --- a/install/installhelper.groovy +++ b/install/installhelper.groovy @@ -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 diff --git a/versioncontrol/git.groovy b/versioncontrol/git.groovy index 3ea97ec..bb7c0ce 100644 --- a/versioncontrol/git.groovy +++ b/versioncontrol/git.groovy @@ -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') diff --git a/versionnumbering/generate.groovy b/versionnumbering/generate.groovy index f4f1bdc..2e4f60d 100644 --- a/versionnumbering/generate.groovy +++ b/versionnumbering/generate.groovy @@ -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()) {