This commit is contained in:
Dan Hawkins 2019-04-28 22:48:35 +01:00
commit 9ed80b4f79
5 changed files with 96 additions and 41 deletions

View file

@ -1,3 +1,27 @@
import hudson.FilePath
// Transfer file from intermediate position to final position;
// creating necessary folders on the way;
// deleting intermediate file
def copyToFinalPosition(String pathToIntermediate, String finalBaseFolder, String finalFilename) {
def channel = Jenkins.getInstance().getComputer(env['NODE_NAME']).getChannel()
def String abs_exports_root_path = "${WORKSPACE}/${finalBaseFolder}"
def String abs_export_out = "${abs_exports_root_path}/${finalFilename}"
def export_filepath = new hudson.FilePath(channel, abs_export_out)
def export_out_folder = export_filepath.getParent()
def export_out_folder_string = export_out_folder.toString()
def export_out_file = export_filepath.getName()
echo "Creating folder ${export_out_folder_string}"
export_out_folder.mkdirs()
echo "Copying from ${pathToIntermediate} to ${abs_export_out}"
def intermediate_filepath = new hudson.FilePath(channel, pathToIntermediate)
intermediate_filepath.copyTo(export_filepath)
intermediate_filepath.delete()
}
// Given details about artifacts to import and details of installers to build, import artifacts that are required
def Map artifactsImporter(meta, artifactDetails, installerDetails) {
artifactFetched = [:]
@ -14,22 +38,6 @@ def Map artifactsImporter(meta, artifactDetails, installerDetails) {
return artifactFetched
}
// Export any required binaries to the <WORKSPACE>/bin folder
def placeBinaries(artifactDetails, installerDetails) {
for (installer in toBuild) {
(installertool, artifactSet, targetFolder, executionPath, ISMprojectFile, installerVariant, exportBinaries) = installerDetails.get(installer)
if (exportBinaries) {
(sourceProject, sourceselector, destFolder, incrementversionnumber, toCopy, notToCopy, binariesFolders) = artifactDetails.get(artifactSet)
for (binaryFolder in binariesFolders) {
def binariesSourceFolder = "${destFolder}/${binaryFolder}"
def binariesDestFolder = "${WORKSPACE}/bin/${artifactSet}/${binaryFolder}"
echo "Copying from: ${binariesSourceFolder} to: ${binariesDestFolder}"
fileOperations([folderCopyOperation(destinationFolderPath: binariesDestFolder, sourceFolderPath: binariesSourceFolder)])
}
}
}
}
@NonCPS
def checkISMfilebackend(String xml) {
def String message = ""

View file

@ -233,6 +233,7 @@ class ReleaseInfo extends GISJsonSerialised {
}
void addReleaseItem(String releaseitem) {
script.echo("Adding release item: ${releaseitem} to release items")
releaseitems.add(releaseitem)
}

View file

@ -1,8 +1,23 @@
// The filepath must end in "<folder>/**" or "<folder>/" - Glob wildcard - as a git sparse checkout
def checkallowed(String filepath) {
if (filepath.endsWith('/**') || filepath.endsWith('/')) {
def files = findFiles glob: filepath
if (files.length > 0) {
return
} else {
error "There are no files/folders under the publishable item: ${filepath}"
}
}
error "The publishable item: ${filepath} does not end in <folder>/** or <folder>/ (for git sparse checkouts)"
}
// Generate a list of artifact files that are publishable to outside parties
def generatelist(meta, publishable) {
filelist = []
for (filepath in publishable) {
checkallowed(filepath)
meta.addPublishable(filepath)
}
}

View file

@ -61,7 +61,7 @@ def checkoutreleaserepo(buildmeta, String checkoutfolder) {
}
previousreleasemeta = getpreviousreleasemeta(buildmeta, checkoutfolder)
dir(checkoutfolder) {
// Clear all existing files
// Clear all existing files - Note that this does not remove .git*
sh("git rm -r *")
}
return previousreleasemeta
@ -189,7 +189,7 @@ def boolean releasegittag(String postcommitshacode, String tag) {
if (existingshacode) { // Tag exists
if (existingshacode != postcommitshacode) { // If the existing tag is not associated with HEAD
// This is a problem - The tag is already at another position in git repo
setunstable("The tag ${tag} has been used at another commit other than HEAD - You must decide what to do with it - Not good practice to delete it or move it")
setunstable("The release tag ${tag} has been used at another commit other than HEAD - You must decide what to do with it - Not good practice to delete it or move it")
summaryappend("(${tag} - Could not add!)")
} else {
summaryappend("(${tag} - Already added)")
@ -275,6 +275,22 @@ def sourcegitpush(String dryrunpush ) {
}
}
def boolean isalreadyreleased(buildmeta, tag) {
def boolean alreadyreleased = buildmeta.releaseinfo.released
if (alreadyreleased) {
echo "Component is already marked as released: ${alreadyreleased}"
} else {
String commitshacode = releasegitgetshacode(tag)
if (commitshacode) {
echo "Tag: ${tag} already exists in this repo therefore marking as already released"
alreadyreleased = true
} else {
alreadyreleased = false
}
}
return alreadyreleased
}
def gitrelease(buildmeta, previousreleasemeta, String releaserepo, String sourcerepo, String otherreleasetags, String dryrunpush) {
summaryappend(" Git operations: ")
def String buildstamptag = buildmeta.releasetag()
@ -283,8 +299,7 @@ def gitrelease(buildmeta, previousreleasemeta, String releaserepo, String source
def String precommitshacode = sh(script: "git rev-parse --verify HEAD", returnStdout: true).trim()
echo "Pre commit sha code: ${precommitshacode}"
def boolean alreadyreleased = buildmeta.releaseinfo.released
echo "Already released: ${alreadyreleased}"
def boolean alreadyreleased = isalreadyreleased(buildmeta, buildstamptag)
def String postcommitshacode
def boolean changed = false

View file

@ -75,7 +75,23 @@ def String checkouttoreporoot(String gitURL) {
return reporootsubfolder
}
def checkgitlfsinstall() {
if (isUnix()) {
sh """
git lfs install
if [ \$? -ne 0 ]; then exit 1; fi
"""
} else {
bat """
git lfs install
if errorlevel 1 EXIT /b 1
"""
}
}
def gitCheckout(String gitURL, String revision, String targetDir, String repoRootSuffix = "", int cloneDepth = 1, boolean shallowClone = true, ArrayList<String> sparseitemlist = new ArrayList<String>()) {
checkgitlfsinstall()
def reporootpath = checkouttoreporoot(gitURL)
checkout([
$class: 'GitSCM',
@ -99,33 +115,33 @@ def gitCheckout(String gitURL, String revision, String targetDir, String repoRoo
}
String getSHAFromVersion(String versionFolder) {
dir (versionFolder) {
dir (versionFolder) {
srcRevision = readFile("gitrevision.txt").trim()
}
return srcRevision
}
return srcRevision
}
boolean checkAllVersionsAgree(java.util.LinkedHashMap versions) {
def keys = versions.keySet()
if (keys.size() < 1) {
return false
}
if (keys.size() == 1) {
return true
}
if (keys.size() < 1) {
return false
}
if (keys.size() == 1) {
return true
}
else {
version = ""
for (key in keys) {
nextversion = versions.get(key)
if (version == "") {
version = nextversion
}
if (nextversion != version) {
return false
}
}
}
return true
version = ""
for (key in keys) {
nextversion = versions.get(key)
if (version == "") {
version = nextversion
}
if (nextversion != version) {
return false
}
}
}
return true
}
def stripgithistory(String rootfolder) {