Copy from Atlas Autobuild scripts as a starting point
This commit is contained in:
parent
b9a22c1989
commit
2d66e342df
92 changed files with 11897 additions and 0 deletions
117
Common_scripts/install/installhelper.groovy
Normal file
117
Common_scripts/install/installhelper.groovy
Normal file
|
|
@ -0,0 +1,117 @@
|
|||
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, importer, artifactDetails, installerDetails) {
|
||||
artifactFetched = [:]
|
||||
|
||||
def importoptions = importer.getNewImportOptions()
|
||||
for (installer in toBuild) {
|
||||
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) {
|
||||
importoptions.jenkinsjob(sourceProject, sourceselector)
|
||||
importoptions.setincrementversionnumber(incrementversionnumber)
|
||||
importoptions.setfilter(toCopy)
|
||||
importoptions.setexcludes(notToCopy)
|
||||
|
||||
def importmeta = importer.artifactimport(meta, importoptions, destFolder)
|
||||
artifactFetched.put(artifactKey, importmeta)
|
||||
}
|
||||
}
|
||||
}
|
||||
return artifactFetched
|
||||
}
|
||||
|
||||
@NonCPS
|
||||
def checkISMfilebackend(String xml) {
|
||||
def String message = ""
|
||||
|
||||
def parsedxml = new XmlParser(true, true, true).parseText(xml)
|
||||
def pathvariableinfo = [:]
|
||||
def exitcode = 0
|
||||
// Load up a map of path variable and path pairs
|
||||
// Ignore blank path definitions
|
||||
// Ignore the workspace definition which should have the only absolute path
|
||||
parsedxml.each{ table ->
|
||||
if (table.@name == "ISPathVariable") {
|
||||
table['row'].each{ row ->
|
||||
def pathname = row['td'][0].value()[0]
|
||||
def path = row['td'][1].value()[0]
|
||||
if (path && pathname != 'WORKSPACE') {
|
||||
pathvariableinfo[pathname] = path
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Check that each path variable is defined beginning with a path variable or the WORKSPACE one
|
||||
pathvariableinfo.each{ pair ->
|
||||
message += "pair key: ${pair.key} value: ${pair.value}\n"
|
||||
def path = pair.value
|
||||
def pathvarmatcher = path =~ /<(.*)>.*/
|
||||
if (pathvarmatcher.matches()) {
|
||||
def pathvarfound = pathvarmatcher.group(1)
|
||||
if (pathvarfound != 'WORKSPACE') {
|
||||
if (!pathvariableinfo.containsKey(pathvarfound)) {
|
||||
message += "Undefined path variable ${pathvarfound} found\n"
|
||||
exitcode = 1
|
||||
}
|
||||
}
|
||||
} else {
|
||||
message += "Path: ${path} does not begin with a path variable\n"
|
||||
exitcode = 1
|
||||
}
|
||||
}
|
||||
return [exitcode, message]
|
||||
}
|
||||
|
||||
def checkISMfile(String ISMfile) {
|
||||
echo "Checking ISM file: ${ISMfile}"
|
||||
def xml = readFile(ISMfile)
|
||||
(exitcode, message) = checkISMfilebackend(xml)
|
||||
echo message
|
||||
if (exitcode > 0) {
|
||||
error "ISM file errors found"
|
||||
} else {
|
||||
echo "Checked ISM file - ok"
|
||||
}
|
||||
}
|
||||
|
||||
certificatethumbprints = [:]
|
||||
certificatethumbprints['floreana'] = '0FDEB0A227982C877146CA595091173AC9655479' // Authoring takes place on this machine - so this is what should be in the ISM file already
|
||||
certificatethumbprints['hawaii'] = '49FD1B361CFF35014B81940C5B046543045DD34B'
|
||||
|
||||
def selectSigningCertificate(String nodeName, String ISMfile) {
|
||||
def masterpattern = '0FDEB0A227982C877146CA595091173AC9655479'
|
||||
echo "Substituting occurrences of ${masterpattern} with ${certificatethumbprints[nodeName]} in ISM file: ${ISMfile}"
|
||||
|
||||
textutils_subst = load("${autobuilder.commonscripts()}/textutils/subst.groovy")
|
||||
textutils_subst.substitute(ISMfile, masterpattern, certificatethumbprints[nodeName])
|
||||
}
|
||||
|
||||
return this;
|
||||
Loading…
Add table
Add a link
Reference in a new issue