This commit is contained in:
Dan Hawkins 2018-10-26 16:57:06 +01:00
commit 4c9178afdc
3 changed files with 65 additions and 10 deletions

View file

@ -1,7 +0,0 @@
// Methods in this file will end up as object methods on the object that load returns.
def lookAtThis(String whoAreYou) {
echo "Look at this, ${whoAreYou}! You loaded this from another file!"
}
return this;

View file

@ -0,0 +1,56 @@
// Each version folder should have been created using version creation scripts in this Common_scripts folder
// as their are well-known files in each folder
def combineSubjobVersions(versionLabelPrefix, versionFolderList, outputFolder = "${WORKSPACE}/metaversion") {
env.VLP = versionLabelPrefix
env.OF = outputFolder
totalrevision = 0
if (isUnix()) {
sh """#!/bin/bash
rm -rf "${OF}"
mkdir -p "${OF}"
if [ \$? -ne 0 ]; then exit 1; fi
touch "${OF}/differences.txt"
if [ \$? -ne 0 ]; then exit 1; fi
touch "${OF}/buildstamps.txt"
if [ \$? -ne 0 ]; then exit 1; fi
"""
}
else {
error "combineSubjobVersions script is not supported in Windows yet"
}
for (versionFolder in versionFolderList) {
env.differencesFile = "${versionFolder}/differences.txt"
sh """#!/bin/bash
echo ${differencesFile}: >> "${OF}/differences.txt"
if [ \$? -ne 0 ]; then exit 1; fi
cat "${differencesFile}" >> "${OF}/differences.txt"
if [ \$? -ne 0 ]; then exit 1; fi
"""
buildStampFile = "${versionFolder}/buildstamp.txt"
buildStampFileContents = readFile "${buildStampFile}"
metabuildStampFile = "${OF}/buildstamps.txt"
metabuildStampFileContents = readFile "${metabuildStampFile}"
writeFile file: "${metabuildStampFile}", text: metabuildStampFileContents + "\r\n" + "${versionFolder}" + ": " + buildStampFileContents
revision = readFile("${versionFolder}/revision.txt").trim()
intrevision = revision.toInteger()
echo "Revision read in: ${intrevision}"
totalrevision += intrevision
echo "Accumulated revision is: ${totalrevision}"
}
if (versionLabelPrefix.endsWith(".")) {
writeFile file: "${OF}/metaversion.txt", text: versionLabelPrefix + totalrevision
}
else {
writeFile file: "${OF}/metaversion.txt", text: versionLabelPrefix + "." + totalrevision
}
}
return this;

View file

@ -12,6 +12,7 @@ import os
import sys
import shutil
import subprocess
import re
from argparse import ArgumentParser
from argparse import RawDescriptionHelpFormatter
@ -81,13 +82,18 @@ def getVersionPrefix(sourcebranch):
sourcebranch = splits[-1]
if sourcebranch.lower().endswith("master"): # Special case
if sourcebranch.lower().find("master") != -1: # Special case
return mastertypeversionprefix
splits = sourcebranch.split('.')
splits2 = re.split(r'(\d+)', sourcebranch)
splits = []
for split in splits2:
if split.isdigit():
splits.append(split)
versionprefix = ""
if len(splits) < 1:
print("This source branch name has no decimal points in its name so defaulting to: {0}".format(defaultversionprefix))
print("This source branch name has no numbers in its name so defaulting to: {0}".format(defaultversionprefix))
versionprefix = defaultversionprefix
else:
splitnumbercount = 0