Merge commit '1b74ea88ff' as 'Common_scripts'
This commit is contained in:
commit
a838c2fc30
64 changed files with 7397 additions and 0 deletions
17
Common_scripts/.project
Normal file
17
Common_scripts/.project
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>Common Build Scripts</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.python.pydev.PyDevBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.python.pydev.pythonNature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
8
Common_scripts/.pydevproject
Normal file
8
Common_scripts/.pydevproject
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<?eclipse-pydev version="1.0"?><pydev_project>
|
||||
<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
|
||||
<path>/${PROJECT_DIR_NAME}</path>
|
||||
</pydev_pathproperty>
|
||||
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.7</pydev_property>
|
||||
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">python35</pydev_property>
|
||||
</pydev_project>
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
eclipse.preferences.version=1
|
||||
encoding//versionnumbering/versioninfo.py=utf-8
|
||||
17
Common_scripts/artifacts/archiver.groovy
Normal file
17
Common_scripts/artifacts/archiver.groovy
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
enum Store {
|
||||
JENKINS,
|
||||
ARTIFACTSERVER,
|
||||
}
|
||||
|
||||
this.JENKINS = Store.JENKINS
|
||||
this.ARTIFACTSERVER = Store.JENKINS
|
||||
|
||||
def archive(MetaInfo meta, String artifactlist, Store store = JENKINS) {
|
||||
echo "Archiving artifacts to store: ${store}"
|
||||
meta.copyrelatedmeta()
|
||||
if (store == JENKINS) {
|
||||
archiveArtifacts(artifacts: artifactlist)
|
||||
}
|
||||
}
|
||||
|
||||
return this
|
||||
26
Common_scripts/artifacts/metaexport.groovy
Normal file
26
Common_scripts/artifacts/metaexport.groovy
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
// Take a list of Sub-job descriptors and output folder pairs, copy the artifacts, while filling in a string of artifact folders
|
||||
def combineSubjobArtifacts(meta, importer, subJobs) {
|
||||
def ArrayList<String> artifactFolders = new ArrayList<String>()
|
||||
for (subJob in subJobs) {
|
||||
def subJobObject = subJob[0]
|
||||
if (subJobObject != null) {
|
||||
def subJobName = subJobObject.getProjectName()
|
||||
def subJobNumber = subJobObject.getNumber()
|
||||
def destFolder = subJob[1]
|
||||
def boolean incrementversionnumber = subJob[2]
|
||||
dir(destFolder) {
|
||||
deleteDir()
|
||||
}
|
||||
|
||||
def importoptions = importer.getNewImportOptions()
|
||||
importoptions.jenkinsjob(subJobName, subJobNumber)
|
||||
importoptions.setincrementversionnumber(incrementversionnumber)
|
||||
importer.artifactimport(meta, importoptions, destFolder)
|
||||
|
||||
artifactFolders.add("${destFolder}/**")
|
||||
}
|
||||
}
|
||||
return artifactFolders
|
||||
}
|
||||
|
||||
return this;
|
||||
147
Common_scripts/autobuilder.groovy
Normal file
147
Common_scripts/autobuilder.groovy
Normal file
|
|
@ -0,0 +1,147 @@
|
|||
// Assume that WORKSPACE environment variable is set
|
||||
|
||||
autobuildroot = 'autobuild'
|
||||
commonscriptsroot = "${autobuildroot}/Common_scripts"
|
||||
metafolderscript = null
|
||||
|
||||
def conditionalclean(doclean = "${CLEAN_WORKSPACE}" == "true") {
|
||||
if (doclean) {
|
||||
echo "Cleaning workspace"
|
||||
// Save any script files that were loaded into the workspace at first and are required after cleaning the workspace
|
||||
def stashname = 'Clean workspace stash'
|
||||
stash(allowEmpty: true,
|
||||
includes: "${autobuildroot}/**,${autobuildroot}/.git/**",
|
||||
name: stashname,
|
||||
useDefaultExcludes: false
|
||||
)
|
||||
cleanWs()
|
||||
unstash name: stashname
|
||||
}
|
||||
else {
|
||||
echo "Not cleaning workspace"
|
||||
}
|
||||
}
|
||||
|
||||
def commonscripts() {
|
||||
return commonscriptsroot
|
||||
}
|
||||
|
||||
def getautobuildpath() {
|
||||
return autobuildroot
|
||||
}
|
||||
|
||||
def getmetafolderscript() {
|
||||
return metafolderscript
|
||||
}
|
||||
|
||||
def alterreleaserepo(String releaserepo, String releaserepovariantsuffix) {
|
||||
def String altered = releaserepo.trim()
|
||||
|
||||
if (releaserepovariantsuffix?.trim()) {
|
||||
altered = altered.replace("-RELEASE_REPO_VARIANT_SUFFIX-", releaserepovariantsuffix)
|
||||
}
|
||||
return altered
|
||||
}
|
||||
|
||||
def setBuildType(meta, boolean dofullbuild = true) {
|
||||
def doquickbuild = false
|
||||
|
||||
echo "Build trigger cause: ${currentBuild.getBuildCauses()}"
|
||||
if (currentBuild.getBuildCauses('hudson.model.Cause$UserIdCause')) {
|
||||
echo "Build triggered by user"
|
||||
if (!dofullbuild) {
|
||||
echo "Marking as quick build as user wanted one"
|
||||
doquickbuild = true
|
||||
}
|
||||
} else {
|
||||
echo "Build triggered automatically"
|
||||
if (currentBuild.getBuildCauses('jenkins.branch.BranchEventCause') || currentBuild.getBuildCauses('hudson.triggers.SCMTrigger$SCMTriggerCause')) {
|
||||
echo "Marking as quick build as it was triggered by a commit"
|
||||
doquickbuild = true
|
||||
} else if (currentBuild.getBuildCauses('hudson.triggers.TimerTrigger$TimerTriggerCause')) {
|
||||
echo "Marking as full build as it was triggered by timer"
|
||||
}
|
||||
}
|
||||
echo "Build type is ${doquickbuild ? "quick" : "full"}"
|
||||
if (doquickbuild) {
|
||||
unstable('This not a full build - a subset of the artifacts is not being generated')
|
||||
}
|
||||
meta.jenkinsbuildinfo.set(!doquickbuild)
|
||||
return doquickbuild
|
||||
}
|
||||
|
||||
def setupmeta(script, String productname, String subcomponentname, String productvariant = '') {
|
||||
def meta = getmetafolderscript().metareset(script)
|
||||
echo "Product name: ${productname} Subcomponent name: ${subcomponentname} Variant: ${productvariant}"
|
||||
meta.productinfo.set(productname, subcomponentname, productvariant)
|
||||
def now = new Date()
|
||||
now.format("yyMMdd.HHmm", TimeZone.getTimeZone('UTC'))
|
||||
meta.jenkinsbuildinfo.set(JOB_NAME, BUILD_ID.toInteger(), NODE_NAME, now.toString())
|
||||
for (p in params) {
|
||||
meta.jenkinsbuildinfo.addParameter(p.key, p.value)
|
||||
}
|
||||
return meta
|
||||
}
|
||||
|
||||
// Start up boilerplate
|
||||
def startbuild(
|
||||
script,
|
||||
String productname = PRODUCT_NAME,
|
||||
String subcomponentname = SUBCOMPONENT_NAME,
|
||||
String releaserepo = RELEASE_REPO,
|
||||
String productvariant = '',
|
||||
String autobuildpath = autobuildroot,
|
||||
String commonscriptspath = commonscriptsroot
|
||||
) {
|
||||
echo "Starting...."
|
||||
|
||||
autobuildroot = autobuildpath
|
||||
commonscriptsroot = commonscriptspath
|
||||
metafolderscript = load("${commonscripts()}/meta/folder.groovy")
|
||||
|
||||
conditionalclean()
|
||||
|
||||
def meta = setupmeta(script, productname, subcomponentname, productvariant)
|
||||
|
||||
def rr = load("${commonscripts()}/release/registerrepo.groovy")
|
||||
def String alteredreleaserepo = alterreleaserepo(releaserepo, productvariant)
|
||||
|
||||
echo "Release repo: ${alteredreleaserepo}"
|
||||
rr.registerrepo(meta, alteredreleaserepo)
|
||||
|
||||
def ch = load("${commonscripts()}/configuration/configuration.groovy")
|
||||
ch.registerPipelineScriptConfiguration(meta)
|
||||
|
||||
return meta
|
||||
}
|
||||
|
||||
// Start up boilerplate
|
||||
def startnonbuild(
|
||||
script,
|
||||
autobuildpath = autobuildroot,
|
||||
commonscriptspath = commonscriptsroot
|
||||
) {
|
||||
echo "Starting non-build job...."
|
||||
|
||||
autobuildroot = autobuildpath
|
||||
commonscriptsroot = commonscriptspath
|
||||
metafolderscript = load("${commonscripts()}/meta/folder.groovy")
|
||||
|
||||
conditionalclean()
|
||||
|
||||
def meta = setupmeta(script, "Non-build-product", "Non-build-subcomponent")
|
||||
|
||||
def ch = load("${commonscripts()}/configuration/configuration.groovy")
|
||||
ch.registerPipelineScriptConfiguration(meta)
|
||||
|
||||
return meta
|
||||
}
|
||||
|
||||
def configurationhelper() {
|
||||
return load("${commonscripts()}/configuration/configuration.groovy")
|
||||
}
|
||||
|
||||
// Everyone wants to know this
|
||||
autobuilder = this
|
||||
|
||||
return this;
|
||||
113
Common_scripts/build/integrity.groovy
Normal file
113
Common_scripts/build/integrity.groovy
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
import static groovy.json.JsonOutput.*
|
||||
|
||||
def check(buildmeta) {
|
||||
def results = [
|
||||
'good': true,
|
||||
'comment': '',
|
||||
]
|
||||
|
||||
// Walk the meta looking for different versions of the same components
|
||||
def allmeta = buildmeta.allrelatedmeta()
|
||||
echo "All meta:\n${allmeta.comment}"
|
||||
|
||||
// Store build stamps associated with each product component; Store a counter against each product component version
|
||||
def productcomponents = [:]
|
||||
for (meta in allmeta.metacollection) {
|
||||
def key = meta.componentidentifier()
|
||||
|
||||
if (!productcomponents.containsKey(key)) {
|
||||
productcomponents[key] = [:]
|
||||
}
|
||||
def buildstampnumber = meta.releasetag()
|
||||
if (!productcomponents[key].containsKey(buildstampnumber)) {
|
||||
productcomponents[key][buildstampnumber] = 1
|
||||
} else {
|
||||
productcomponents[key][buildstampnumber] += 1
|
||||
}
|
||||
}
|
||||
|
||||
// Show what was collected
|
||||
echo prettyPrint(toJson(productcomponents))
|
||||
|
||||
// Look for product components with more than one build stamp
|
||||
for (pc in productcomponents.keySet()) {
|
||||
def bsns = productcomponents[pc]
|
||||
if (bsns.size() > 1) {
|
||||
results.good = false
|
||||
results.comment += "There is more than one version of Product component: ${pc} being used in this build:\n"
|
||||
for (bsn in bsns.keySet()) {
|
||||
results.comment += "${bsn}\n"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Store product components associated with each release git url
|
||||
def releasegiturls = [:]
|
||||
for (meta in allmeta.metacollection) {
|
||||
def String key = meta.releaseinfo.releaserepoURL
|
||||
|
||||
if (key) {
|
||||
if (!releasegiturls.containsKey(key)) {
|
||||
releasegiturls[key] = [:]
|
||||
}
|
||||
def componentidentifier = meta.componentidentifier()
|
||||
if (!releasegiturls[key].containsKey(componentidentifier)) {
|
||||
releasegiturls[key][componentidentifier] = 1
|
||||
} else {
|
||||
releasegiturls[key][componentidentifier] += 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Show what was collected
|
||||
echo prettyPrint(toJson(releasegiturls))
|
||||
|
||||
// Look for release git urls being used by more than one product component
|
||||
for (rgu in releasegiturls.keySet()) {
|
||||
def cis = releasegiturls[rgu]
|
||||
if (cis.size() > 1) {
|
||||
results.good = false
|
||||
results.comment += "There is more than one product component associated with a release git url: ${rgu} being used in this build:\n"
|
||||
for (ci in cis.keySet()) {
|
||||
results.comment += "${ci}\n"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Store git commit shas associated with each source git url
|
||||
def sourcegiturls = [:]
|
||||
for (meta in allmeta.metacollection) {
|
||||
def String key = meta.gitinfo.remoteurl
|
||||
|
||||
if (key) {
|
||||
if (!sourcegiturls.containsKey(key)) {
|
||||
sourcegiturls[key] = [:]
|
||||
}
|
||||
def commitsha = meta.gitinfo.gitrevision
|
||||
if (!sourcegiturls[key].containsKey(commitsha)) {
|
||||
sourcegiturls[key][commitsha] = 1
|
||||
} else {
|
||||
sourcegiturls[key][commitsha] += 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Show what was collected
|
||||
echo prettyPrint(toJson(sourcegiturls))
|
||||
|
||||
// Look for source git urls associated with more than one sha code
|
||||
for (sgu in sourcegiturls.keySet()) {
|
||||
def cs = sourcegiturls[sgu]
|
||||
if (cs.size() > 1) {
|
||||
results.good = false
|
||||
results.comment += "There is more than one source commit sha associated with a source git url: ${sgu} being used in this build:\n"
|
||||
for (c in cs.keySet()) {
|
||||
results.comment += "${c}\n"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return results
|
||||
}
|
||||
|
||||
return this
|
||||
225
Common_scripts/build/postactions.groovy
Normal file
225
Common_scripts/build/postactions.groovy
Normal file
|
|
@ -0,0 +1,225 @@
|
|||
/* Example post build info
|
||||
{
|
||||
"Build outcomes": {
|
||||
"Success": {
|
||||
"Actions": {
|
||||
"Deploy documentation": {
|
||||
"Description": "Can be empty - Name of documentation/doxygen deploy job to run if this build is successful",
|
||||
"Job": "HMB_FD_HV_0.9.6/HMB_FD_HV_0.9.6_sg1024_doxygen_deploy"
|
||||
},
|
||||
"Static analysis": {
|
||||
"Description": "Can be empty - Static analysis job to run when this build is successful",
|
||||
"Job": ""
|
||||
},
|
||||
"Unit test": {
|
||||
"Description": "Can be empty - Unit test job to run when this build is successful",
|
||||
"Job": ""
|
||||
},
|
||||
"Regression test": {
|
||||
"Description": "Can be empty - Regression test job to run when this build is successful",
|
||||
"Job": "HMB_FD_HV_0.9.6/HMB_FD_HV_0.9.6_sg1024_run_tests"
|
||||
},
|
||||
"Update differences": {
|
||||
"Description": "Can be empty - Update differences job to run when this build is successful",
|
||||
"Job": "HMB_FD_HV_diff_releases"
|
||||
},
|
||||
"Release to git": {
|
||||
"Description": "Can be empty - Name of release to git job to run if this build is successful",
|
||||
"Job": "HMB_FD_HV_release_to_git"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Failed": {
|
||||
"Actions": {
|
||||
"Email": {
|
||||
"Description": "Can be empty - Name of release to git job to run if this build is successful",
|
||||
"To": [
|
||||
"dan.hawkins@globalinkjetsystems.com"
|
||||
]
|
||||
},
|
||||
"ExtEmail": {
|
||||
"Description": "Send an email using Extended Email plugin",
|
||||
"To": [
|
||||
"dan.hawkins@globalinkjetsystems.com"
|
||||
],
|
||||
"Recipient providers": [
|
||||
"culprits",
|
||||
"requestor",
|
||||
"developers",
|
||||
"upstreamDevelopers"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
def getActionJobName(postbuildactions, String action, String alternativeparamname) {
|
||||
def String jobname = ''
|
||||
if (postbuildactions) {
|
||||
try {
|
||||
jobname = postbuildactions[action]['Job']
|
||||
} catch(Exception ex) {
|
||||
echo "No post build actions found for action: ${action}"
|
||||
jobname = ''
|
||||
}
|
||||
} else {
|
||||
if (params[alternativeparamname] != null) {
|
||||
if (params[alternativeparamname]) {
|
||||
jobname = params[alternativeparamname]
|
||||
}
|
||||
}
|
||||
}
|
||||
if (jobname) {
|
||||
def jobitem = Jenkins.instance.getItemByFullName(jobname)
|
||||
if (jobitem) {
|
||||
if (!jobitem.isBuildable()) {
|
||||
jobname = ''
|
||||
}
|
||||
} else {
|
||||
jobname = ''
|
||||
}
|
||||
}
|
||||
// echo "Job name for action: ${action}: ${jobname}"
|
||||
return jobname
|
||||
}
|
||||
|
||||
def deployjob(String buildselector, postbuildactions, String action, String alternativeparamname, String jobnameparametername, String jobselectorparametername) {
|
||||
def jobname = getActionJobName(postbuildactions, action, alternativeparamname)
|
||||
if (jobname) {
|
||||
build(
|
||||
wait: false,
|
||||
job: jobname,
|
||||
parameters: [
|
||||
string(name: jobnameparametername, value: JOB_NAME),
|
||||
string(name: jobselectorparametername, value: buildselector),
|
||||
]
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
def readPostBuildInfo() {
|
||||
def postbuildinfo = readJSON(text: POST_BUILD_INFO)
|
||||
def postbuildjsontext = writeJSON(returnText: true, json: postbuildinfo, pretty: 1)
|
||||
// echo "Post build info:\n${postbuildjsontext}"
|
||||
|
||||
return postbuildinfo
|
||||
}
|
||||
|
||||
def performSuccessfulBuildActions() {
|
||||
def postbuildactions
|
||||
if (params.POST_BUILD_INFO != null) {
|
||||
def postbuildinfo = readPostBuildInfo()
|
||||
try {
|
||||
postbuildactions = postbuildinfo['Build outcomes']['Success']['Actions']
|
||||
} catch(Exception ex) {
|
||||
echo "Post build info did not contain: Build outcomes/Success/Actions"
|
||||
postbuildactions = null
|
||||
}
|
||||
}
|
||||
def String buildselector = "<SpecificBuildSelector plugin='copyartifact@1.46.2'><buildNumber>${BUILD_NUMBER}</buildNumber></SpecificBuildSelector>"
|
||||
deployjob(buildselector, postbuildactions, 'Deploy documentation', 'DOXYGEN_DEPLOY_JOB', 'BUILD_JOB_WITH_DOXYGEN_ARTIFACTS', 'BUILD_JOB_WITH_DOXYGEN_ARTIFACTS_SELECTOR')
|
||||
deployjob(buildselector, postbuildactions, 'Static analysis', 'STATIC_ANALYSIS_JOB', 'BUILD_JOB_TO_ANALYSE', 'BUILD_JOB_TO_ANALYSE_SELECTOR' )
|
||||
deployjob(buildselector, postbuildactions, 'Unit test', 'UNIT_TEST_JOB', 'BUILD_JOB_TO_TEST', 'BUILD_JOB_TO_TEST_SELECTOR')
|
||||
deployjob(buildselector, postbuildactions, 'Regression test', 'REGRESSION_TEST_JOB', 'BUILD_JOB_TO_TEST', 'BUILD_JOB_TO_TEST_SELECTOR')
|
||||
deployjob(buildselector, postbuildactions, 'Update differences', 'DIFF_JOB', 'LATER_BUILD_JOB', 'LATER_BUILD_SELECTOR')
|
||||
deployjob(buildselector, postbuildactions, 'Release to git', 'RELEASE_TO_GIT_JOB', 'BUILD_JOB', 'BUILD_JOB_SELECTOR')
|
||||
}
|
||||
|
||||
def sendemails(emailinfo) {
|
||||
def emailtolist = emailinfo['To']
|
||||
|
||||
if (emailtolist) {
|
||||
def emailbody = """
|
||||
Failed build: ${JOB_NAME} ${BUILD_DISPLAY_NAME} : ${BUILD_URL}
|
||||
|
||||
Console output: ${BUILD_URL}console
|
||||
"""
|
||||
for(emailto in emailtolist) {
|
||||
mail(
|
||||
subject: "[Jenkins] Failed build: ${JOB_NAME} ${BUILD_DISPLAY_NAME}",
|
||||
body: emailbody,
|
||||
to: emailto
|
||||
)
|
||||
// echo "Send email to: ${emailto}"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def getRecipientProviders(recipientProviderInfoList) {
|
||||
def recipientProviderMap = [
|
||||
culprits: [$class: 'CulpritsRecipientProvider'],
|
||||
requestor: [$class: 'RequesterRecipientProvider'],
|
||||
developers: [$class: 'DevelopersRecipientProvider'],
|
||||
upstreamDevelopers: [$class: 'UpstreamComitterRecipientProvider'],
|
||||
]
|
||||
def recipientProviders = []
|
||||
|
||||
if (recipientProviderInfoList) {
|
||||
for(rp in recipientProviderInfoList) {
|
||||
if (recipientProviderMap.containsKey(rp)) {
|
||||
recipientProviders.add(recipientProviderMap[rp])
|
||||
}
|
||||
}
|
||||
}
|
||||
if (recipientProviders.size() == 0) {
|
||||
recipientProviders = [culprits(), requestor(), developers(), upstreamDevelopers()]
|
||||
}
|
||||
// echo "recipientProviders: ${recipientProviders.toString()}"
|
||||
return recipientProviders;
|
||||
}
|
||||
|
||||
def String getToList(toListInfo) {
|
||||
def String toList = ''
|
||||
|
||||
if (toListInfo) {
|
||||
toList = toListInfo.join(',')
|
||||
}
|
||||
// echo "toList: ${toList}"
|
||||
return toList
|
||||
}
|
||||
|
||||
def sendextemail(extmailinfo) {
|
||||
def recipientProviders = getRecipientProviders(extmailinfo['Recipient providers'])
|
||||
def toList = getToList(extmailinfo['To'])
|
||||
|
||||
emailext(
|
||||
subject: "[Jenkins] Failed build: ${JOB_NAME} ${BUILD_DISPLAY_NAME}",
|
||||
body: '''${JELLY_SCRIPT,template="html"}''',
|
||||
attachLog: true,
|
||||
// attachmentsPattern: '',
|
||||
compressLog: false,
|
||||
// from : '',
|
||||
mimeType: 'text/html',
|
||||
// postsendScript: '',
|
||||
// presendScript: '',
|
||||
recipientProviders: recipientProviders, // Could be: buildUser, culprits, developers, brokenTestsSuspects, brokenBuildSuspects, recipients, requestor, upstreamDevelopers
|
||||
// replyTo: '',
|
||||
saveOutput: false,
|
||||
to: toList,
|
||||
)
|
||||
}
|
||||
|
||||
def performFailedBuildActions() {
|
||||
def postbuildactions = null
|
||||
if (params.POST_BUILD_INFO != null) {
|
||||
def postbuildinfo = readPostBuildInfo()
|
||||
try {
|
||||
postbuildactions = postbuildinfo['Build outcomes']['Failed']['Actions']
|
||||
} catch(Exception ex) {
|
||||
echo "Post build info did not contain: Build outcomes/Failed/Actions"
|
||||
postbuildactions = null
|
||||
}
|
||||
}
|
||||
if (postbuildactions) {
|
||||
if (postbuildactions['Email']) {
|
||||
sendemails(postbuildactions['Email'])
|
||||
}
|
||||
if (postbuildactions['ExtEmail']) {
|
||||
sendextemail(postbuildactions['ExtEmail'])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
43
Common_scripts/build/postactionstest.groovy
Normal file
43
Common_scripts/build/postactionstest.groovy
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
pipeline {
|
||||
agent { label 'master' }
|
||||
stages {
|
||||
stage('Initial setup') {
|
||||
steps {
|
||||
script {
|
||||
CLEAN_WORKSPACE = false
|
||||
meta = load("${WORKSPACE}/autobuild/Common_scripts/autobuilder.groovy").startnonbuild(this)
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Dummy build job') {
|
||||
steps {
|
||||
script {
|
||||
echo "Execute dummy build job: ${CAUSE_ERROR}"
|
||||
if (CAUSE_ERROR == 'true') {
|
||||
error("Causing error")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
post {
|
||||
always {
|
||||
echo 'Post-build'
|
||||
}
|
||||
failure {
|
||||
echo 'Failed build'
|
||||
script {
|
||||
load("${autobuilder.commonscripts()}/build/postactions.groovy").performFailedBuildActions()
|
||||
}
|
||||
}
|
||||
unstable {
|
||||
echo 'Unstable build'
|
||||
}
|
||||
success {
|
||||
echo 'Succeeded build'
|
||||
script {
|
||||
load("${autobuilder.commonscripts()}/build/postactions.groovy").performSuccessfulBuildActions()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
87
Common_scripts/check/build_meta.groovy
Normal file
87
Common_scripts/check/build_meta.groovy
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
pipeline {
|
||||
agent { label AGENT_LABEL }
|
||||
stages {
|
||||
stage('Initial setup') {
|
||||
steps {
|
||||
script {
|
||||
autobuilderscript = load("${WORKSPACE}/autobuild/Common_scripts/autobuilder.groovy")
|
||||
meta = autobuilderscript.startnonbuild(this)
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Clean exports') {
|
||||
steps {
|
||||
script {
|
||||
cleanfolders = [
|
||||
"${WORKSPACE}/build_artifacts",
|
||||
]
|
||||
cleaner = load("${autobuilder.commonscripts()}/clean/clean.groovy")
|
||||
cleaner.clean(cleanfolders)
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Get build artifact meta') {
|
||||
steps {
|
||||
script {
|
||||
BUILD_ARTIFACTS = "${WORKSPACE}/build_artifacts"
|
||||
copyArtifacts(
|
||||
projectName: BUILD_JOB,
|
||||
selector: [
|
||||
$class: 'ParameterizedBuildSelector',
|
||||
parameterName: BUILD_JOB_SELECTOR
|
||||
],
|
||||
target: BUILD_ARTIFACTS
|
||||
)
|
||||
def mfs = autobuilderscript.getmetafolderscript()
|
||||
buildmeta = mfs.metafromfolder(BUILD_ARTIFACTS)
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Check components') {
|
||||
steps {
|
||||
script {
|
||||
def checker = load("${autobuilder.commonscripts()}/check/do_meta.groovy")
|
||||
(summarystring, markunstable, unstablereason) = checker.checkhierarchy(buildmeta, MAX_META_DEPTH, BUILD_ARTIFACTS)
|
||||
if (markunstable) {
|
||||
env.unstablereason = unstablereason
|
||||
currentBuild.result = 'UNSTABLE'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Archiving artifacts') {
|
||||
steps {
|
||||
script {
|
||||
def artifactlist = meta.generateartifacts()
|
||||
artifactarchiver = load("${autobuilder.commonscripts()}/artifacts/archiver.groovy")
|
||||
artifactarchiver.archive("summary/**,${artifactlist}")
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Summarise') {
|
||||
steps {
|
||||
script {
|
||||
echo "Summary:\n${summarystring}\n"
|
||||
if (env.unstablereason) {
|
||||
echo "Instability reason: ${env.unstablereason}"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
post {
|
||||
always {
|
||||
echo 'Post-build'
|
||||
}
|
||||
failure {
|
||||
echo 'Failed build'
|
||||
}
|
||||
unstable {
|
||||
echo 'Unstable build'
|
||||
}
|
||||
success {
|
||||
echo 'Succeeded build'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
77
Common_scripts/check/do_meta.groovy
Normal file
77
Common_scripts/check/do_meta.groovy
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
markunstable = false
|
||||
unstablereason = ""
|
||||
|
||||
summaryfolder = "${WORKSPACE}/summary"
|
||||
summaryfile = "${summaryfolder}/summary.txt"
|
||||
summarystring = ""
|
||||
releaserepofolder = "${WORKSPACE}/releaserepos"
|
||||
sourcerepofolder = "${WORKSPACE}/sourcerepos"
|
||||
tempfolder = "${WORKSPACE}/temp"
|
||||
gitrevparseoutputfile = "${tempfolder}/gitrevparse.out"
|
||||
|
||||
metascript = autobuilder.getmetafolderscript()
|
||||
|
||||
def resetfolders() {
|
||||
dir(summaryfolder) {
|
||||
deleteDir()
|
||||
}
|
||||
dir(releaserepofolder) {
|
||||
deleteDir()
|
||||
}
|
||||
dir(tempfolder) {
|
||||
deleteDir()
|
||||
}
|
||||
}
|
||||
|
||||
def preconditions() {
|
||||
markunstable = false
|
||||
unstablereason = ""
|
||||
summarystring = ""
|
||||
writeFile(file: summaryfile, text: "Release summary: \n")
|
||||
}
|
||||
|
||||
def setunstable(String reason) {
|
||||
markunstable = true
|
||||
unstablereason += reason + "\n"
|
||||
echo "Marked build as unstable: Reason: ${reason}"
|
||||
}
|
||||
|
||||
def summaryappend(String summary) {
|
||||
def String currentsummarycontents = readFile(file: summaryfile)
|
||||
writeFile(file: summaryfile, text: currentsummarycontents + summary)
|
||||
summarystring += summary
|
||||
}
|
||||
|
||||
def checkhierarchy(buildmeta, String maxdepth, String buildpathroot) {
|
||||
int md = maxdepth.toInteger()
|
||||
resetfolders()
|
||||
preconditions()
|
||||
|
||||
// Walk the meta information to a max depth
|
||||
def buildinfo = buildmeta.releasewalker(md)
|
||||
echo "All components:"
|
||||
def String componentinfo = ""
|
||||
for (entry in buildinfo) {
|
||||
def name = entry.metainfo.componentversionuniqueidentifier()
|
||||
def offsetpath = entry.accumulatedpath
|
||||
def abspath = "${buildpathroot}/${offsetpath}"
|
||||
componentinfo += "Name: ${name} \t\t\t\tPath: ${offsetpath} \t\t\t\tFile exists in import: ${fileExists(abspath)}\n"
|
||||
}
|
||||
echo componentinfo
|
||||
|
||||
// Walk the meta information to a max depth
|
||||
def componentReleaseInfo = buildmeta.releasewalkerunique(md)
|
||||
echo "Unique components:"
|
||||
def String versioncomponent = ""
|
||||
for (key in componentReleaseInfo.keySet()) {
|
||||
def buildinfo2 = componentReleaseInfo[key]
|
||||
def offsetpath = buildinfo2.accumulatedpath
|
||||
def abspath = "${buildpathroot}/${offsetpath}"
|
||||
versioncomponent += "Key: ${key} \t\t\tPath: ${offsetpath} \t\t\tFile exists in import: ${fileExists(abspath)}\n"
|
||||
}
|
||||
echo versioncomponent
|
||||
|
||||
return [summarystring, markunstable, unstablereason]
|
||||
}
|
||||
|
||||
return this;
|
||||
15
Common_scripts/checksum/utils.groovy
Normal file
15
Common_scripts/checksum/utils.groovy
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
|
||||
// Generate a checksum file of from a list of files/directories relative to workspace
|
||||
def generatelist(meta, checksummable) {
|
||||
for (filepath in checksummable) {
|
||||
def checksumset = meta.checksuminfo.addChecksumSet(filepath)
|
||||
def files = findFiles(glob: filepath)
|
||||
for (file in files) {
|
||||
echo "Checksumming: ${file.path}"
|
||||
def sum = sha1(file: file.path).trim()
|
||||
checksumset.addChecksumPair(file.path, sum)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
10
Common_scripts/clean/clean.groovy
Normal file
10
Common_scripts/clean/clean.groovy
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
|
||||
def clean(folderlist) {
|
||||
for (folder in folderlist) {
|
||||
dir(folder) {
|
||||
deleteDir()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
12
Common_scripts/commandline/commandline.groovy
Normal file
12
Common_scripts/commandline/commandline.groovy
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
String getCommandOutput(String cmd) {
|
||||
if (isUnix()) {
|
||||
return sh(returnStdout: true, script: '#!/bin/sh -e\n' + cmd).trim()
|
||||
} else {
|
||||
return powershell(returnStdout: true, script: """
|
||||
${cmd}
|
||||
"""
|
||||
).trim()
|
||||
}
|
||||
}
|
||||
|
||||
return this
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
|
||||
// Disable parallel make builds - which may be causing autobuild issues
|
||||
def doDisableParallelMake(rootSearchFolder = "${WORKSPACE}") {
|
||||
if (isUnix()) {
|
||||
sh """
|
||||
# Looks for "<builder*parallelBuildOn="true"* in all .cproject files and replaces the "true" with "false"
|
||||
find "${rootSearchFolder}" -iname ".cproject" | xargs -iXX sed -i "s@\\(<builder.*parallelBuildOn=\\"\\)true\\(\\"\\)@\\1false\\2@g" XX
|
||||
"""
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
172
Common_scripts/compile/eclipsebuild/eclipseSTM8build.groovy
Normal file
172
Common_scripts/compile/eclipsebuild/eclipseSTM8build.groovy
Normal file
|
|
@ -0,0 +1,172 @@
|
|||
def doDisplayLeftovers() {
|
||||
}
|
||||
|
||||
def doKillLeftovers() {
|
||||
}
|
||||
|
||||
def doCheck(checkpathlist, build_variant = "") {
|
||||
def result = 0
|
||||
for (checkpath in checkpathlist) {
|
||||
echo "Checking file at: ${checkpath}"
|
||||
script {
|
||||
echo "Build variant is ${build_variant}"
|
||||
if (build_variant) {
|
||||
def srcFile = "${WORKSPACE}\${checkpath}"
|
||||
def srcFileExpanded = srcFile.replace("-BUILDVARIANT-", "${build_variant}")
|
||||
// Print out dependencies of the built file
|
||||
echo "Showing dependencies of ${srcFileExpanded}"
|
||||
if (srcFileExpanded.endsWith(".elf")) {
|
||||
result = bat ( script: """
|
||||
${CYGWINDIR}/bin/readelf -hS ${srcFileExpanded}
|
||||
if errorlevel 1 EXIT /b 1
|
||||
""",
|
||||
returnStatus: true
|
||||
)
|
||||
}
|
||||
if (result != 0) {
|
||||
return result
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
def doExport(exportfolder, exportpathlist, partdest = "", build_variant = "") {
|
||||
def result = 0
|
||||
def destFolder = ""
|
||||
def srcFile = ""
|
||||
def srcFileExpanded = ""
|
||||
for (exportpath in exportpathlist) {
|
||||
echo "Export path at: ${exportpath}"
|
||||
script {
|
||||
if (build_variant) {
|
||||
echo "Build variant is ${build_variant}"
|
||||
srcFile = "${WORKSPACE}\\${exportpath}"
|
||||
srcFileExpanded = srcFile.replace("-BUILDVARIANT-", "${build_variant}")
|
||||
}
|
||||
else {
|
||||
echo "No build variant"
|
||||
srcFileExpanded = "${WORKSPACE}\\${exportpath}"
|
||||
}
|
||||
destFolder = "${exportfolder}"
|
||||
if (partdest) {
|
||||
destFolder += "\\" + partdest
|
||||
}
|
||||
}
|
||||
def destFolderExpanded = destFolder.replace("-BUILDVARIANT-", "${build_variant}")
|
||||
dir (destFolderExpanded) {
|
||||
echo "Copy \"${srcFileExpanded}\" to \"${destFolderExpanded}\""
|
||||
result = bat( script: """
|
||||
copy "${srcFileExpanded}" "${destFolderExpanded}"
|
||||
if errorlevel 1 EXIT /b 1
|
||||
""",
|
||||
returnStatus: true
|
||||
)
|
||||
if (result != 0) {
|
||||
return result
|
||||
}
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
// Import all eclipse projects in a given folder
|
||||
def doImportProjects(ds5folder, ds5shellcommand, buildcommand, sourcefolder) {
|
||||
bat """
|
||||
"${ds5shellcommand}" ${buildcommand} -no-indexer -importAll "${sourcefolder}"
|
||||
"""
|
||||
}
|
||||
|
||||
def doBuildAndExportProject(String ds5folder, String ds5shellcommand, String buildcommand, String project, Boolean doexport, variants, String exportfolder, exportpathlist, String destpart) {
|
||||
echo "Doing build and export project: ${project} : ${doexport}"
|
||||
for (build_variant in variants) {
|
||||
retry(maxprojectbuildretries) { // Eclipse occasionally raises exceptions (rather than the builds failing)
|
||||
try {
|
||||
if (toBuild.contains(build_variant)) {
|
||||
doDisplayLeftovers()
|
||||
echo "Build command: ${ds5shellcommand} \'${buildcommand} -no-indexer -build ${project}/${build_variant}\'"
|
||||
timeout(time: 20, unit: 'MINUTES') {
|
||||
bat """
|
||||
"${ds5shellcommand}" ${buildcommand} -no-indexer -build ${project}/${build_variant}
|
||||
"""
|
||||
}
|
||||
result = doCheck(exportpathlist, build_variant)
|
||||
if (result != 0) {
|
||||
error "Failed to check files...."
|
||||
}
|
||||
echo "Doing export: ${doexport}"
|
||||
if (doexport) {
|
||||
result = doExport(exportfolder, exportpathlist, destpart, build_variant)
|
||||
if (result != 0) {
|
||||
error "Failed to copy...."
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
echo "Not building ${build_variant} variant of project: ${project}"
|
||||
}
|
||||
} catch (Exception e) {
|
||||
echo "Exception: ${e.getMessage()}\nBuild failed - Waiting for a while"
|
||||
sleep(time: 4, unit: 'SECONDS')
|
||||
error "Build failed..."
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def doExportOnlyProject(String project, Boolean doexport, variants, String exportfolder, exportpathlist, String destpart) {
|
||||
echo "Doing export only project: ${project} : ${doexport}"
|
||||
if (doexport) {
|
||||
if (!variants) {
|
||||
result = doExport(exportfolder, exportpathlist, destpart)
|
||||
if (result != 0) {
|
||||
error "Failed to copy...."
|
||||
}
|
||||
} else {
|
||||
for (build_variant in variants) {
|
||||
if (toBuild.contains(build_variant)) {
|
||||
result = doExport(exportfolder, exportpathlist, destpart, build_variant)
|
||||
if (result != 0) {
|
||||
error "Failed to copy...."
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Build and export files
|
||||
def doBuild(apps, ds5folder, ds5shellcommand, buildcommand, sourcefolder, variantstobuild, exportfolder = "${WORKSPACE}") {
|
||||
toBuild = []
|
||||
if (variantstobuild) {
|
||||
toBuildUntrimmed = variantstobuild.split(',')
|
||||
toBuildUntrimmed.each {
|
||||
toBuild.add(it.trim())
|
||||
}
|
||||
}
|
||||
// The lock is being used because it was being found that the doKillLeftovers was affecting other builds
|
||||
lock(resource: "eclipsebuild_${env.NODE_NAME}") {
|
||||
try {
|
||||
timeout(time: 5, unit: 'MINUTES') {
|
||||
doImportProjects(ds5folder, ds5shellcommand, buildcommand, sourcefolder)
|
||||
}
|
||||
for (appInfo in apps) {
|
||||
def Boolean build
|
||||
def Boolean doexport
|
||||
(build, doexport, project, variants, exportpathlist, destpart) = appInfo
|
||||
if (build) {
|
||||
doBuildAndExportProject(ds5folder, ds5shellcommand, buildcommand, project, doexport, variants, exportfolder, exportpathlist, destpart)
|
||||
}
|
||||
else {
|
||||
doExportOnlyProject(project, doexport, variants, exportfolder, exportpathlist, destpart)
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// doKillLeftovers()
|
||||
error "Exception: ${e.getMessage()}\nBuild failed - Killing leftovers"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
252
Common_scripts/compile/eclipsebuild/eclipseds5build.groovy
Normal file
252
Common_scripts/compile/eclipsebuild/eclipseds5build.groovy
Normal file
|
|
@ -0,0 +1,252 @@
|
|||
def doDisplayLeftovers() {
|
||||
if (isUnix()) {
|
||||
sh """
|
||||
# Killing any processes that may interfere with the next build
|
||||
# The build system must be setup to do more than one eclipse build concurrently
|
||||
# Don't return an error if the processes don't exist
|
||||
USER=`whoami`
|
||||
ps aux | grep "eclipse"
|
||||
ps aux | grep "make"
|
||||
ps aux | grep "arm-linux"
|
||||
# ps aux | grep "sh"
|
||||
"""
|
||||
}
|
||||
}
|
||||
|
||||
def doKillLeftovers() {
|
||||
if (isUnix()) {
|
||||
doDisplayLeftovers()
|
||||
sh """
|
||||
# Killing any processes that may interfere with the next build
|
||||
# The build system must be setup to do more than one eclipse build concurrently
|
||||
# Don't return an error if the processes don't exist
|
||||
USER=`whoami`
|
||||
pkill -U "${USER}" -9 eclipse || true
|
||||
pkill -U "${USER}" -9 make || true
|
||||
pkill -U "${USER}" -9 ".*arm-linux.*" || true
|
||||
"""
|
||||
}
|
||||
}
|
||||
|
||||
def doCheck(checkpathlist, build_variant = "") {
|
||||
def result = 0
|
||||
for (checkpath in checkpathlist) {
|
||||
echo "Checking file at: ${checkpath}"
|
||||
script {
|
||||
echo "Build variant is ${build_variant}"
|
||||
if (build_variant) {
|
||||
def srcFile = "${WORKSPACE}/${checkpath}"
|
||||
def srcFileExpanded = srcFile.replace("-BUILDVARIANT-", "${build_variant}")
|
||||
// Print out dependencies of the built file
|
||||
echo "Showing dependencies of ${srcFileExpanded}"
|
||||
result = sh( script: """
|
||||
readelf -d "${srcFileExpanded}"
|
||||
if [ \$? -ne 0 ]; then exit 1; fi
|
||||
""",
|
||||
returnStatus: true
|
||||
)
|
||||
if (result != 0) {
|
||||
return result
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
def doExport(exportfolder, exportpathlist, partdest = "", build_variant = "") {
|
||||
def result = 0
|
||||
def destFolder = ""
|
||||
def srcFile = ""
|
||||
def srcFileExpanded = ""
|
||||
for (exportpath in exportpathlist) {
|
||||
echo "Export path at: ${exportpath}"
|
||||
script {
|
||||
if (build_variant) {
|
||||
echo "Build variant is ${build_variant}"
|
||||
srcFile = "${WORKSPACE}/${exportpath}"
|
||||
srcFileExpanded = srcFile.replace("-BUILDVARIANT-", "${build_variant}")
|
||||
}
|
||||
else {
|
||||
echo "No build variant"
|
||||
srcFileExpanded = "${WORKSPACE}/${exportpath}"
|
||||
}
|
||||
destFolder = "${exportfolder}"
|
||||
if (partdest) {
|
||||
destFolder += "/" + partdest
|
||||
}
|
||||
}
|
||||
def destFolderExpanded = destFolder.replace("-BUILDVARIANT-", "${build_variant}")
|
||||
dir (destFolderExpanded) {
|
||||
echo "Copy \"${srcFileExpanded}\" to \"${destFolderExpanded}\""
|
||||
if (isUnix()) {
|
||||
result = sh( script: """
|
||||
cp -v --no-dereference --preserve=links -r "${srcFileExpanded}" "${destFolderExpanded}"
|
||||
if [ \$? -ne 0 ]; then exit 1; fi
|
||||
""",
|
||||
returnStatus: true
|
||||
)
|
||||
if (result != 0) {
|
||||
return result
|
||||
}
|
||||
}
|
||||
else {
|
||||
result = bat( script: """
|
||||
copy "${srcFileExpanded}" "${destFolderExpanded}"
|
||||
if errorlevel 1 EXIT /b 1
|
||||
""",
|
||||
returnStatus: true
|
||||
)
|
||||
if (result != 0) {
|
||||
return result
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
// Register toolchain
|
||||
def doRegisterToolchain(ds5folder, toolchainfolder) {
|
||||
// Register toolchain (if it is not already)
|
||||
if (isUnix()) {
|
||||
sh """
|
||||
"${ds5folder}/bin/add_toolchain" --non-interactive "${toolchainfolder}"
|
||||
"""
|
||||
}
|
||||
else {
|
||||
bat """
|
||||
"%ds5folder%\\bin\\add_toolchain" --non-interactive "%toolchainfolder%"
|
||||
"""
|
||||
}
|
||||
echo "Path is: ${PATH}"
|
||||
}
|
||||
|
||||
// Add toolchain to path
|
||||
def addToolchainPath(toolchainfolder) {
|
||||
// Register toolchain (if it is not already)
|
||||
if (isUnix()) {
|
||||
env.PATH = toolchainfolder + ":" + env.PATH
|
||||
}
|
||||
else {
|
||||
env.PATH = toolchainfolder + ";" + env.PATH
|
||||
}
|
||||
echo "Path is: ${PATH}"
|
||||
}
|
||||
|
||||
// Import all eclipse projects in a given folder
|
||||
def doImportProjects(ds5folder, toolchainfolder, ds5shellcommand, buildcommand, sourcefolder) {
|
||||
doRegisterToolchain(ds5folder, toolchainfolder)
|
||||
if (isUnix()) {
|
||||
sh """
|
||||
${ds5shellcommand} \'${buildcommand} -no-indexer -importAll "${sourcefolder}"\'
|
||||
"""
|
||||
}
|
||||
else {
|
||||
bat '%ds5shellcommand% %buildcommand% -no-indexer -importAll "%sourcefolder%"'
|
||||
}
|
||||
}
|
||||
|
||||
def doBuildAndExportProject(String ds5folder, String toolchainfolder, String ds5shellcommand, String buildcommand, String project, Boolean doexport, variants, String exportfolder, exportpathlist, String destpart) {
|
||||
echo "Doing build and export project: ${project} : ${doexport}"
|
||||
for (build_variant in variants) {
|
||||
retry(maxprojectbuildretries) { // Eclipse occasionally raises exceptions (rather than the builds failing)
|
||||
try {
|
||||
if (toBuild.contains(build_variant)) {
|
||||
doDisplayLeftovers()
|
||||
doRegisterToolchain(ds5folder, toolchainfolder)
|
||||
echo "Build command: ${ds5shellcommand} \'${buildcommand} -no-indexer -build \"${project}/${build_variant}\"\'"
|
||||
timeout(time: 20, unit: 'MINUTES') {
|
||||
if (isUnix()) {
|
||||
sh """
|
||||
echo Start time: `date`
|
||||
${ds5shellcommand} \'${buildcommand} -no-indexer -build \"${project}/${build_variant}\"\'
|
||||
echo End time: `date`
|
||||
"""
|
||||
}
|
||||
else {
|
||||
bat """
|
||||
"%ds5shellcommand%" "%buildcommand%" -no-indexer -build "${project}\\${build_variant}"
|
||||
"""
|
||||
}
|
||||
}
|
||||
result = doCheck(exportpathlist, build_variant)
|
||||
if (result != 0) {
|
||||
error "Failed to check files...."
|
||||
}
|
||||
echo "Doing export: ${doexport}"
|
||||
if (doexport) {
|
||||
result = doExport(exportfolder, exportpathlist, destpart, build_variant)
|
||||
if (result != 0) {
|
||||
error "Failed to copy...."
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
echo "Not building ${build_variant} variant of project: ${project}"
|
||||
}
|
||||
} catch (Exception e) {
|
||||
echo "Exception: ${e.getMessage()}\nBuild failed - Waiting for a while"
|
||||
sleep(time: 4, unit: 'SECONDS')
|
||||
error "Build failed..."
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def doExportOnlyProject(String project, Boolean doexport, variants, String exportfolder, exportpathlist, String destpart) {
|
||||
echo "Doing export only project: ${project} : ${doexport}"
|
||||
if (doexport) {
|
||||
if (!variants) {
|
||||
result = doExport(exportfolder, exportpathlist, destpart)
|
||||
if (result != 0) {
|
||||
error "Failed to copy...."
|
||||
}
|
||||
} else {
|
||||
for (build_variant in variants) {
|
||||
if (toBuild.contains(build_variant)) {
|
||||
result = doExport(exportfolder, exportpathlist, destpart, build_variant)
|
||||
if (result != 0) {
|
||||
error "Failed to copy...."
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Build and export files
|
||||
def doBuild(apps, ds5folder, toolchainfolder, ds5shellcommand, buildcommand, sourcefolder, variantstobuild, exportfolder = "${WORKSPACE}/export") {
|
||||
toBuild = []
|
||||
if (variantstobuild) {
|
||||
toBuildUntrimmed = variantstobuild.split(',')
|
||||
toBuildUntrimmed.each {
|
||||
toBuild.add(it.trim())
|
||||
}
|
||||
}
|
||||
// The lock is being used because it was being found that the doKillLeftovers was affecting other builds
|
||||
lock(resource: "eclipsebuild_${env.NODE_NAME}") {
|
||||
try {
|
||||
timeout(time: 10, unit: 'MINUTES') {
|
||||
addToolchainPath(toolchainfolder)
|
||||
doImportProjects(ds5folder, toolchainfolder, ds5shellcommand, buildcommand, sourcefolder)
|
||||
}
|
||||
for (appInfo in apps) {
|
||||
def Boolean build
|
||||
def Boolean doexport
|
||||
(build, doexport, project, variants, exportpathlist, destpart) = appInfo
|
||||
if (build) {
|
||||
doBuildAndExportProject(ds5folder, toolchainfolder, ds5shellcommand, buildcommand, project, doexport, variants, exportfolder, exportpathlist, destpart)
|
||||
}
|
||||
else {
|
||||
doExportOnlyProject(project, doexport, variants, exportfolder, exportpathlist, destpart)
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// doKillLeftovers()
|
||||
error "Exception: ${e.getMessage()}\nBuild failed - Killing leftovers"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
116
Common_scripts/compile/eclipsebuild/eclipseniosbuild.groovy
Normal file
116
Common_scripts/compile/eclipsebuild/eclipseniosbuild.groovy
Normal file
|
|
@ -0,0 +1,116 @@
|
|||
// Gets the debug and optimization flags.
|
||||
// Arg1 is "app" or "lib". Returns flags.
|
||||
// Restore the debug and optimization levels, in case this is a dev machine.
|
||||
// Arg1 is "app" or "lib". Arg2-3 is flags from getFlags. Returns nothing.
|
||||
def setFlagsToRelease(NIOSEDS, project, wdir) {
|
||||
if ( project == "app" ) {
|
||||
if (isUnix()) {
|
||||
sh """#!/bin/bash
|
||||
set -x
|
||||
cd "${wdir}"
|
||||
|
||||
"${NIOSEDS}/nios2_command_shell.sh" nios2-app-update-makefile --app-dir=. --set-optimization=-O2 --set-debug-level=
|
||||
"""
|
||||
}
|
||||
}
|
||||
else if ( project == "lib" ) {
|
||||
if (isUnix()) {
|
||||
sh """#!/bin/bash
|
||||
set -x
|
||||
cd "${wdir}"
|
||||
|
||||
"${NIOSEDS}/nios2_command_shell.sh" nios2-lib-update-makefile --lib-dir=. --set-optimization=-O2 --set-debug-level=
|
||||
"""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def remake_and_check(NIOSEDS, wdir) {
|
||||
if (isUnix()) {
|
||||
sh """#!/bin/bash
|
||||
set -x
|
||||
cd "${wdir}"
|
||||
|
||||
# Use the makefile to clean and build
|
||||
"${NIOSEDS}/nios2_command_shell.sh" make clean
|
||||
if [ \$? -ne 0 ]; then exit 1; fi
|
||||
|
||||
# Set the debug and optimization levels to production values
|
||||
"${NIOSEDS}/nios2_command_shell.sh" make -j12 all
|
||||
if [ \$? -ne 0 ]; then exit 1; fi
|
||||
"""
|
||||
}
|
||||
}
|
||||
|
||||
def generate_bsp(NIOSEDS, bspfolder) {
|
||||
if (isUnix()) {
|
||||
sh """#!/bin/bash
|
||||
set -x
|
||||
|
||||
"${NIOSEDS}/nios2_command_shell.sh" nios2-bsp-generate-files --bsp-dir "${bspfolder}" --log "${bspfolder}/bsp.log" --settings "${bspfolder}/settings.bsp"
|
||||
"""
|
||||
}
|
||||
}
|
||||
|
||||
def modifylib(NIOSEDS, bspfolder, buildconfig, wdir) {
|
||||
if (isUnix()) {
|
||||
sh """#!/bin/bash
|
||||
set -x
|
||||
|
||||
cd "${wdir}"
|
||||
|
||||
"${NIOSEDS}/nios2_command_shell.sh" nios2-lib-update-makefile --lib-dir=. --set-bsp-dir "${bspfolder}" --set-active-build-config "${buildconfig}"
|
||||
"""
|
||||
}
|
||||
}
|
||||
|
||||
def modifyapp(NIOSEDS, bspfolder, wdir) {
|
||||
if (isUnix()) {
|
||||
sh """#!/bin/bash
|
||||
set -x
|
||||
|
||||
cd "${wdir}"
|
||||
|
||||
"${NIOSEDS}/nios2_command_shell.sh" nios2-app-update-makefile --app-dir=. --set-bsp-dir "${bspfolder}"
|
||||
"""
|
||||
}
|
||||
}
|
||||
|
||||
def dump_elf_info(NIOSEDS, elffile, meta, custominfokeyprefix) {
|
||||
if (isUnix()) {
|
||||
def cpu_name = sh(script: """#!/bin/bash
|
||||
"${NIOSEDS}/nios2_command_shell.sh" nios2-elf-query "${elffile}" --cpu_name
|
||||
""",
|
||||
returnStdout: true
|
||||
).trim()
|
||||
meta.addCustomInfo("${custominfokeyprefix}_cpu_name", cpu_name)
|
||||
def sidp = sh(script: """#!/bin/bash
|
||||
"${NIOSEDS}/nios2_command_shell.sh" nios2-elf-query "${elffile}" --sidp
|
||||
""",
|
||||
returnStdout: true
|
||||
).trim()
|
||||
meta.addCustomInfo("${custominfokeyprefix}_sidp", sidp)
|
||||
def id = sh(script: """#!/bin/bash
|
||||
"${NIOSEDS}/nios2_command_shell.sh" nios2-elf-query "${elffile}" --id
|
||||
""",
|
||||
returnStdout: true
|
||||
).trim()
|
||||
meta.addCustomInfo("${custominfokeyprefix}_id", id)
|
||||
def timestamp = sh(script: """#!/bin/bash
|
||||
"${NIOSEDS}/nios2_command_shell.sh" nios2-elf-query "${elffile}" --timestamp
|
||||
""",
|
||||
returnStdout: true
|
||||
).trim()
|
||||
meta.addCustomInfo("${custominfokeyprefix}_timestamp", timestamp)
|
||||
/*
|
||||
def sopcinfo = sh(script: """#!/bin/bash
|
||||
"${NIOSEDS}/nios2_command_shell.sh" nios2-elf-query "${elffile}" --sopcinfo
|
||||
""",
|
||||
returnStdout: true
|
||||
).trim()
|
||||
meta.addCustomInfo("${custominfokeyprefix}_sopcinfo", sopcinfo)
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
18
Common_scripts/configuration/configuration.groovy
Normal file
18
Common_scripts/configuration/configuration.groovy
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
gh = load("${autobuilder.commonscripts()}/versioncontrol/git.groovy")
|
||||
|
||||
def registerConfigurationInfo(meta, String configurationName, String configurationURL, String configurationVersion, String configurationSHA) {
|
||||
return meta.addConfigurationInfo(configurationName, configurationURL, configurationVersion, configurationSHA)
|
||||
}
|
||||
|
||||
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, String filter = '') {
|
||||
def ArrayList<String> sparseitemlist = gh.convertSparseItemsString(filter)
|
||||
gh.gitCheckoutAlt(gitURL, revision, targetDir, repoRoot, cloneDepth, shallowClone)
|
||||
|
||||
return registerConfigurationInfo(meta, tool, gitURL, revision, gh.getGitInfo(targetDir))
|
||||
}
|
||||
|
||||
return this
|
||||
59
Common_scripts/configuration/tools.groovy
Normal file
59
Common_scripts/configuration/tools.groovy
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
gh = load("${autobuilder.commonscripts()}/versioncontrol/git.groovy")
|
||||
|
||||
class ToolOptions {
|
||||
def m_script // Script to use if wanting to execute script commands (eg. echo -> script.echo)
|
||||
|
||||
String m_toolName
|
||||
|
||||
String m_gitURL
|
||||
String m_revision
|
||||
String m_repoRoot
|
||||
int m_cloneDepth
|
||||
boolean m_shallowClone
|
||||
|
||||
ToolOptions(script) {
|
||||
m_script = script
|
||||
m_gitURL = '-'
|
||||
m_revision = '-'
|
||||
m_repoRoot = ''
|
||||
m_cloneDepth = 1
|
||||
m_shallowClone = true
|
||||
}
|
||||
|
||||
void toolName(String name) {
|
||||
m_toolName = name.trim()
|
||||
}
|
||||
|
||||
void toolRepo(String gitURL, String revision) {
|
||||
m_gitURL = gitURL.trim()
|
||||
m_revision = revision.trim()
|
||||
}
|
||||
|
||||
void repoRoot(String root) {
|
||||
m_repoRoot = root.trim()
|
||||
}
|
||||
|
||||
void clonedepth(int depth) {
|
||||
m_cloneDepth = depth
|
||||
}
|
||||
|
||||
void shallowclone(boolean shallow) {
|
||||
m_shallowClone = shallow
|
||||
}
|
||||
}
|
||||
|
||||
ToolOptions getNewToolOptions() {
|
||||
return new ToolOptions(this)
|
||||
}
|
||||
|
||||
def registerConfigurationInfo(meta, String configurationName, String configurationURL, String configurationVersion, String configurationSHA) {
|
||||
meta.addConfigurationInfo(configurationName, configurationURL, configurationVersion, configurationSHA)
|
||||
}
|
||||
|
||||
def getTool(meta, ToolOptions options, String targetDir) {
|
||||
gh.gitCheckoutAlt(options.m_gitURL, options.m_revision, targetDir, options.m_repoRoot, options.m_cloneDepth, options.m_shallowClone)
|
||||
|
||||
registerConfigurationInfo(meta, options.m_toolName, options.m_gitURL, options.m_revision, gh.getGitInfo(targetDir))
|
||||
}
|
||||
|
||||
return this
|
||||
79
Common_scripts/copy/all.groovy
Normal file
79
Common_scripts/copy/all.groovy
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
pipeline {
|
||||
agent { label AGENT_LABEL }
|
||||
stages {
|
||||
stage('Initial setup') {
|
||||
steps {
|
||||
script {
|
||||
meta = load("${WORKSPACE}/autobuild/Common_scripts/autobuilder.groovy").startnonbuild(this)
|
||||
|
||||
importer = load("${autobuilder.commonscripts()}/import/importer.groovy")
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Clean exports') {
|
||||
steps {
|
||||
script {
|
||||
IMPORTS = 'imports'
|
||||
cleanfolders = [
|
||||
IMPORTS,
|
||||
]
|
||||
cleaner = load("${autobuilder.commonscripts()}/clean/clean.groovy")
|
||||
cleaner.clean(cleanfolders)
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Import source artifacts') {
|
||||
steps {
|
||||
script {
|
||||
def copyoptions = importer.getNewImportOptions()
|
||||
copyoptions.source(
|
||||
SOURCE_ARTIFACT_LOCATION,
|
||||
SOURCE_ARTIFACT_BUILD_JOB,
|
||||
SOURCE_ARTIFACT_BUILD_SELECTOR,
|
||||
SOURCE_ARTIFACT_RELEASE_REPO,
|
||||
SOURCE_ARTIFACT_RELEASE_REVISION)
|
||||
echo "Nested: ${NESTED_COPY}"
|
||||
copyoptions.setnested(NESTED_COPY == 'true')
|
||||
importer.artifactimport(meta, copyoptions, IMPORTS)
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Archiving artifacts') {
|
||||
steps {
|
||||
script {
|
||||
def artifactlist = meta.generateartifacts(['**/*'])
|
||||
def artifactarchiver = load("${autobuilder.commonscripts()}/artifacts/archiver.groovy")
|
||||
|
||||
cleaner.clean(['meta', 'autobuild'])
|
||||
|
||||
dir(IMPORTS) {
|
||||
fileOperations([
|
||||
fileCopyOperation(excludes: '',
|
||||
flattenFiles: false,
|
||||
includes: '**/*',
|
||||
targetLocation: WORKSPACE)
|
||||
])
|
||||
}
|
||||
|
||||
cleaner.clean([IMPORTS])
|
||||
|
||||
artifactarchiver.archive(meta, artifactlist)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
post {
|
||||
always {
|
||||
echo 'Post-build'
|
||||
}
|
||||
failure {
|
||||
echo 'Failed build'
|
||||
}
|
||||
unstable {
|
||||
echo 'Unstable build'
|
||||
}
|
||||
success {
|
||||
echo 'Succeeded build'
|
||||
}
|
||||
}
|
||||
}
|
||||
67
Common_scripts/copy/esw.groovy
Normal file
67
Common_scripts/copy/esw.groovy
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
pipeline {
|
||||
agent { label AGENT_LABEL }
|
||||
stages {
|
||||
stage('Initial setup') {
|
||||
steps {
|
||||
script {
|
||||
meta = load("${WORKSPACE}/autobuild/Common_scripts/autobuilder.groovy").startnonbuild(this)
|
||||
|
||||
importer = load("${autobuilder.commonscripts()}/import/importer.groovy")
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Clean exports') {
|
||||
steps {
|
||||
script {
|
||||
env.ESW = 'esw'
|
||||
env.ESWDEST = "${WORKSPACE}/${ESW}"
|
||||
env.ESWEXPORT = 'embedded_software'
|
||||
cleanfolders = [
|
||||
ESWDEST,
|
||||
ESWEXPORT,
|
||||
]
|
||||
cleaner = load("${autobuilder.commonscripts()}/clean/clean.groovy")
|
||||
cleaner.clean(cleanfolders)
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Copying embedded software artifacts') {
|
||||
steps {
|
||||
script {
|
||||
def eswimportoptions = importer.getNewImportOptions()
|
||||
eswimportoptions.source(ESW_ARTIFACT_LOCATION, ESW_ARTIFACT_BUILD_JOB, ESW_ARTIFACT_BUILD_SELECTOR, ESW_ARTIFACT_RELEASE_REPO, ESW_ARTIFACT_RELEASE_REVISION)
|
||||
eswimportoptions.setincrementversionnumber(true)
|
||||
importer.artifactimport(meta, eswimportoptions, ESWDEST)
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Archiving artifacts') {
|
||||
steps {
|
||||
script {
|
||||
def artifactlist = meta.generateartifacts(["${ESWEXPORT}/**"])
|
||||
sh """
|
||||
rm -v -rf diff
|
||||
rm -v -rf meta
|
||||
mv -v "${ESW}"/* .
|
||||
"""
|
||||
artifactarchiver = load("${autobuilder.commonscripts()}/artifacts/archiver.groovy")
|
||||
artifactarchiver.archive(meta, artifactlist)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
post {
|
||||
always {
|
||||
echo 'Post-build'
|
||||
}
|
||||
failure {
|
||||
echo 'Failed build'
|
||||
}
|
||||
unstable {
|
||||
echo 'Unstable build'
|
||||
}
|
||||
success {
|
||||
echo 'Succeeded build'
|
||||
}
|
||||
}
|
||||
}
|
||||
73
Common_scripts/copy/filtered.groovy
Normal file
73
Common_scripts/copy/filtered.groovy
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
pipeline {
|
||||
agent { label AGENT_LABEL }
|
||||
stages {
|
||||
stage('Initial setup') {
|
||||
steps {
|
||||
script {
|
||||
meta = load("${WORKSPACE}/autobuild/Common_scripts/autobuilder.groovy").startnonbuild(this)
|
||||
|
||||
importer = load("${autobuilder.commonscripts()}/import/importer.groovy")
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Clean') {
|
||||
steps {
|
||||
script {
|
||||
env.IMPORT = "${WORKSPACE}/import"
|
||||
env.FILTEREDDEST = "${WORKSPACE}/filtered"
|
||||
cleanfolders = [
|
||||
FILTEREDDEST,
|
||||
IMPORT,
|
||||
]
|
||||
cleaner = load("${autobuilder.commonscripts()}/clean/clean.groovy")
|
||||
cleaner.clean(cleanfolders)
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Import artifacts') {
|
||||
steps {
|
||||
script {
|
||||
def importoptions = importer.getNewImportOptions()
|
||||
importoptions.source(ARTIFACT_LOCATION, ARTIFACT_PROJECT, ARTIFACT_BUILD_SELECTOR, RELEASE_REPO, RELEASE_REVISION)
|
||||
importer.artifactimport(meta, importoptions, IMPORT)
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Filtered copy') {
|
||||
steps {
|
||||
script {
|
||||
dir(IMPORT) {
|
||||
fileOperations([
|
||||
fileCopyOperation(excludes: EXCLUDES,
|
||||
flattenFiles: FLATTENOUTPUT,
|
||||
includes: INCLUDES,
|
||||
targetLocation: FILTEREDDEST)])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Archiving artifacts') {
|
||||
steps {
|
||||
script {
|
||||
def artifactlist = meta.generateartifacts(["filtered/**"])
|
||||
artifactarchiver = load("${autobuilder.commonscripts()}/artifacts/archiver.groovy")
|
||||
artifactarchiver.archive(meta, artifactlist)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
post {
|
||||
always {
|
||||
echo 'Post-build'
|
||||
}
|
||||
failure {
|
||||
echo 'Failed build'
|
||||
}
|
||||
unstable {
|
||||
echo 'Unstable build'
|
||||
}
|
||||
success {
|
||||
echo 'Succeeded build'
|
||||
}
|
||||
}
|
||||
}
|
||||
79
Common_scripts/copy/logic.groovy
Normal file
79
Common_scripts/copy/logic.groovy
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
pipeline {
|
||||
agent { label AGENT_LABEL }
|
||||
stages {
|
||||
stage('Initial setup') {
|
||||
steps {
|
||||
script {
|
||||
meta = load("${WORKSPACE}/autobuild/Common_scripts/autobuilder.groovy").startnonbuild(this)
|
||||
|
||||
importer = load("${autobuilder.commonscripts()}/import/importer.groovy")
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Clean exports') {
|
||||
steps {
|
||||
script {
|
||||
LOGICDEST = 'logic'
|
||||
cleanfolders = [
|
||||
LOGICDEST,
|
||||
"${WORKSPACE}/embedded_logic",
|
||||
"${WORKSPACE}/el",
|
||||
]
|
||||
cleaner = load("${autobuilder.commonscripts()}/clean/clean.groovy")
|
||||
cleaner.clean(cleanfolders)
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Import source artifacts') {
|
||||
steps {
|
||||
script {
|
||||
def logicoptions = importer.getNewImportOptions()
|
||||
logicoptions.source(
|
||||
LOGIC_ARTIFACT_LOCATION,
|
||||
LOGIC_ARTIFACT_PROJECT,
|
||||
LOGIC_ARTIFACT_BUILD_SELECTOR,
|
||||
LOGIC_ARTIFACT_RELEASE_REPO,
|
||||
LOGIC_ARTIFACT_RELEASE_REVISION)
|
||||
importer.artifactimport(meta, logicoptions, LOGICDEST)
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Archiving artifacts') {
|
||||
steps {
|
||||
script {
|
||||
def artifactlist = meta.generateartifacts(['**/*'])
|
||||
def artifactarchiver = load("${autobuilder.commonscripts()}/artifacts/archiver.groovy")
|
||||
|
||||
cleaner.clean(['meta', 'autobuild'])
|
||||
|
||||
dir(LOGICDEST) {
|
||||
fileOperations([
|
||||
fileCopyOperation(excludes: '',
|
||||
flattenFiles: false,
|
||||
includes: '**/*',
|
||||
targetLocation: WORKSPACE)
|
||||
])
|
||||
}
|
||||
|
||||
cleaner.clean([LOGICDEST])
|
||||
|
||||
artifactarchiver.archive(meta, artifactlist)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
post {
|
||||
always {
|
||||
echo 'Post-build'
|
||||
}
|
||||
failure {
|
||||
echo 'Failed build'
|
||||
}
|
||||
unstable {
|
||||
echo 'Unstable build'
|
||||
}
|
||||
success {
|
||||
echo 'Succeeded build'
|
||||
}
|
||||
}
|
||||
}
|
||||
17
Common_scripts/differences/.project
Normal file
17
Common_scripts/differences/.project
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>Release_difference</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.python.pydev.PyDevBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.python.pydev.pythonNature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
8
Common_scripts/differences/.pydevproject
Normal file
8
Common_scripts/differences/.pydevproject
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<?eclipse-pydev version="1.0"?><pydev_project>
|
||||
<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
|
||||
<path>/${PROJECT_DIR_NAME}</path>
|
||||
</pydev_pathproperty>
|
||||
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 3.0</pydev_property>
|
||||
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
|
||||
</pydev_project>
|
||||
836
Common_scripts/differences/dometahierarchy.groovy
Normal file
836
Common_scripts/differences/dometahierarchy.groovy
Normal file
|
|
@ -0,0 +1,836 @@
|
|||
import groovy.json.JsonSlurper
|
||||
|
||||
markunstable = false
|
||||
unstablereason = ""
|
||||
|
||||
summaryfolder = "${WORKSPACE}/summary"
|
||||
summaryfile = "${summaryfolder}/summary.txt"
|
||||
summarystring = ""
|
||||
|
||||
sourcerepofolder = "${WORKSPACE}/sourcerepos"
|
||||
tempfolder = "${WORKSPACE}/temp"
|
||||
|
||||
reportfolder = "${WORKSPACE}/reports"
|
||||
|
||||
class JiraTicketInfo {
|
||||
String jiranumber
|
||||
String uri
|
||||
|
||||
JiraTicketInfo() {
|
||||
jiranumber = ''
|
||||
uri = ''
|
||||
}
|
||||
|
||||
def String dump() {
|
||||
return "jiranumber: ${jiranumber} uri: ${uri}"
|
||||
}
|
||||
}
|
||||
|
||||
class DifferenceRecord {
|
||||
String productname
|
||||
String subcomponentname
|
||||
|
||||
String rawdifferencetext
|
||||
String sha
|
||||
String type
|
||||
String mergeinfo
|
||||
String squashinfo
|
||||
List<JiraTicketInfo> jiraticketinfo
|
||||
String comment
|
||||
|
||||
DifferenceRecord() {
|
||||
productname = ""
|
||||
subcomponentname = ""
|
||||
|
||||
rawdifferencetext = ""
|
||||
sha = ""
|
||||
type = ""
|
||||
mergeinfo = ""
|
||||
squashinfo = ""
|
||||
jiraticketinfo = []
|
||||
comment = ""
|
||||
}
|
||||
|
||||
def String dump() {
|
||||
String jiraticketstring = ''
|
||||
for (j in jiraticketinfo) {
|
||||
jiraticketstring += j.dump() + " "
|
||||
}
|
||||
return "Difference Record:\nproductname: ${productname}\nsubcomponentname: ${subcomponentname}\nrawdifferencetext: ${rawdifferencetext}\nsha: ${sha}\ntype: ${type}\nmergeinfo: ${mergeinfo}\njiraticketinfo: ${jiraticketstring}\ncomment: ${comment}"
|
||||
}
|
||||
}
|
||||
|
||||
def resetfolders() {
|
||||
dir(summaryfolder) {
|
||||
deleteDir()
|
||||
}
|
||||
dir(tempfolder) {
|
||||
deleteDir()
|
||||
}
|
||||
dir(reportfolder) {
|
||||
deleteDir()
|
||||
}
|
||||
}
|
||||
|
||||
def preconditions() {
|
||||
markunstable = false
|
||||
unstablereason = ""
|
||||
summarystring = ""
|
||||
writeFile(file: summaryfile, text: "Release summary: \n")
|
||||
}
|
||||
|
||||
def setunstable(String reason) {
|
||||
markunstable = true
|
||||
unstablereason += reason + "\n"
|
||||
echo "Marked build as unstable: Reason: ${reason}"
|
||||
}
|
||||
|
||||
def summaryappend(String summary) {
|
||||
def String currentsummarycontents = readFile(file: summaryfile)
|
||||
writeFile(file: summaryfile, text: currentsummarycontents + summary)
|
||||
summarystring += summary
|
||||
}
|
||||
|
||||
def showmetaitems(metaitems) {
|
||||
String info = ''
|
||||
for (key in metaitems.keySet()) {
|
||||
def relatedmetainfo = metaitems[key]
|
||||
def accumulatedpath = relatedmetainfo.accumulatedpath
|
||||
info += "Name: ${key}\t\t\t\tPath: ${accumulatedpath}\n"
|
||||
}
|
||||
echo info
|
||||
}
|
||||
|
||||
def boolean checkoutsourcerepo(buildmeta, String checkoutfolder) {
|
||||
boolean checkedout = false
|
||||
def String sourcerepo = buildmeta.gitinfo.remoteurl
|
||||
if (sourcerepo?.trim()) {
|
||||
echo "Updating source repo: ${sourcerepo} in folder: ${checkoutfolder}"
|
||||
if (sourcerepo) {
|
||||
// Get the latest revision of the source repo without checking out working copy; Check out to a folder unique to component
|
||||
if (fileExists(checkoutfolder)) {
|
||||
dir(checkoutfolder) {
|
||||
sh("""
|
||||
git reset --hard
|
||||
git clean -fdx
|
||||
git pull
|
||||
"""
|
||||
)
|
||||
}
|
||||
}
|
||||
else {
|
||||
dir(sourcerepofolder) {
|
||||
sh("git clone ${sourcerepo} ${checkoutfolder}")
|
||||
}
|
||||
}
|
||||
}
|
||||
checkedout = true
|
||||
}
|
||||
return checkedout
|
||||
}
|
||||
|
||||
def String getcomponent(meta) {
|
||||
def String uniquefolder = "${meta.productinfo.productname}_${meta.productinfo.subcomponentname}"
|
||||
def String uniquefoldertemp = "${tempfolder}/${uniquefolder}"
|
||||
def String uniquefolderforsourcerepo = "${sourcerepofolder}/${uniquefolder}"
|
||||
|
||||
boolean checkedout = checkoutsourcerepo(meta, uniquefolderforsourcerepo)
|
||||
|
||||
return [checkedout, uniquefolderforsourcerepo]
|
||||
}
|
||||
|
||||
def getgitlogdifferences(String gitrootfolder, String earlyrevision, String laterrevision, boolean tripledot = false) {
|
||||
def String releaseexpression
|
||||
if (tripledot) {
|
||||
releaseexpression = earlyrevision + "..." + laterrevision
|
||||
} else {
|
||||
releaseexpression = earlyrevision + ".." + laterrevision
|
||||
}
|
||||
def String differencetext
|
||||
dir(gitrootfolder) {
|
||||
differencetext = sh(returnStdout: true, script: "git --no-pager log --oneline ${releaseexpression}").trim()
|
||||
}
|
||||
return differencetext
|
||||
}
|
||||
|
||||
def extractsha(String line) {
|
||||
def pattern = ~"^(\\p{XDigit}*) (.*)"
|
||||
def match = (line =~ pattern)
|
||||
match.find()
|
||||
|
||||
def sha = match.group(1)
|
||||
def restofline = match.group(2)
|
||||
|
||||
//echo "Sha filtering: line: ${line} sha: ${sha} therest: ${restofline}"
|
||||
|
||||
return [sha.trim(), restofline.trim()]
|
||||
}
|
||||
|
||||
def extractsquashes(String line) {
|
||||
def pattern1 = "^(.*)(Squashed .*)"
|
||||
def match1 = (line =~ pattern1)
|
||||
if (match1.find()) {
|
||||
return [true, match1.group(2)]
|
||||
}
|
||||
|
||||
return [false, line]
|
||||
}
|
||||
|
||||
def extractmerges(String line) {
|
||||
def pattern1 = "^(.*)(Merge branch .*)"
|
||||
def match1 = (line =~ pattern1)
|
||||
if (match1.find()) {
|
||||
return [true, match1.group(2)]
|
||||
}
|
||||
|
||||
def pattern2 = "^(.*)(Merge remote-tracking branch .*)"
|
||||
def match2 = (line =~ pattern2)
|
||||
if (match2.find()) {
|
||||
return [true, match2.group(2)]
|
||||
}
|
||||
|
||||
def pattern3 = "^(.*)(Merge commit .*)"
|
||||
def match3 = (line =~ pattern3)
|
||||
if (match3.find()) {
|
||||
return [true, match3.group(2)]
|
||||
}
|
||||
|
||||
def pattern4 = "^(.*)(Add .* from commit .*)"
|
||||
def match4 = (line =~ pattern4)
|
||||
if (match4.find()) {
|
||||
return [true, match4.group(2)]
|
||||
}
|
||||
|
||||
return [false, line]
|
||||
}
|
||||
|
||||
def jiraticketexists(String jiraticket) {
|
||||
def String URI = "${JIRA_URI}/browse/${jiraticket}"
|
||||
def String RestfulURI = "${JIRA_URI}/rest/api/latest/issue/${jiraticket}?fields=summary"
|
||||
def get = new URL(RestfulURI).openConnection();
|
||||
get.setRequestProperty( 'X-AUSERNAME', "${JIRA_USERNAME}" )
|
||||
get.setRequestProperty( 'Authorization', "Basic ${JIRA_ENCODED_PASSWORD}" )
|
||||
get.setRequestProperty( 'User-Agent', 'groovy-2.4.4' )
|
||||
get.setRequestProperty( 'Accept', 'application/json' )
|
||||
def getRC = get.getResponseCode();
|
||||
|
||||
def String redirectedjiraticket = jiraticket
|
||||
if(!getRC.equals(200)) {
|
||||
return [false, '', jiraticket]
|
||||
} else {
|
||||
def jsonresponse = new JsonSlurper().parseText(get.inputStream.getText('UTF-8'))
|
||||
redirectedjiraticket = jsonresponse['key']
|
||||
}
|
||||
return [true, URI, redirectedjiraticket]
|
||||
}
|
||||
|
||||
def extractjiraticketinfo(String line) {
|
||||
def List jiratickets = []
|
||||
boolean exists = false
|
||||
String URI = ''
|
||||
|
||||
while (true) {
|
||||
line = line.trim()
|
||||
def commapattern = '^\\s*,(.*)' // Consume separating commas at the beginning of the line
|
||||
def commamatch = (line =~ commapattern)
|
||||
if (commamatch.find()) {
|
||||
line = commamatch.group(1).trim()
|
||||
}
|
||||
def pattern1 = '^(\\w+-\\d+)(.*)' //GIS-1234 hmbxr5601-1234
|
||||
def match1 = (line =~ pattern1)
|
||||
if (match1.find()) {
|
||||
jiraticket = match1.group(1)
|
||||
(exists, URI, jiraticket) = jiraticketexists(jiraticket)
|
||||
if (exists) {
|
||||
def JiraTicketInfo j = new JiraTicketInfo()
|
||||
j.jiranumber = jiraticket
|
||||
j.uri = URI
|
||||
jiratickets.add(j)
|
||||
line = match1.group(2)
|
||||
} else {
|
||||
break
|
||||
}
|
||||
} else {
|
||||
def pattern2 = '^(\\w+)(\\d+)(.*)' //GIS1234 smb1234
|
||||
def match2 = (line =~ pattern2)
|
||||
if (match2.find()) {
|
||||
jiraticket = match2.group(1) + "-" + match2.group(2)
|
||||
(exists, URI, jiraticket) = jiraticketexists(jiraticket)
|
||||
if (exists) {
|
||||
def JiraTicketInfo j = new JiraTicketInfo()
|
||||
j.jiranumber = jiraticket
|
||||
j.uri = URI
|
||||
jiratickets.add(j)
|
||||
line = match2.group(3)
|
||||
} else {
|
||||
break
|
||||
}
|
||||
} else {
|
||||
def pattern3 = '^(\\w+)\\s(\\d+)(.*)' //GIS 1234 smb 1234
|
||||
def match3 = (line =~ pattern3)
|
||||
if (match3.find()) {
|
||||
jiraticket = match3.group(1) + "-" + match3.group(2)
|
||||
(exists, URI, jiraticket) = jiraticketexists(jiraticket)
|
||||
if (exists) {
|
||||
def JiraTicketInfo j = new JiraTicketInfo()
|
||||
j.jiranumber = jiraticket
|
||||
j.uri = URI
|
||||
jiratickets.add(j)
|
||||
line = match3.group(3)
|
||||
} else {
|
||||
break
|
||||
}
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
boolean result = jiratickets.size() > 0
|
||||
return [result, jiratickets, line]
|
||||
}
|
||||
|
||||
def extractreverts(String line) {
|
||||
boolean result = true
|
||||
|
||||
def pattern1 = '^(.*)Revert \"(.*)\"'
|
||||
def match1 = (line =~ pattern1)
|
||||
if (match1.find()) {
|
||||
def line2 = match1.group(2)
|
||||
(result, originaljiraticketinfo, originalcomment) = extractjiraticketinfo(line2)
|
||||
return [true, originaljiraticketinfo, originalcomment]
|
||||
}
|
||||
|
||||
def pattern2 = '^(.*)Partial Revert \"(.*)\"'
|
||||
def match2 = (line =~ pattern2)
|
||||
if (match2.find()) {
|
||||
def line2 = match2.group(2)
|
||||
(result, originaljiraticketinfo, originalcomment) = extractjiraticketinfo(line2)
|
||||
return [true, originaljiraticketinfo, originalcomment]
|
||||
}
|
||||
|
||||
return [false, [], line]
|
||||
}
|
||||
|
||||
def getgitlogdifferencesfromsquash(String gitrootfolder, String squashedrevision) {
|
||||
def String differencetext
|
||||
dir(gitrootfolder) {
|
||||
differencetext = sh(returnStdout: true, script: "git --no-pager log --oneline ${squashedrevision}").trim()
|
||||
}
|
||||
return differencetext
|
||||
}
|
||||
|
||||
def List fillsquashrecords(String sourcepath, String sha) {
|
||||
def List differencerecords = []
|
||||
|
||||
String squashloglines = getgitlogdifferencesfromsquash(sourcepath, sha)
|
||||
int count = 0
|
||||
squashloglines.split('\n').each {
|
||||
if (count > 0) { // Ignore first line
|
||||
def line = it
|
||||
if (line?.trim()) {
|
||||
def List drs = fillrecord(meta, line.trim(), sourcepath)
|
||||
differencerecords.addAll(drs)
|
||||
//echo "${dr.dump()}"
|
||||
}
|
||||
}
|
||||
count += 1
|
||||
}
|
||||
return differencerecords
|
||||
}
|
||||
|
||||
def List fillrecord(meta, line, String sourcepath) {
|
||||
def List differencerecords = []
|
||||
def DifferenceRecord dr = new DifferenceRecord()
|
||||
|
||||
dr.productname = meta.productinfo.productname
|
||||
dr.subcomponentname = meta.productinfo.subcomponentname
|
||||
|
||||
dr.rawdifferencetext = line
|
||||
|
||||
// Example of raw text to process:
|
||||
// 76056562e4 GIS-1621 - Removing redundant lines and effects of this - Restore nuget_version_edit.py
|
||||
|
||||
(sha, line2) = extractsha(line)
|
||||
dr.sha = sha
|
||||
|
||||
(result, squashinfo) = extractsquashes(line2)
|
||||
if (result) {
|
||||
dr.type = "Squash"
|
||||
dr.squashinfo = squashinfo
|
||||
squashrecords = fillsquashrecords(sourcepath, sha)
|
||||
differencerecords.addAll(squashrecords)
|
||||
} else {
|
||||
(result, mergeinfo) = extractmerges(line2)
|
||||
if (result) {
|
||||
dr.type = "Merge"
|
||||
dr.mergeinfo = mergeinfo
|
||||
} else {
|
||||
(result, jiraticketinfo, comment) = extractreverts(line2)
|
||||
if (result) {
|
||||
dr.type = "Revert"
|
||||
dr.jiraticketinfo = jiraticketinfo
|
||||
dr.comment = comment
|
||||
} else {
|
||||
(result, jiraticketinfo, comment) = extractjiraticketinfo(line2)
|
||||
if (result) {
|
||||
dr.type = "Ticketed"
|
||||
dr.jiraticketinfo = jiraticketinfo
|
||||
dr.comment = comment
|
||||
} else {
|
||||
dr.type = "Unticketed"
|
||||
dr.comment = line2
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
differencerecords.add(dr)
|
||||
return differencerecords
|
||||
}
|
||||
|
||||
def List processtext(meta, String text, String sourcepath) {
|
||||
def List differencerecords = []
|
||||
|
||||
text.split('\n').each {
|
||||
def line = it
|
||||
if (line?.trim()) {
|
||||
def List drs = fillrecord(meta, line.trim(), sourcepath)
|
||||
differencerecords.addAll(drs)
|
||||
//echo "${dr.dump()}"
|
||||
}
|
||||
}
|
||||
return differencerecords
|
||||
}
|
||||
|
||||
def getdifferencerecords(earlymeta, latermeta, String sourcepath) {
|
||||
boolean result = true;
|
||||
def List differencerecords = []
|
||||
|
||||
def earlygitinfo = earlymeta.gitinfo
|
||||
def latergitinfo = latermeta.gitinfo
|
||||
|
||||
if (earlygitinfo.remoteurl == latergitinfo.remoteurl) {
|
||||
def earlyrevision = earlygitinfo.gitrevision
|
||||
def laterrevision = latergitinfo.gitrevision
|
||||
echo "Comparing early revision: ${earlyrevision} with: ${laterrevision} Working copy path: ${sourcepath}"
|
||||
summaryappend("Early revision: ${earlyrevision} Later revision: ${laterrevision}")
|
||||
def String differencetext = getgitlogdifferences(sourcepath, earlyrevision, laterrevision)
|
||||
differencerecords = processtext(earlymeta, differencetext, sourcepath)
|
||||
if (earlyrevision == laterrevision) {
|
||||
summaryappend(" No change")
|
||||
}
|
||||
} else {
|
||||
summaryappend("The early and later git urls don't match")
|
||||
echo "The early and later git urls don't match"
|
||||
result = false;
|
||||
setunstable("The early and later git urls don't match in: ${earlymeta.componentidentifier()}")
|
||||
}
|
||||
|
||||
return [result, differencerecords]
|
||||
}
|
||||
|
||||
def deletedcomponent(earlymetaitems, key) {
|
||||
echo "Component ${key} has been deleted in later version"
|
||||
summaryappend("Deleted ")
|
||||
}
|
||||
|
||||
def addedcomponent(latermetaitems, key) {
|
||||
echo "Component ${key} has been added in later version"
|
||||
summaryappend("Added ")
|
||||
}
|
||||
|
||||
class SquashReportRecord {
|
||||
String comment
|
||||
int duplicates
|
||||
|
||||
SquashReportRecord() {
|
||||
comment = ''
|
||||
duplicates = 0
|
||||
}
|
||||
}
|
||||
|
||||
def squashreport(String reportsubfolder, String title, LinkedHashMap<String, SquashReportRecord> squashes, boolean iscomponent = true) {
|
||||
dir(reportsubfolder) {
|
||||
def String squashlist = "${title}\nSquash list:\n"
|
||||
def squashessorted = squashes.sort()
|
||||
for (asquash in squashessorted) {
|
||||
def SquashReportRecord s = asquash.value
|
||||
squashlist += "${s.comment} (${s.duplicates})\n"
|
||||
}
|
||||
writeFile(file: "squashlist.txt", text: squashlist)
|
||||
}
|
||||
}
|
||||
|
||||
class MergeReportRecord {
|
||||
String comment
|
||||
int duplicates
|
||||
|
||||
MergeReportRecord() {
|
||||
comment = ''
|
||||
duplicates = 0
|
||||
}
|
||||
}
|
||||
|
||||
def mergereport(String reportsubfolder, String title, LinkedHashMap<String, MergeReportRecord> merges, boolean iscomponent = true) {
|
||||
dir(reportsubfolder) {
|
||||
def String mergelist = "${title}\nMerge list:\n"
|
||||
def mergessorted = merges.sort()
|
||||
for (amerge in mergessorted) {
|
||||
def MergeReportRecord m = amerge.value
|
||||
mergelist += "${m.comment} (${m.duplicates})\n"
|
||||
}
|
||||
writeFile(file: "mergelist.txt", text: mergelist)
|
||||
}
|
||||
}
|
||||
|
||||
class CommentsRecord {
|
||||
String comment
|
||||
int duplicates
|
||||
|
||||
CommentsRecord() {
|
||||
comment = ''
|
||||
duplicates = 0
|
||||
}
|
||||
}
|
||||
|
||||
class RevertsReportRecord {
|
||||
String jiraticket
|
||||
String ticketURI
|
||||
LinkedHashMap<String, CommentsRecord> commentscollection
|
||||
|
||||
RevertsReportRecord() {
|
||||
jiraticket = ''
|
||||
ticketURI = ''
|
||||
commentscollection = new LinkedHashMap<String, CommentsRecord>()
|
||||
}
|
||||
}
|
||||
|
||||
def revertsreport(String reportsubfolder, String title, LinkedHashMap<String, RevertsReportRecord> reverts, boolean iscomponent = true) {
|
||||
dir(reportsubfolder) {
|
||||
def String revertlist = "${title}\nRevert list:\n"
|
||||
def revertssorted = reverts.sort()
|
||||
for (arevert in revertssorted) {
|
||||
def RevertsReportRecord r = arevert.value
|
||||
revertlist += "${r.jiraticket} (${r.ticketURI}):\n"
|
||||
def commentscollection = r.commentscollection
|
||||
def sortedcommentscollection = commentscollection.sort()
|
||||
for (commentrecord in sortedcommentscollection) {
|
||||
def CommentsRecord c = commentrecord.value
|
||||
revertlist += "${c.comment} (${c.duplicates})\n"
|
||||
}
|
||||
revertlist += "\n"
|
||||
}
|
||||
writeFile(file: "revertlist.txt", text: revertlist)
|
||||
}
|
||||
}
|
||||
|
||||
class TicketedReportRecord {
|
||||
String jiraticket
|
||||
String ticketURI
|
||||
LinkedHashMap<String, CommentsRecord> commentscollection
|
||||
|
||||
TicketedReportRecord() {
|
||||
jiraticket = ''
|
||||
ticketURI = ''
|
||||
commentscollection = new LinkedHashMap<String, CommentsRecord>()
|
||||
}
|
||||
}
|
||||
|
||||
def ticketedreport(String reportsubfolder, String title, LinkedHashMap<String, TicketedReportRecord> ticketed, boolean iscomponent = true) {
|
||||
dir(reportsubfolder) {
|
||||
def String ticketedlist = "${title}\nTicketed list:\n"
|
||||
def ticketedsorted = ticketed.sort()
|
||||
for (aticketed in ticketedsorted) {
|
||||
def TicketedReportRecord r = aticketed.value
|
||||
ticketedlist += "${r.jiraticket} (${r.ticketURI}):\n"
|
||||
def commentscollection = r.commentscollection
|
||||
def sortedcommentscollection = commentscollection.sort()
|
||||
for (commentrecord in sortedcommentscollection) {
|
||||
def CommentsRecord c = commentrecord.value
|
||||
ticketedlist += "${c.comment} (${c.duplicates})\n"
|
||||
}
|
||||
ticketedlist += "\n"
|
||||
}
|
||||
writeFile(file: "ticketedlist.txt", text: ticketedlist)
|
||||
}
|
||||
}
|
||||
|
||||
class UnticketedReportRecord {
|
||||
String comment
|
||||
int duplicates
|
||||
|
||||
UnticketedReportRecord() {
|
||||
comment = ''
|
||||
duplicates = 0
|
||||
}
|
||||
}
|
||||
|
||||
def unticketedreport(String reportsubfolder, String title, LinkedHashMap<String, UnticketedReportRecord> unticketed, boolean iscomponent = true) {
|
||||
dir(reportsubfolder) {
|
||||
def String unticketedlist = "${title}\nUnticketed list:\n"
|
||||
def unticketedsorted = unticketed.sort()
|
||||
for (anunticketed in unticketedsorted) {
|
||||
UnticketedReportRecord u = anunticketed.value
|
||||
unticketedlist += "${u.comment} (${u.duplicates})\n"
|
||||
}
|
||||
writeFile(file: "unticketedlist.txt", text: unticketedlist)
|
||||
}
|
||||
}
|
||||
|
||||
class TicketsReportRecord {
|
||||
String jiraticket
|
||||
String ticketURI
|
||||
int duplicates
|
||||
|
||||
TicketsReportRecord() {
|
||||
jiraticket = ''
|
||||
ticketURI = ''
|
||||
duplicates = 0
|
||||
}
|
||||
}
|
||||
|
||||
def ticketsreport(String reportsubfolder, String title, tickets, boolean iscomponent = true) {
|
||||
dir(reportsubfolder) {
|
||||
String ticketlist = "${title}\nTicket list:\n"
|
||||
ticketssorted = tickets.sort()
|
||||
for (ticketnumber in ticketssorted) {
|
||||
TicketsReportRecord t = ticketnumber.value
|
||||
ticketlist += "${t.jiraticket} (${t.ticketURI}) (${t.duplicates})\n"
|
||||
}
|
||||
writeFile(file: "ticketlist.txt", text: ticketlist)
|
||||
}
|
||||
}
|
||||
|
||||
def differencerecordsreport(String reportsubfolder, String title, differencerecords, boolean iscomponent = true) {
|
||||
dir(reportsubfolder) {
|
||||
String recordlist = "${title}\n"
|
||||
for (dr in differencerecords) {
|
||||
recordlist += dr.dump() + "\n\n"
|
||||
}
|
||||
writeFile(file: "recordlist.txt", text: recordlist)
|
||||
}
|
||||
}
|
||||
|
||||
def boolean report(meta, title, differencerecords, boolean iscomponent = true) {
|
||||
def Map ticketed = [:]
|
||||
def Map squashes = [:]
|
||||
def Map merges = [:]
|
||||
def Map reverts = [:]
|
||||
def Map unticketed = [:]
|
||||
def Map tickets = [:]
|
||||
|
||||
for (dr in differencerecords) {
|
||||
if (dr.type == "Squash") {
|
||||
def SquashReportRecord s
|
||||
if (!squashes.containsKey(dr.mergeinfo)) {
|
||||
s = new SquashReportRecord()
|
||||
s.comment = dr.squashinfo
|
||||
s.duplicates = 1
|
||||
} else {
|
||||
s = squashes[dr.squashinfo]
|
||||
s.duplicates += 1
|
||||
}
|
||||
squashes[dr.squashinfo] = s
|
||||
}
|
||||
if (dr.type == "Merge") {
|
||||
def MergeReportRecord m
|
||||
if (!merges.containsKey(dr.mergeinfo)) {
|
||||
m = new MergeReportRecord()
|
||||
m.comment = dr.mergeinfo
|
||||
m.duplicates = 1
|
||||
} else {
|
||||
m = merges[dr.mergeinfo]
|
||||
m.duplicates += 1
|
||||
}
|
||||
merges[dr.mergeinfo] = m
|
||||
}
|
||||
if (dr.type == "Revert") {
|
||||
def RevertsReportRecord r
|
||||
for (ticket in dr.jiraticketinfo) {
|
||||
JiraTicketInfo j = ticket
|
||||
if (!reverts.containsKey(j.jiranumber)) {
|
||||
r = new RevertsReportRecord()
|
||||
r.jiraticket = j.jiranumber
|
||||
r.ticketURI = j.uri
|
||||
CommentsRecord c = new CommentsRecord()
|
||||
c.comment = dr.comment
|
||||
c.duplicates = 1
|
||||
r.commentscollection[dr.comment] = c
|
||||
} else {
|
||||
r = reverts[j.jiranumber]
|
||||
def CommentsRecord c
|
||||
if (!r.commentscollection.containsKey(dr.comment)) {
|
||||
c = new CommentsRecord()
|
||||
c.comment = dr.comment
|
||||
c.duplicates = 1
|
||||
r.commentscollection[dr.comment] = c
|
||||
} else {
|
||||
c = r.commentscollection[dr.comment]
|
||||
c.duplicates += 1
|
||||
}
|
||||
r.commentscollection[dr.comment] = c
|
||||
}
|
||||
reverts[j.jiranumber] = r
|
||||
def TicketsReportRecord t
|
||||
if (!tickets.containsKey(j.jiranumber)) {
|
||||
t = new TicketsReportRecord()
|
||||
t.jiraticket = j.jiranumber
|
||||
t.ticketURI = j.uri
|
||||
t.duplicates = 1
|
||||
} else {
|
||||
t = tickets[j.jiranumber]
|
||||
t.duplicates += 1
|
||||
}
|
||||
tickets[j.jiranumber] = t
|
||||
}
|
||||
}
|
||||
if (dr.type == "Ticketed") {
|
||||
def TicketedReportRecord t
|
||||
for (ticket in dr.jiraticketinfo) {
|
||||
JiraTicketInfo j = ticket
|
||||
if (!ticketed.containsKey(j.jiranumber)) {
|
||||
t = new TicketedReportRecord()
|
||||
t.jiraticket = j.jiranumber
|
||||
t.ticketURI = j.uri
|
||||
CommentsRecord c = new CommentsRecord()
|
||||
c.comment = dr.comment
|
||||
c.duplicates = 1
|
||||
t.commentscollection[dr.comment] = c
|
||||
} else {
|
||||
t = ticketed[j.jiranumber]
|
||||
def CommentsRecord c
|
||||
if (!t.commentscollection.containsKey(dr.comment)) {
|
||||
c = new CommentsRecord()
|
||||
c.comment = dr.comment
|
||||
c.duplicates = 1
|
||||
t.commentscollection[dr.comment] = c
|
||||
} else {
|
||||
c = t.commentscollection[dr.comment]
|
||||
c.duplicates += 1
|
||||
}
|
||||
t.commentscollection[dr.comment] = c
|
||||
}
|
||||
ticketed[j.jiranumber] = t
|
||||
def TicketsReportRecord ti
|
||||
if (!tickets.containsKey(j.jiranumber)) {
|
||||
ti = new TicketsReportRecord()
|
||||
ti.jiraticket = j.jiranumber
|
||||
ti.ticketURI = j.uri
|
||||
ti.duplicates = 1
|
||||
} else {
|
||||
ti = tickets[j.jiranumber]
|
||||
ti.duplicates += 1
|
||||
}
|
||||
tickets[j.jiranumber] = ti
|
||||
}
|
||||
}
|
||||
if (dr.type == "Unticketed") {
|
||||
UnticketedReportRecord u
|
||||
if (!unticketed.containsKey(dr.comment)) {
|
||||
u = new UnticketedReportRecord()
|
||||
u.comment = dr.comment
|
||||
u.duplicates = 1
|
||||
} else {
|
||||
u = unticketed[dr.comment]
|
||||
u.duplicates += 1
|
||||
}
|
||||
unticketed[dr.comment] = u
|
||||
}
|
||||
}
|
||||
String reportsubfolder = ""
|
||||
if (iscomponent) {
|
||||
reportsubfolder = "${reportfolder}/${meta.componentidentifier()}"
|
||||
} else {
|
||||
reportsubfolder = "${reportfolder}/Combined"
|
||||
}
|
||||
mergereport(reportsubfolder, title, merges, iscomponent)
|
||||
squashreport(reportsubfolder, title, squashes, iscomponent)
|
||||
revertsreport(reportsubfolder, title, reverts, iscomponent)
|
||||
ticketedreport(reportsubfolder, title, ticketed, iscomponent)
|
||||
unticketedreport(reportsubfolder, title, unticketed, iscomponent)
|
||||
ticketsreport(reportsubfolder, title, tickets, iscomponent)
|
||||
differencerecordsreport(reportsubfolder, title, differencerecords, iscomponent)
|
||||
}
|
||||
|
||||
def title(earlymeta, latermeta) {
|
||||
return """
|
||||
Differences in:
|
||||
Product: ${earlymeta.productinfo.productname} Subcomponent: ${earlymeta.productinfo.subcomponentname}
|
||||
between:
|
||||
then:
|
||||
Build date: ${earlymeta.jenkinsbuildinfo.builddate} Build stamp: ${earlymeta.buildstampinfo.buildstamp} Git revision: ${earlymeta.gitinfo.gitrevision}
|
||||
now:
|
||||
Build date: ${latermeta.jenkinsbuildinfo.builddate} Build stamp: ${latermeta.buildstampinfo.buildstamp} Git revision: ${latermeta.gitinfo.gitrevision}
|
||||
"""
|
||||
}
|
||||
|
||||
def compare(earlymetaitems, latermetaitems, key) {
|
||||
boolean result = true;
|
||||
echo "Collecting changes between early and later versions of component: ${key}"
|
||||
|
||||
def earlymeta = earlymetaitems[key].metainfo
|
||||
def latermeta = latermetaitems[key].metainfo
|
||||
|
||||
summaryappend("${earlymeta.productinfo.productname} ${earlymeta.productinfo.subcomponentname}: Changed: ")
|
||||
|
||||
def boolean repoavailable
|
||||
def String uniquefolderforsourcerepo
|
||||
(repoavailable, uniquefolderforsourcerepo) = getcomponent(earlymeta)
|
||||
|
||||
List differencerecords = []
|
||||
if (repoavailable) {
|
||||
(result, differencerecords) = getdifferencerecords(earlymeta, latermeta, uniquefolderforsourcerepo)
|
||||
|
||||
summaryappend(" Items: ${differencerecords.size()} ")
|
||||
report(earlymeta, title(earlymeta, latermeta), differencerecords)
|
||||
} else {
|
||||
summaryappend(" No source repo ")
|
||||
}
|
||||
summaryappend("\n")
|
||||
|
||||
return [result, differencerecords];
|
||||
}
|
||||
|
||||
def comparehierarchy(meta, String earlymetafolder, String latermetafolder, String maxdepth, String summaryfolder) {
|
||||
def List differencerecords = []
|
||||
|
||||
def int md = maxdepth.toInteger()
|
||||
resetfolders()
|
||||
preconditions()
|
||||
|
||||
echo "Comparing product meta hierarchy from folders: ${earlymetafolder} and ${latermetafolder} to a depth of ${md}. Exporting summary to ${summaryfolder}"
|
||||
|
||||
def earlymeta = meta.importrelated(true, earlymetafolder)
|
||||
def latermeta = meta.importrelated(true, latermetafolder)
|
||||
|
||||
def earlymetaitems = earlymeta.releasewalkerunique(md, '', earlymetafolder)
|
||||
def latermetaitems = latermeta.releasewalkerunique(md, '', latermetafolder)
|
||||
|
||||
echo "Early items:"
|
||||
showmetaitems(earlymetaitems)
|
||||
|
||||
echo "Later items:"
|
||||
showmetaitems(latermetaitems)
|
||||
|
||||
for (key in earlymetaitems.keySet()) {
|
||||
if (latermetaitems.containsKey(key)) {
|
||||
(result, componentdifferencerecords) = compare(earlymetaitems, latermetaitems, key)
|
||||
differencerecords = differencerecords + componentdifferencerecords
|
||||
} else {
|
||||
summaryappend("${earlymeta.productinfo.productname} ${earlymeta.productinfo.subcomponentname}: ")
|
||||
deletedcomponent(earlymetaitems, key)
|
||||
summaryappend("\n")
|
||||
}
|
||||
}
|
||||
for (key in latermetaitems.keySet()) {
|
||||
if (!earlymetaitems.containsKey(key)) {
|
||||
summaryappend("${latermeta.productinfo.productname} ${latermeta.productinfo.subcomponentname}: ")
|
||||
addedcomponent(latermetaitems, key)
|
||||
summaryappend("\n")
|
||||
}
|
||||
}
|
||||
report(meta, title(earlymeta, latermeta), differencerecords, false)
|
||||
return [summarystring, markunstable, unstablereason]
|
||||
}
|
||||
|
||||
return this;
|
||||
24
Common_scripts/differences/file.groovy
Normal file
24
Common_scripts/differences/file.groovy
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
def comparefiles(importedfile, currentfile, boolean ignorewhitespace = true) {
|
||||
echo "Comparing file: ${importedfile} with: ${currentfile} option: ${ignorewhitespace}"
|
||||
def wsparameter = "-w"
|
||||
if (!ignorewhitespace) {
|
||||
wsparameter = ""
|
||||
}
|
||||
if (isUnix()) {
|
||||
sh """
|
||||
diff -c ${wsparameter} "${importedfile}" "${currentfile}"
|
||||
"""
|
||||
}
|
||||
else {
|
||||
// diffutils can be installed on windows with chocolatey
|
||||
powershell """
|
||||
# echo Checking utilities exist
|
||||
# where diff
|
||||
# if errorlevel 1 EXIT /b 1
|
||||
|
||||
diff.exe -c ${wsparameter} "${importedfile}" "${currentfile}"
|
||||
"""
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
51
Common_scripts/differences/json.groovy
Normal file
51
Common_scripts/differences/json.groovy
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
def comparefiles(importedjsonfile, currentjsonfile) {
|
||||
echo "Comparing json file: ${importedjsonfile} with: ${currentjsonfile}"
|
||||
if (isUnix()) {
|
||||
sh """
|
||||
which jq
|
||||
if [ \$? -ne 0 ]; then exit 1; fi
|
||||
# jq -S sorts json output
|
||||
diff -c <(jq -S . "${importedjsonfile}") <(jq -S . "${currentjsonfile}")
|
||||
"""
|
||||
}
|
||||
else {
|
||||
// Jq and diffutils can be installed on windows with chocolatey
|
||||
powershell """
|
||||
# echo Checking utilities exist
|
||||
# set
|
||||
# echo %PATH%
|
||||
try {
|
||||
if (Get-Command jq) {}
|
||||
}
|
||||
catch {
|
||||
echo "jq is unavailable"
|
||||
exit \$false
|
||||
}
|
||||
try {
|
||||
if (Get-Command diff) {}
|
||||
}
|
||||
catch {
|
||||
echo "diff is unavailable"
|
||||
exit \$false
|
||||
}
|
||||
|
||||
# echo Sorting json in files to compare
|
||||
# jq -S sorts json output
|
||||
jq -S . "${importedjsonfile}" > temp1.txt
|
||||
if (\$lastexitcode -ge 1) { exit 1 }
|
||||
jq -S . "${currentjsonfile}" > temp2.txt
|
||||
if (\$lastexitcode -ge 1) { exit 1 }
|
||||
|
||||
# echo Diffing sorted json files
|
||||
diff.exe -c temp1.txt temp2.txt
|
||||
\$lec = \$lastexitcode
|
||||
|
||||
Remove-Item temp1.txt
|
||||
Remove-Item temp2.txt
|
||||
|
||||
if (\$lec -ge 1) { exit 1 }
|
||||
"""
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
102
Common_scripts/differences/metahierarchy.groovy
Normal file
102
Common_scripts/differences/metahierarchy.groovy
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
pipeline {
|
||||
agent { label AGENT_LABEL }
|
||||
stages {
|
||||
stage('Initial setup') {
|
||||
steps {
|
||||
script {
|
||||
autobuilderscript = load("${WORKSPACE}/autobuild/Common_scripts/autobuilder.groovy")
|
||||
meta = autobuilderscript.startnonbuild(this)
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Clean exports') {
|
||||
steps {
|
||||
script {
|
||||
SUMMARYDIR = "${WORKSPACE}/summary"
|
||||
REPORTDIR = "${WORKSPACE}/reports"
|
||||
EARLYROOTDIR = 'early'
|
||||
EARLYDIR = "${WORKSPACE}/${EARLYROOTDIR}"
|
||||
LATERROOTDIR = 'later'
|
||||
LATERDIR = "${WORKSPACE}/${LATERROOTDIR}"
|
||||
|
||||
cleanfolders = [
|
||||
"${WORKSPACE}/build_artifacts",
|
||||
"${EARLYDIR}",
|
||||
"${LATERDIR}",
|
||||
"${SUMMARYDIR}",
|
||||
"${REPORTDIR}",
|
||||
]
|
||||
cleaner = load("${autobuilder.commonscripts()}/clean/clean.groovy")
|
||||
cleaner.clean(cleanfolders)
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Obtain top level meta') {
|
||||
steps {
|
||||
script {
|
||||
importer = load("${autobuilder.commonscripts()}/import/importer.groovy")
|
||||
|
||||
SOURCEURL = TOP_LEVEL_META_REPOSITORY.trim()
|
||||
|
||||
def earlyimportoptions = importer.getNewImportOptions()
|
||||
earlyimportoptions.source(EARLY_SOURCE, EARLY_BUILD_JOB, EARLY_BUILD_SELECTOR, SOURCEURL, RELEASE_EARLY_REVISION)
|
||||
earlyimportoptions.setincrementversionnumber(false)
|
||||
earlyimportoptions.setfilter('meta/**')
|
||||
importer.artifactimport(meta, earlyimportoptions, EARLYROOTDIR)
|
||||
|
||||
def laterimportoptions = importer.getNewImportOptions()
|
||||
laterimportoptions.source(LATER_SOURCE, LATER_BUILD_JOB, LATER_BUILD_SELECTOR, SOURCEURL, RELEASE_LATER_REVISION)
|
||||
laterimportoptions.setincrementversionnumber(false)
|
||||
laterimportoptions.setfilter('meta/**')
|
||||
importer.artifactimport(meta, laterimportoptions, LATERROOTDIR)
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Diff components') {
|
||||
steps {
|
||||
script {
|
||||
def comparator = load("${autobuilder.commonscripts()}/differences/dometahierarchy.groovy")
|
||||
(summarystring, markunstable, unstablereason) = comparator.comparehierarchy(meta, EARLYDIR, LATERDIR, MAX_META_DEPTH, SUMMARYDIR)
|
||||
if (markunstable) {
|
||||
env.unstablereason = unstablereason
|
||||
currentBuild.result = 'UNSTABLE'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Archiving artifacts') {
|
||||
steps {
|
||||
script {
|
||||
def artifactlist = meta.generateartifacts()
|
||||
artifactarchiver = load("${autobuilder.commonscripts()}/artifacts/archiver.groovy")
|
||||
artifactarchiver.archive("summary/**,reports/**,${artifactlist}")
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Summarise') {
|
||||
steps {
|
||||
script {
|
||||
echo "Summary:\n${summarystring}\n"
|
||||
if (env.unstablereason) {
|
||||
echo "Instability reason: ${env.unstablereason}"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
post {
|
||||
always {
|
||||
echo 'Post-build'
|
||||
}
|
||||
failure {
|
||||
echo 'Failed build'
|
||||
}
|
||||
unstable {
|
||||
echo 'Unstable build'
|
||||
}
|
||||
success {
|
||||
echo 'Succeeded build'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
80
Common_scripts/documentation/doxygen_deploy.groovy
Normal file
80
Common_scripts/documentation/doxygen_deploy.groovy
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
pipeline {
|
||||
agent { label AGENT_LABEL }
|
||||
stages {
|
||||
stage('Initial setup') {
|
||||
steps {
|
||||
script {
|
||||
meta = load("${WORKSPACE}/autobuild/Common_scripts/autobuilder.groovy").startnonbuild(this)
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Clean imports') {
|
||||
steps {
|
||||
script {
|
||||
env.DOXYGEN = "doxygen"
|
||||
cleanfolders = [
|
||||
DOXYGEN,
|
||||
]
|
||||
cleaner = load("${autobuilder.commonscripts()}/clean/clean.groovy")
|
||||
cleaner.clean(cleanfolders)
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Import doxygen artifacts') {
|
||||
steps {
|
||||
script {
|
||||
importer = load("${autobuilder.commonscripts()}/import/importer.groovy")
|
||||
def importoptions = importer.getNewImportOptions()
|
||||
|
||||
importoptions.jenkinsjob(BUILD_JOB_WITH_DOXYGEN_ARTIFACTS, BUILD_JOB_WITH_DOXYGEN_ARTIFACTS_SELECTOR)
|
||||
importoptions.setfilter(ARTIFACT_PATH_TO_DOXYGEN_ROOT + '/**')
|
||||
doxygenmeta = importer.artifactimportfrombuildjob(meta, importoptions, DOXYGEN)
|
||||
|
||||
productname = doxygenmeta.productinfo.productname
|
||||
buildstampprefix = doxygenmeta.buildstampinfo.buildstampprefix
|
||||
|
||||
echo "Doyxgen imported for product: ${productname} and build stamp prefix: ${buildstampprefix}"
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Copy doxygen to server') {
|
||||
steps {
|
||||
script {
|
||||
doxygensource = "${DOXYGEN}/${ARTIFACT_PATH_TO_DOXYGEN_ROOT}"
|
||||
pathonserver = "${ROOT_PATH_ON_SERVER.trim()}/${productname}/${buildstampprefix}"
|
||||
echo "Copying from ${doxygensource} to ${pathonserver}"
|
||||
if (isUnix()) {
|
||||
sh """#!/bin/bash
|
||||
rm -rfv "${pathonserver}"
|
||||
if [ \$? -ne 0 ]; then exit 1; fi
|
||||
|
||||
mkdir -pv "${pathonserver}"
|
||||
if [ \$? -ne 0 ]; then exit 1; fi
|
||||
|
||||
echo mv -v "${doxygensource}"/ "${pathonserver}"
|
||||
mv -v "${doxygensource}"/ "${pathonserver}"
|
||||
if [ \$? -ne 0 ]; then exit 1; fi
|
||||
"""
|
||||
} else {
|
||||
error("This job does not run on Windows at the moment")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
post {
|
||||
always {
|
||||
echo 'Post-build'
|
||||
}
|
||||
failure {
|
||||
echo 'Failed build'
|
||||
}
|
||||
unstable {
|
||||
echo 'Unstable build'
|
||||
}
|
||||
success {
|
||||
echo 'Succeeded build'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
80
Common_scripts/hardware/sominfo.groovy
Normal file
80
Common_scripts/hardware/sominfo.groovy
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
def sominfostore = null
|
||||
|
||||
/* Example expected JSON
|
||||
{
|
||||
"SomType": {
|
||||
"Som_BA4": {
|
||||
"Artifact info": {
|
||||
"Location": "Jenkins job artifact",
|
||||
"Job": "HMB_FD_HV_0.9.6/0.9.6_SG1024_EL_syn_ba4",
|
||||
"Job selector": "<stable>true</stable>",
|
||||
"Release repo": "git@hydra:hmb_fd_hv-releases/sg1024/hmb_fd_hv_logic_ba4.git",
|
||||
"Release repo revision": ""
|
||||
}
|
||||
},
|
||||
"Som_FC5": {
|
||||
"Artifact info": {
|
||||
"Location": "Jenkins job artifact",
|
||||
"Job": "HMB_FD_HV_0.9.6/0.9.6_SG1024_EL_syn_fc5",
|
||||
"Job selector": "<stable>true</stable>",
|
||||
"Release repo": "git@hydra:hmb_fd_hv-releases/sg1024/hmb_fd_hv_logic_fc5.git",
|
||||
"Release repo revision": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
def String asJsonText() {
|
||||
return writeJSON(returnText: true, json: sominfostore, pretty: 1)
|
||||
}
|
||||
|
||||
def boolean exists() {
|
||||
return (sominfostore != null)
|
||||
}
|
||||
|
||||
def set(String jsontext) {
|
||||
sominfostore = readJSON(text: jsontext)
|
||||
echo "Som support info:\n${asJsonText()}"
|
||||
}
|
||||
|
||||
def get() {
|
||||
return sominfostore
|
||||
}
|
||||
|
||||
def somtypes() {
|
||||
return sominfostore['SomType']
|
||||
}
|
||||
|
||||
def artifactinfo(somtype) {
|
||||
return somtype['Artifact info']
|
||||
}
|
||||
|
||||
def artifactlocation(artifactinfo) {
|
||||
return artifactinfo['Location']
|
||||
}
|
||||
|
||||
def boolean isjoblocation(artifactinfo) {
|
||||
return (artifactinfo['Location'] == 'Jenkins job artifact' ||
|
||||
artifactinfo['Location'] == 'Jenkins job artefact')
|
||||
}
|
||||
|
||||
def boolean isreleaserepolocation(artifactinfo) {
|
||||
return artifactinfo['Location'] == 'Release repository'
|
||||
}
|
||||
|
||||
def artifactjob(artifactinfo) {
|
||||
return [
|
||||
"name": artifactinfo['Job'],
|
||||
"selector": "<StatusBuildSelector plugin=\"copyartifact@1.46.2\">${artifactinfo['Job selector']}</StatusBuildSelector>"
|
||||
]
|
||||
}
|
||||
|
||||
def releaserepo(artifactinfo) {
|
||||
return [
|
||||
"repo": artifactinfo['Release repo'],
|
||||
"revision": artifactinfo['Release repo revision']
|
||||
]
|
||||
}
|
||||
|
||||
return this
|
||||
377
Common_scripts/import/importer.groovy
Normal file
377
Common_scripts/import/importer.groovy
Normal file
|
|
@ -0,0 +1,377 @@
|
|||
gh = load("${autobuilder.commonscripts()}/versioncontrol/git.groovy")
|
||||
versiongenerator = load("${autobuilder.commonscripts()}/versionnumbering/generate.groovy")
|
||||
|
||||
class ImportOptions {
|
||||
def m_script // Script to use if wanting to execute script commands (eg. echo -> script.echo)
|
||||
|
||||
boolean m_incrementversionnumber // If true, increment the parent's (4th) version number with the (4th) version number of this object being imported
|
||||
String m_filter // Only import files/paths/folders that match the filter
|
||||
String m_excludes // Exclude files/paths/folders that match the exclude filter
|
||||
boolean m_fingerprint // Do Jenkins fingerprinting on imported artifacts
|
||||
boolean m_nested // Import all child artifacts too (identified in the related meta info
|
||||
boolean m_flatten // Flatten files and folders imported
|
||||
boolean m_includemetainfilter // Make sure meta is also included in filter
|
||||
boolean m_clean // Clean import folder before obtaining artifacts
|
||||
boolean m_appendtoparentmeta // Append to parent meta
|
||||
String m_sourceselect // Where are the artifacts coming from
|
||||
|
||||
String m_jobname
|
||||
def m_buildnumberorselector
|
||||
|
||||
String m_repo
|
||||
String m_revision
|
||||
|
||||
ImportOptions(script,
|
||||
String sourceselect = 'Jenkins job artifact',
|
||||
boolean incrementversionnumber = true,
|
||||
String filter = '',
|
||||
String excludes = '',
|
||||
boolean fingerprint = false,
|
||||
boolean nested = false,
|
||||
boolean flatten = false,
|
||||
boolean includemetainfilter = true,
|
||||
boolean clean = true,
|
||||
appendtoparentmeta = true) {
|
||||
m_script = script
|
||||
m_sourceselect = sourceselect.trim()
|
||||
m_incrementversionnumber = incrementversionnumber
|
||||
m_filter = filter.trim()
|
||||
m_excludes = excludes.trim()
|
||||
m_fingerprint = fingerprint
|
||||
m_nested = nested
|
||||
m_flatten = flatten
|
||||
m_includemetainfilter = includemetainfilter
|
||||
m_clean = clean
|
||||
m_appendtoparentmeta = appendtoparentmeta
|
||||
}
|
||||
|
||||
void setsourceselect(String sourceselect) {
|
||||
sourceselect = sourceselect.trim()
|
||||
switch (sourceselect) {
|
||||
case 'Jenkins job artefact':
|
||||
m_sourceselect = 'Jenkins job artifact'
|
||||
break
|
||||
case 'Jenkins job artifact':
|
||||
case 'Release repository':
|
||||
m_sourceselect = sourceselect
|
||||
break
|
||||
default:
|
||||
m_script.error("Unknown type of artifact source select: ${sourceselect}")
|
||||
}
|
||||
}
|
||||
|
||||
void setincrementversionnumber(boolean incrementversionnumber = true) {
|
||||
m_incrementversionnumber = incrementversionnumber
|
||||
}
|
||||
|
||||
void setfilter(String filter) {
|
||||
m_filter = filter.trim()
|
||||
}
|
||||
|
||||
void setexcludes(String excludes) {
|
||||
m_excludes = excludes.trim()
|
||||
}
|
||||
|
||||
void setfingerprint(boolean fingerprint = true) {
|
||||
m_fingerprint = fingerprint
|
||||
}
|
||||
|
||||
void setnested(boolean nested = true) {
|
||||
m_nested = nested
|
||||
}
|
||||
|
||||
void flattenimports(boolean flatten = true) {
|
||||
m_flatten = flatten
|
||||
}
|
||||
|
||||
void includemetainfilter(boolean includemetainfilter = true) {
|
||||
m_includemetainfilter = includemetainfilter
|
||||
}
|
||||
|
||||
void clean(boolean clean = true) {
|
||||
m_clean = clean
|
||||
}
|
||||
|
||||
void setappendtoparentmeta(boolean appendtoparentmeta) {
|
||||
m_appendtoparentmeta = appendtoparentmeta
|
||||
}
|
||||
|
||||
void jenkinsjob(String jobname, buildnumberorselector) {
|
||||
m_jobname = jobname.trim()
|
||||
m_buildnumberorselector = [
|
||||
$class: 'ParameterizedBuildSelector',
|
||||
parameterName: buildnumberorselector
|
||||
]
|
||||
setsourceselect('Jenkins job artifact')
|
||||
}
|
||||
|
||||
void jenkinsjob(String jobname, int buildnumberorselector) {
|
||||
m_jobname = jobname.trim()
|
||||
m_buildnumberorselector = [
|
||||
$class: 'ParameterizedBuildSelector',
|
||||
parameterName: "<SpecificBuildSelector plugin='copyartifact@1.41'><buildNumber>${buildnumberorselector}</buildNumber></SpecificBuildSelector>"
|
||||
]
|
||||
setsourceselect('Jenkins job artifact')
|
||||
}
|
||||
|
||||
void releaserepo(String repo, String revision) {
|
||||
m_repo = repo.trim()
|
||||
m_revision = revision.trim()
|
||||
setsourceselect('Release repository')
|
||||
}
|
||||
|
||||
void source(String sourceselect, String jobname, String buildnumberorselector, String repo, String revision) {
|
||||
jenkinsjob(jobname, buildnumberorselector)
|
||||
releaserepo(repo, revision)
|
||||
setsourceselect(sourceselect)
|
||||
}
|
||||
}
|
||||
|
||||
ImportOptions getNewImportOptions() {
|
||||
return new ImportOptions(this)
|
||||
}
|
||||
|
||||
def formFilter(ImportOptions importoptions) {
|
||||
def String filter = importoptions.m_filter
|
||||
if (filter != '') {
|
||||
if (importoptions.m_includemetainfilter) {
|
||||
filter = 'meta/**,' + filter
|
||||
}
|
||||
}
|
||||
echo "Import options filter is: ${filter}"
|
||||
return filter
|
||||
}
|
||||
|
||||
def conditionalClean(ImportOptions importoptions, String destpath) {
|
||||
if (importoptions.m_clean) {
|
||||
echo "Cleaning ${destpath}"
|
||||
dir(destpath) {
|
||||
deleteDir()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def artifactimportfrombuildjob(meta, ImportOptions importoptions, String destpath) {
|
||||
if (importoptions.m_sourceselect != 'Jenkins job artifact') {
|
||||
error("Import options settings have not been set for: Jenkins job artifact")
|
||||
return
|
||||
}
|
||||
|
||||
conditionalClean(importoptions, destpath)
|
||||
|
||||
echo "Build selector type: ${importoptions.m_buildnumberorselector.getClass()}"
|
||||
echo "Importing artifacts from job: ${importoptions.m_jobname} selector: ${importoptions.m_buildnumberorselector.toString()}"
|
||||
copyArtifacts(
|
||||
filter: formFilter(importoptions),
|
||||
excludes: importoptions.m_excludes,
|
||||
fingerprintArtifacts: importoptions.m_fingerprint,
|
||||
projectName: importoptions.m_jobname,
|
||||
selector: importoptions.m_buildnumberorselector,
|
||||
flatten: importoptions.m_flatten,
|
||||
target: destpath
|
||||
)
|
||||
def importedmeta = meta.importrelated(importoptions.m_appendtoparentmeta, destpath)
|
||||
if (importoptions.m_incrementversionnumber) {
|
||||
meta.buildstampinfo.changerevision(versiongenerator.incrementrevision(meta.buildstampinfo.revision, importedmeta.buildstampinfo.revision))
|
||||
}
|
||||
return importedmeta
|
||||
}
|
||||
|
||||
def rewritemetafileasreleased(meta, String filepath) {
|
||||
// Modify the meta info to say that is has already been released
|
||||
meta.markreleased()
|
||||
meta.saveJsonSerialised(filepath)
|
||||
}
|
||||
|
||||
def hierarchyartifactimportfromrepo(meta, ImportOptions importoptions, String destpath) {
|
||||
if (importoptions.m_sourceselect != 'Release repository') {
|
||||
error("Import options settings have not been set for: Release repository")
|
||||
return
|
||||
}
|
||||
|
||||
def rooturl = importoptions.m_repo
|
||||
def rootrevision = importoptions.m_revision
|
||||
echo "Cloning root release repo: ${rooturl}, revision: ${rootrevision} at folder: ${destpath}"
|
||||
|
||||
conditionalClean(importoptions, destpath)
|
||||
|
||||
def ArrayList<String> sparseitemlist = gh.convertSparseItemsString(formFilter(importoptions))
|
||||
gh.gitCheckoutAlt(rooturl, rootrevision, destpath, "", 1, true, sparseitemlist)
|
||||
|
||||
def importedmeta = meta.importrelated(importoptions.m_appendtoparentmeta, destpath, rooturl, rootrevision, gh.getGitInfo(destpath))
|
||||
|
||||
echo "Getting associated metadata from path: ${destpath}"
|
||||
def collectedmetalist = importedmeta.getassociated(destpath)
|
||||
for(def collectedmeta in collectedmetalist) {
|
||||
echo "Collection meta item: ${collectedmeta.metainfo.componentversionuniqueidentifier()} offset path: ${collectedmeta.accumulatedpath}"
|
||||
}
|
||||
|
||||
echo "Cloning associated repos inside path: ${destpath}"
|
||||
for(def collectedmeta in collectedmetalist) {
|
||||
def relatedmeta = collectedmeta.metainfo
|
||||
def relatedoffsetpath = collectedmeta.accumulatedpath
|
||||
def cloneurl = relatedmeta.releaseinfo.releaserepoURL
|
||||
def clonerevision = "refs/tags/${relatedmeta.releasetag()}"
|
||||
def clonepath = "${destpath}/${relatedoffsetpath}"
|
||||
echo "Cloning release repo: ${cloneurl}, revision: ${clonerevision} at folder: ${clonepath}"
|
||||
|
||||
gh.gitCheckoutAlt(cloneurl, clonerevision, clonepath, "", 1, true, [])
|
||||
|
||||
gh.stripgithistory(clonepath)
|
||||
|
||||
def metafilepath = "${clonepath}${relatedmeta.metafilepath()}"
|
||||
echo "Marking related meta as released and rewriting meta file: ${metafilepath}"
|
||||
rewritemetafileasreleased(relatedmeta, metafilepath)
|
||||
}
|
||||
gh.stripgithistory(destpath)
|
||||
def metafilepath = "${destpath}/${meta.metafilepath()}"
|
||||
echo "Marking root meta as released and rewriting meta file: ${metafilepath}"
|
||||
rewritemetafileasreleased(importedmeta, metafilepath)
|
||||
|
||||
if (importoptions.m_incrementversionnumber) {
|
||||
meta.buildstampinfo.changerevision(versiongenerator.incrementrevision(meta.buildstampinfo.revision, importedmeta.buildstampinfo.revision))
|
||||
}
|
||||
return importedmeta
|
||||
}
|
||||
|
||||
def artifactimportfromrepo(meta, ImportOptions importoptions, String destpath) {
|
||||
if (importoptions.m_sourceselect != 'Release repository') {
|
||||
error("Import options settings have not been set for: Release repository")
|
||||
return
|
||||
}
|
||||
|
||||
conditionalClean(importoptions, destpath)
|
||||
|
||||
def rooturl = importoptions.m_repo
|
||||
def rootrevision = importoptions.m_revision
|
||||
echo "Cloning release repo: ${rooturl}, revision: ${rootrevision} at folder: ${destpath}"
|
||||
|
||||
def ArrayList<String> sparseitemlist = gh.convertSparseItemsString(formFilter(importoptions))
|
||||
gh.gitCheckoutAlt(rooturl, rootrevision, destpath, "", 1, true, sparseitemlist)
|
||||
|
||||
def importedmeta = meta.importrelated(importoptions.m_appendtoparentmeta, destpath, rooturl, rootrevision, gh.getGitInfo(destpath))
|
||||
|
||||
gh.stripgithistory(destpath)
|
||||
def metafilepath = "${destpath}/${meta.metafilepath()}"
|
||||
echo "Marking meta as released and rewriting meta file: ${metafilepath}"
|
||||
rewritemetafileasreleased(importedmeta, metafilepath)
|
||||
|
||||
if (importoptions.m_incrementversionnumber) {
|
||||
meta.buildstampinfo.changerevision(versiongenerator.incrementrevision(meta.buildstampinfo.revision, importedmeta.buildstampinfo.revision))
|
||||
}
|
||||
return importedmeta
|
||||
}
|
||||
|
||||
def artifactimport(meta, ImportOptions importoptions, String destpath) {
|
||||
switch (importoptions.m_sourceselect) {
|
||||
case 'Jenkins job artifact':
|
||||
case 'Jenkins job artefact':
|
||||
return artifactimportfrombuildjob(meta, importoptions, destpath)
|
||||
case 'Release repository':
|
||||
if (importoptions.m_nested) {
|
||||
return hierarchyartifactimportfromrepo(meta, importoptions, destpath)
|
||||
}
|
||||
return artifactimportfromrepo(meta, importoptions, destpath)
|
||||
default:
|
||||
error("Unknown type of artifact source: ${source}")
|
||||
}
|
||||
return meta
|
||||
}
|
||||
|
||||
// Deprecated (use above)
|
||||
def artifactimport(meta,
|
||||
String sourceselect,
|
||||
String jenkinsjob,
|
||||
buildnumberorselector,
|
||||
String repo,
|
||||
String revision,
|
||||
String destpath,
|
||||
boolean incrementversionnumber = true,
|
||||
String filter = '',
|
||||
String excludes = '',
|
||||
boolean fingerprint = false,
|
||||
boolean nested = false) {
|
||||
echo "DEPRECATED method: artifactimport(meta, String source, String jenkinsjob, buildnumberorselector, String repo, String revision, String destpath ...)"
|
||||
def importoptions = importer.getNewImportOptions()
|
||||
|
||||
importoptions.source(sourceselect, jenkinsjob, buildnumberorselector, repo, revision)
|
||||
importoptions.setincrementversionnumber(incrementversionnumber)
|
||||
importoptions.setfilter(filter)
|
||||
importoptions.setexcludes(excludes)
|
||||
importoptions.setfingerprint(fingerprint)
|
||||
importoptions.setnested(nested)
|
||||
|
||||
return artifactimport(meta, importoptions, destpath)
|
||||
}
|
||||
|
||||
// Deprecated (use above)
|
||||
def artifactimport(meta,
|
||||
String buildjob,
|
||||
int buildnumber,
|
||||
String destpath,
|
||||
boolean incrementversionnumber = true,
|
||||
String filter = '**',
|
||||
String excludes = '',
|
||||
boolean fingerprint = false) {
|
||||
echo "DEPRECATED method: artifactimport(meta, String buildjob, int buildnumber, String destpath, ...)"
|
||||
def importoptions = importer.getNewImportOptions()
|
||||
|
||||
importoptions.jenkinsjob(buildjob, "<SpecificBuildSelector plugin='copyartifact@1.41'> <buildNumber>${buildnumber}</buildNumber></SpecificBuildSelector>")
|
||||
importoptions.setincrementversionnumber(incrementversionnumber)
|
||||
importoptions.setfilter(filter)
|
||||
importoptions.setexcludes(excludes)
|
||||
importoptions.setfingerprint(fingerprint)
|
||||
|
||||
return artifactimport(meta, importoptions, destpath)
|
||||
}
|
||||
|
||||
// Deprecated (use above)
|
||||
def artifactimport(meta,
|
||||
String buildjob,
|
||||
buildnumberorselector,
|
||||
String destpath,
|
||||
boolean incrementversionnumber = true,
|
||||
String filter = '',
|
||||
String excludes = '',
|
||||
boolean fingerprint = false) {
|
||||
echo "DEPRECATED method: artifactimport(meta, String buildjob, buildnumberorselector, String destpath, ...)"
|
||||
def importoptions = importer.getNewImportOptions()
|
||||
|
||||
importoptions.jenkinsjob(buildjob, buildnumberorselector)
|
||||
importoptions.setincrementversionnumber(incrementversionnumber)
|
||||
importoptions.setfilter(filter)
|
||||
importoptions.setexcludes(excludes)
|
||||
importoptions.setfingerprint(fingerprint)
|
||||
|
||||
return artifactimport(meta, importoptions, destpath)
|
||||
}
|
||||
|
||||
// Import the artifacts of a named child component found below parent meta's hierarchy
|
||||
def artifactimport(meta,
|
||||
parentmeta,
|
||||
String parentmetapath,
|
||||
String childproduct,
|
||||
String childsubcomponent,
|
||||
ImportOptions importoptions,
|
||||
String destinationfolder) {
|
||||
// Import from parent meta
|
||||
def childmeta = meta.getNewMetaObject()
|
||||
def childmeta2
|
||||
echo "Finding meta associated with child: Product: ${childproduct} Sub-component: ${childsubcomponent}"
|
||||
echo "From parent meta identifier: ${parentmeta.componentidentifier()} and parent meta path: ${parentmetapath}"
|
||||
def findresults = parentmeta.findAssociatedMeta(parentmetapath, childproduct, childsubcomponent)
|
||||
if (findresults.matchfound) {
|
||||
childmeta = findresults.matchedmetaitem.metainfo
|
||||
if (importoptions.m_sourceselect == 'Release repository' || childmeta.releaseinfo.released) {
|
||||
importoptions.releaserepo(childmeta.releaseinfo.releaserepoURL, childmeta.releasetag())
|
||||
} else {
|
||||
importoptions.jenkinsjob(childmeta.jenkinsbuildinfo.buildjobname, childmeta.jenkinsbuildinfo.buildnumber)
|
||||
}
|
||||
childmeta2 = importer.artifactimport(meta, importoptions, destinationfolder)
|
||||
} else {
|
||||
error("Could not find meta associated with child: Product: ${childproduct} Sub-component: ${childsubcomponent}")
|
||||
}
|
||||
return childmeta2
|
||||
}
|
||||
|
||||
return this;
|
||||
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;
|
||||
1193
Common_scripts/meta/folder.groovy
Normal file
1193
Common_scripts/meta/folder.groovy
Normal file
File diff suppressed because it is too large
Load diff
111
Common_scripts/packaging/debian.groovy
Normal file
111
Common_scripts/packaging/debian.groovy
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
class DebRootDefinition {
|
||||
String ROOTPATH
|
||||
String PACKAGE_PREFIX
|
||||
String PACKAGE_FOLDER_NAME
|
||||
String PACKAGE_NAME
|
||||
String UNIQUE_PACKAGE_NAME
|
||||
|
||||
String PACKAGE_SOURCE_ROOT
|
||||
String PACKAGE_SOURCE_FOLDER_NAME
|
||||
String DEBPATH
|
||||
|
||||
String ETC
|
||||
String GIS_OPT_BIN
|
||||
String GIS_OPT_LIB
|
||||
String GIS_OPT_SCRIPTS_APP
|
||||
String GIS_OPT_SCRIPTS_EL
|
||||
String GIS_OPT_SCRIPTS_CONTROL
|
||||
String GIS_OPT_WWW
|
||||
String GIS_OPT_OTHER
|
||||
String GIS_OPT_KERNEL
|
||||
String GIS_OPT_LOGIC
|
||||
String GIS_OPT_PRINTHEAD
|
||||
String GIS_OPT_BOOT
|
||||
|
||||
String USR_BIN
|
||||
String USR_LIB_ARCH
|
||||
String LIB_FIRMWARE
|
||||
String HTTP_DEV_DIV
|
||||
String LIB_SYSTEMD
|
||||
|
||||
DebRootDefinition(String rootpath, String packagesourceroot, String packageprefix, String buildstamp, String inpackagepathsuffix) {
|
||||
ROOTPATH = rootpath
|
||||
PACKAGE_PREFIX = packageprefix
|
||||
PACKAGE_FOLDER_NAME = packageprefix
|
||||
PACKAGE_NAME = packageprefix + "_armhf.deb"
|
||||
UNIQUE_PACKAGE_NAME = packageprefix + "_" + buildstamp + "_armhf.deb"
|
||||
|
||||
PACKAGE_SOURCE_ROOT = packagesourceroot
|
||||
PACKAGE_SOURCE_FOLDER_NAME = "${ROOTPATH}/${PACKAGE_PREFIX}"
|
||||
DEBPATH = "${ROOTPATH}/${PACKAGE_FOLDER_NAME}"
|
||||
|
||||
ETC = "${DEBPATH}/etc" + inpackagepathsuffix
|
||||
GIS_OPT_BIN = "${DEBPATH}/opt/gis/bin" + inpackagepathsuffix
|
||||
GIS_OPT_LIB = "${DEBPATH}/opt/gis/lib" + inpackagepathsuffix
|
||||
GIS_OPT_SCRIPTS_APP = "${DEBPATH}/opt/gis/scripts/app" + inpackagepathsuffix
|
||||
GIS_OPT_SCRIPTS_EL = "${DEBPATH}/opt/gis/scripts/el" + inpackagepathsuffix
|
||||
GIS_OPT_SCRIPTS_CONTROL = "${DEBPATH}/opt/gis/scripts/control" + inpackagepathsuffix
|
||||
GIS_OPT_WWW = "${DEBPATH}/opt/gis/www" + inpackagepathsuffix
|
||||
GIS_OPT_OTHER = "${DEBPATH}/opt/gis/other" + inpackagepathsuffix
|
||||
GIS_OPT_KERNEL = "${DEBPATH}/opt/gis/kernel" + inpackagepathsuffix
|
||||
GIS_OPT_LOGIC = "${DEBPATH}/opt/gis/logic" + inpackagepathsuffix
|
||||
GIS_OPT_PRINTHEAD = "${DEBPATH}/opt/gis/printhead" + inpackagepathsuffix
|
||||
GIS_OPT_BOOT = "${DEBPATH}/opt/gis/boot" + inpackagepathsuffix
|
||||
|
||||
USR_BIN = "${DEBPATH}/usr/bin" + inpackagepathsuffix
|
||||
USR_LIB_ARCH = "${DEBPATH}/usr/lib/arm-linux-gnueabihf" + inpackagepathsuffix
|
||||
LIB_FIRMWARE = "${DEBPATH}/lib/firmware" + inpackagepathsuffix
|
||||
HTTP_DEV_DIV = "${DEBPATH}/var/www/gis_dev" + inpackagepathsuffix
|
||||
LIB_SYSTEMD = "${DEBPATH}/lib/systemd" + inpackagepathsuffix
|
||||
}
|
||||
}
|
||||
|
||||
def DebRootDefinition debDefinition(String rootpath, String packagesourceroot, String packageprefix, String buildstamp, String inpackagepathsuffix = '') {
|
||||
return new DebRootDefinition(rootpath, packagesourceroot, packageprefix, buildstamp, inpackagepathsuffix)
|
||||
}
|
||||
|
||||
def buildPackage(String packageout, String uniquepackageout, DebRootDefinition packagedefs, String credentials_id) {
|
||||
withCredentials([usernamePassword(credentialsId: credentials_id,
|
||||
usernameVariable: 'SUDO_USERNAME',
|
||||
passwordVariable: 'SUDO_PASSWORD')]) {
|
||||
def sudo_S = "echo ${SUDO_PASSWORD} | sudo -S"
|
||||
def sudo_Sk = "echo ${SUDO_PASSWORD} | sudo -S -k"
|
||||
try {
|
||||
sh """#!/bin/bash
|
||||
# Exit if any command fails
|
||||
set -xe
|
||||
|
||||
cp -v -r "${packagedefs.PACKAGE_SOURCE_ROOT}/${packagedefs.PACKAGE_SOURCE_FOLDER_NAME}"/* "${packagedefs.DEBPATH}"
|
||||
|
||||
${sudo_Sk} chown -v -R root: "${packagedefs.DEBPATH}"
|
||||
|
||||
mkdir -v -p "${packageout}"
|
||||
echo "Building package:"
|
||||
dpkg-deb -v --build "${packagedefs.DEBPATH}" "${packageout}/${packagedefs.PACKAGE_NAME}"
|
||||
|
||||
mkdir -v -p "${uniquepackageout}"
|
||||
cp "${packageout}/${packagedefs.PACKAGE_NAME}" "${uniquepackageout}/${packagedefs.UNIQUE_PACKAGE_NAME}"
|
||||
|
||||
echo "Showing package:"
|
||||
dpkg-deb --show "${packageout}/${packagedefs.PACKAGE_NAME}"
|
||||
echo "Showing package contents:"
|
||||
dpkg-deb --contents "${packageout}/${packagedefs.PACKAGE_NAME}"
|
||||
|
||||
echo "Showing package lintian output:"
|
||||
lintian --suppress-tags dir-or-file-in-opt "${packageout}/${packagedefs.PACKAGE_NAME}" || true
|
||||
|
||||
${sudo_Sk} chown -R ${USER}: "${packagedefs.DEBPATH}"
|
||||
"""
|
||||
}
|
||||
catch (Exception e) {
|
||||
echo "Exception occurred"
|
||||
sh """#!/bin/bash -v
|
||||
${sudo_Sk} chown -R ${USER}: "${packagedefs.DEBPATH}"
|
||||
|
||||
exit 1
|
||||
"""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
5
Common_scripts/platform/lineendings.groovy
Normal file
5
Common_scripts/platform/lineendings.groovy
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
|
||||
// Put ${nl} into strings when wanting a newline
|
||||
nl = System.properties['line.separator']
|
||||
|
||||
return this;
|
||||
9
Common_scripts/publish/.classpath
Normal file
9
Common_scripts/publish/.classpath
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry excluding="publish.groovy" kind="src" path=""/>
|
||||
<classpathentry exported="true" kind="con" path="GROOVY_SUPPORT"/>
|
||||
<classpathentry exported="true" kind="con" path="GROOVY_DSL_SUPPORT"/>
|
||||
<classpathentry kind="lib" path="/home/dan/.sdkman/candidates/groovy/2.5.6/lib/groovy-json-2.5.6.jar"/>
|
||||
<classpathentry kind="output" path=""/>
|
||||
</classpath>
|
||||
7
Common_scripts/publish/.gitignore
vendored
Normal file
7
Common_scripts/publish/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
/do$_publish_closure4.class
|
||||
/do$_resetfolders_closure1.class
|
||||
/do$_resetfolders_closure2.class
|
||||
/do$_resetfolders_closure3.class
|
||||
/do$_stripgithistory_closure5.class
|
||||
/do.class
|
||||
/publish_item_select.class
|
||||
18
Common_scripts/publish/.project
Normal file
18
Common_scripts/publish/.project
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>publish_item_select</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.groovy.core.groovyNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
eclipse.preferences.version=1
|
||||
groovy.compiler.level=25
|
||||
groovy.script.filters=**/*.dsld,y,**/*.gradle,n
|
||||
174
Common_scripts/publish/do.groovy
Normal file
174
Common_scripts/publish/do.groovy
Normal file
|
|
@ -0,0 +1,174 @@
|
|||
import groovy.io.FileType
|
||||
|
||||
markunstable = false
|
||||
unstablereason = ""
|
||||
|
||||
summaryfolder = "${WORKSPACE}/summary"
|
||||
summaryfile = "${summaryfolder}/summary.txt"
|
||||
summarystring = ""
|
||||
releaserepofolder = "${WORKSPACE}/releaserepos"
|
||||
filteredreleaserepofolder = "${WORKSPACE}/filteredreleaserepos"
|
||||
|
||||
def resetfolders() {
|
||||
dir(summaryfolder) {
|
||||
deleteDir()
|
||||
}
|
||||
dir(releaserepofolder) {
|
||||
deleteDir()
|
||||
}
|
||||
dir(filteredreleaserepofolder) {
|
||||
deleteDir()
|
||||
}
|
||||
}
|
||||
|
||||
def productuniquefolder(releasemeta) {
|
||||
return "${releasemeta.productinfo.productname}_${releasemeta.productinfo.subcomponentname}"
|
||||
}
|
||||
|
||||
def uniquereleasefolder(String productline, String softwarerelease, releasemeta) {
|
||||
return "Software/${productline} ${softwarerelease}/${productuniquefolder(releasemeta)}"
|
||||
}
|
||||
|
||||
def uniqueabsoluterreleasefolder(String productline, String releaserepofolder, String softwarerelease, releasemeta) {
|
||||
return "${releaserepofolder}/${uniquereleasefolder(productline, softwarerelease, releasemeta)}"
|
||||
}
|
||||
|
||||
def preconditions() {
|
||||
markunstable = false
|
||||
unstablereason = ""
|
||||
summarystring = ""
|
||||
writeFile(file: summaryfile, text: "Publish summary: \n")
|
||||
}
|
||||
|
||||
def setunstable(String reason) {
|
||||
markunstable = true
|
||||
unstablereason = reason
|
||||
}
|
||||
|
||||
def summaryappend(String summary) {
|
||||
def String currentsummarycontents = readFile(file: summaryfile)
|
||||
writeFile(file: summaryfile, text: currentsummarycontents + summary)
|
||||
summarystring += summary
|
||||
}
|
||||
|
||||
def guessreporootsuffix(componentURL) {
|
||||
def guess = componentURL.replaceFirst(/.*\/(.*).git/, '$1')
|
||||
return guess
|
||||
}
|
||||
|
||||
gh = load("${autobuilder.commonscripts()}/versioncontrol/git.groovy")
|
||||
def getcomponentartifacts(releaseinfo, String repofolder, itempathstopublish) {
|
||||
summaryappend("Artifacts: ")
|
||||
|
||||
def releasemeta = releaseinfo.metainfo
|
||||
def String componentURL = releasemeta.releaseinfo.releaserepoURL
|
||||
def String revision = "refs/tags/${releasemeta.buildstampinfo.buildstamp}_${releasemeta.jenkinsbuildinfo.buildnumber}"
|
||||
def publishableitems = releasemeta.publishableinfo
|
||||
|
||||
def ArrayList<String> publishablepaths = new ArrayList<String>()
|
||||
if (publishableitems.size() > 0) {
|
||||
for (publishableitem in publishableitems) {
|
||||
def String productuniquepublishableitem = "${productuniquefolder(releasemeta)}/${publishableitem.filepath}"
|
||||
echo "publishableitem: ${productuniquepublishableitem}"
|
||||
if (itempathstopublish.size() == 0 || productuniquepublishableitem in itempathstopublish) {
|
||||
publishablepaths.add(publishableitem.filepath)
|
||||
summaryappend("${publishableitem.filepath},")
|
||||
}
|
||||
}
|
||||
}
|
||||
if (publishablepaths.size() > 0) {
|
||||
def reporootsuffix = guessreporootsuffix(componentURL)
|
||||
gh.gitCheckoutAlt(componentURL, revision, repofolder, reporootsuffix, 1, true, publishablepaths) // Shallow clone
|
||||
}
|
||||
else {
|
||||
summaryappend("None ")
|
||||
}
|
||||
}
|
||||
|
||||
def publish(hostedftpsiteinfo, String customer, String finalreleaserepofolder = releaserepofolder) {
|
||||
summaryappend(" FTP operations: ")
|
||||
|
||||
def String ftproot = "${hostedftpsiteinfo.workingdirectory}${customer}"
|
||||
dir(finalreleaserepofolder) {
|
||||
summaryappend("FTP operations: Transferring to ${ftproot}")
|
||||
sh """#!/bin/bash
|
||||
ncftpput -u ${hostedftpsiteinfo.username} -p ${hostedftpsiteinfo.password} -R ${hostedftpsiteinfo.url} "${ftproot}" .
|
||||
"""
|
||||
summaryappend(", Transferred ")
|
||||
}
|
||||
}
|
||||
|
||||
def copydirectory(File dirFrom, File dirTo) {
|
||||
if (!dirTo.exists()) {
|
||||
dirTo.mkdirs();
|
||||
}
|
||||
dirFrom.eachFile(FileType.FILES) { File source ->
|
||||
File target = new File(dirTo, source.getName())
|
||||
target.bytes = source.bytes
|
||||
}
|
||||
dirFrom.eachFile(FileType.DIRECTORIES) { File source ->
|
||||
File target = new File(dirTo, source.getName())
|
||||
copyLargeDir(source, target)
|
||||
}
|
||||
}
|
||||
|
||||
def recallcomponent(String productline, releaseinfo, String softwarerelease, itempathstopublish) {
|
||||
def releasemeta = releaseinfo.metainfo
|
||||
def String uniquefolderforrepo = uniqueabsoluterreleasefolder(productline, releaserepofolder, softwarerelease, releasemeta)
|
||||
|
||||
summaryappend("${releasemeta.productinfo.productname} ${releasemeta.productinfo.subcomponentname}: ")
|
||||
|
||||
getcomponentartifacts(releaseinfo, uniquefolderforrepo, itempathstopublish)
|
||||
|
||||
summaryappend("\n")
|
||||
}
|
||||
|
||||
def convertitemstopublish(String itemstopublishstring) {
|
||||
def List paths = []
|
||||
|
||||
def String[] items = itemstopublishstring.split(',')
|
||||
def String allpaths = ""
|
||||
for(String item : items) {
|
||||
def String[] pathitems = item.split('#')
|
||||
def String path = "${pathitems[0]}_${pathitems[1]}/${pathitems[2]}"
|
||||
paths.add(path)
|
||||
allpaths += "${path}\n"
|
||||
}
|
||||
echo "Selected item to publish:\n${allpaths}"
|
||||
return paths
|
||||
}
|
||||
|
||||
// Publish selected items from a release to the customer folder on the ftp site
|
||||
// itemstopublishstring is a comma-seperated set of strings in this format <ProductName>#<ComponentName>#<PathToPublishableItem>
|
||||
def publishhierarchy(hostedftpsiteinfo, releasemeta, String releasemetapath, String itemstopublishstring, String customer, String softwarerelease, String maxdepth) {
|
||||
int md = maxdepth.toInteger()
|
||||
resetfolders()
|
||||
preconditions()
|
||||
|
||||
def productline = releasemeta.productinfo.productname
|
||||
// Walk the meta information to a max depth, looking for artifacts to publish
|
||||
def componentReleaseInfoVersionUnique = releasemeta.releasewalkerversionunique(md, '', releasemetapath)
|
||||
|
||||
echo "Version unique components:"
|
||||
def String versionuniquecomponent = ""
|
||||
for (key in componentReleaseInfoVersionUnique.keySet()) {
|
||||
versionuniquecomponent += "${key}\n"
|
||||
}
|
||||
echo versionuniquecomponent
|
||||
|
||||
def itempathstopublish = convertitemstopublish(itemstopublishstring)
|
||||
for (key in componentReleaseInfoVersionUnique.keySet()) {
|
||||
def releaseinfo = componentReleaseInfoVersionUnique[key]
|
||||
recallcomponent(productline, releaseinfo, softwarerelease, itempathstopublish)
|
||||
}
|
||||
gh.stripgithistory(releaserepofolder)
|
||||
publish(hostedftpsiteinfo, customer)
|
||||
|
||||
return [summarystring, markunstable, unstablereason]
|
||||
}
|
||||
|
||||
def publishhierarchy(hostedftpsiteinfo, releasemeta, String releasemetapath, String customer, String softwarerelease, String maxdepth) {
|
||||
return publishhierarchy(hostedftpsiteinfo, releasemeta, releasemetapath, '', customer, softwarerelease, maxdepth)
|
||||
}
|
||||
|
||||
return this;
|
||||
181
Common_scripts/publish/package.groovy
Normal file
181
Common_scripts/publish/package.groovy
Normal file
|
|
@ -0,0 +1,181 @@
|
|||
pipeline {
|
||||
agent { label AGENT_LABEL }
|
||||
stages {
|
||||
stage('Initial setup') {
|
||||
steps {
|
||||
script {
|
||||
meta = load("${WORKSPACE}/autobuild/Common_scripts/autobuilder.groovy").startnonbuild(this)
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Checkout dependencies') {
|
||||
steps {
|
||||
script {
|
||||
configurationhelper = autobuilder.configurationhelper()
|
||||
|
||||
PYTHONURL = 'git@hydra:tools/python.git'
|
||||
if (isUnix()) {
|
||||
PYTHONBRANCH = "origin/3.6.3_linux"
|
||||
}
|
||||
else {
|
||||
PYTHONBRANCH = "origin/3.6.3_windows"
|
||||
}
|
||||
PYTHONDIR = "${WORKSPACE}/python"
|
||||
PYTHONROOTDIR = 'python'
|
||||
configurationhelper.gitCheckoutAndRegister(meta, 'python', PYTHONURL, PYTHONBRANCH, PYTHONDIR, PYTHONROOTDIR)
|
||||
if (isUnix()) {
|
||||
env.PYTHON = "${PYTHONDIR}/usr/local/bin/python3"
|
||||
}
|
||||
else {
|
||||
env.PYTHON = "${PYTHONDIR}/ver/python.exe"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Clean exports') {
|
||||
steps {
|
||||
script {
|
||||
PACKAGEDEST = "${WORKSPACE}/package"
|
||||
cleanfolders = [
|
||||
PACKAGEDEST,
|
||||
]
|
||||
cleaner = load("${autobuilder.commonscripts()}/clean/clean.groovy")
|
||||
cleaner.clean(cleanfolders)
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Copying package artifacts') {
|
||||
steps {
|
||||
script {
|
||||
importer = load("${autobuilder.commonscripts()}/import/importer.groovy")
|
||||
|
||||
def packageimportoptions = importer.getNewImportOptions()
|
||||
packageimportoptions.jenkinsjob(PACKAGE_CREATE_JOB, PACKAGE_CREATE_JOB_SELECTOR)
|
||||
packageimportoptions.setincrementversionnumber(true)
|
||||
packagemeta = importer.artifactimport(meta, packageimportoptions, PACKAGEDEST)
|
||||
|
||||
PACKAGE_FOLDER = "${PACKAGEDEST}/package"
|
||||
UNIQUE_PACKAGE_FOLDER = "${PACKAGEDEST}/uniquepackage"
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Aptly environment') {
|
||||
steps {
|
||||
script {
|
||||
echo "Aptly config file is ${APTLY_CONFIG_FILE}"
|
||||
sh """#!/bin/bash -v
|
||||
aptly config show
|
||||
if [ \$? -ne 0 ]; then exit 1; fi
|
||||
"""
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Create repo - if not already there') {
|
||||
steps {
|
||||
script {
|
||||
echo "Repo name is ${REPO_NAME}"
|
||||
sh """#!/bin/bash -v
|
||||
aptly repo -config="${APTLY_CONFIG_FILE}" -with-packages show "${REPO_NAME}"
|
||||
if [ \$? -ne 0 ]; then
|
||||
echo "aptly repo ${REPO_NAME} does not exist; Creating it"
|
||||
aptly repo -config="${APTLY_CONFIG_FILE}" create "${REPO_NAME}"
|
||||
if [ \$? -ne 0 ]; then exit 1; fi
|
||||
fi
|
||||
aptly repo -config="${APTLY_CONFIG_FILE}" -with-packages show "${REPO_NAME}"
|
||||
if [ \$? -ne 0 ]; then exit 1; fi
|
||||
"""
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Drop published repo - if any') {
|
||||
steps {
|
||||
script {
|
||||
sh """#!/bin/bash -v
|
||||
# This errors if the published repo exists already; Ignore it
|
||||
aptly publish -config="${APTLY_CONFIG_FILE}" drop "${DISTRIBUTION}" "${PUBLISH_PATH_PREFIX}"
|
||||
aptly publish -config="${APTLY_CONFIG_FILE}" list
|
||||
if [ \$? -ne 0 ]; then exit 1; fi
|
||||
"""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Add/update package in repo') {
|
||||
steps {
|
||||
script {
|
||||
echo "Unique package folder is ${UNIQUE_PACKAGE_FOLDER}"
|
||||
sh """#!/bin/bash -v
|
||||
aptly repo -config="${APTLY_CONFIG_FILE}" add "${REPO_NAME}" "${UNIQUE_PACKAGE_FOLDER}"
|
||||
if [ \$? -ne 0 ]; then exit 1; fi
|
||||
aptly repo -config="${APTLY_CONFIG_FILE}" show -with-packages "${REPO_NAME}"
|
||||
if [ \$? -ne 0 ]; then exit 1; fi
|
||||
"""
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Create snapshot') {
|
||||
steps {
|
||||
script {
|
||||
echo "Snapshot name is ${SNAPSHOT_NAME}"
|
||||
FULL_SNAPSHOT_NAME = "${REPO_NAME}_${SNAPSHOT_NAME}"
|
||||
PACKAGE_VERSION_PREFIX = packagemeta.buildstampinfo.buildstampprefix
|
||||
echo "Full Snapshot name is ${FULL_SNAPSHOT_NAME} containing packages of versions beginning with: ${PACKAGE_VERSION_PREFIX}"
|
||||
// Convert prefix to regular expression
|
||||
PACKAGE_VERSION_PREFIX_SPLIT = PACKAGE_VERSION_PREFIX.split("[.]")
|
||||
PACKAGE_VERSION_REGEX = ''
|
||||
i = 0
|
||||
while(true) {
|
||||
if (i == PACKAGE_VERSION_PREFIX_SPLIT.size() - 1) {
|
||||
PACKAGE_VERSION_REGEX += PACKAGE_VERSION_PREFIX_SPLIT[i]
|
||||
break;
|
||||
}
|
||||
PACKAGE_VERSION_REGEX += PACKAGE_VERSION_PREFIX_SPLIT[i]
|
||||
PACKAGE_VERSION_REGEX += '\\.'
|
||||
i++
|
||||
}
|
||||
sh """#!/bin/bash -v
|
||||
# This errors if the snapshot exists already; Ignore it
|
||||
aptly snapshot -config="${APTLY_CONFIG_FILE}" drop "${FULL_SNAPSHOT_NAME}"
|
||||
aptly snapshot -config="${APTLY_CONFIG_FILE}" drop "All_${FULL_SNAPSHOT_NAME}"
|
||||
aptly snapshot -config="${APTLY_CONFIG_FILE}" create "All_${FULL_SNAPSHOT_NAME}" from repo "${REPO_NAME}"
|
||||
if [ \$? -ne 0 ]; then exit 1; fi
|
||||
|
||||
aptly snapshot filter -config="/home/repos/gis-aptly-config/gis.conf" "All_${FULL_SNAPSHOT_NAME}" "${FULL_SNAPSHOT_NAME}" 'Version (~ .*${PACKAGE_VERSION_REGEX}.*)'
|
||||
if [ \$? -ne 0 ]; then exit 1; fi
|
||||
aptly snapshot -config="${APTLY_CONFIG_FILE}" -with-packages show "${FULL_SNAPSHOT_NAME}"
|
||||
if [ \$? -ne 0 ]; then exit 1; fi
|
||||
"""
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Publish snapshot') {
|
||||
steps {
|
||||
script {
|
||||
sh """#!/bin/bash -v
|
||||
aptly publish -config="${APTLY_CONFIG_FILE}" -distribution="${DISTRIBUTION}" -component="${COMPONENT}" -gpg-key="${GPG_KEY_ID}" snapshot "${FULL_SNAPSHOT_NAME}" "${PUBLISH_PATH_PREFIX}"
|
||||
if [ \$? -ne 0 ]; then exit 1; fi
|
||||
aptly publish -config="${APTLY_CONFIG_FILE}" list
|
||||
if [ \$? -ne 0 ]; then exit 1; fi
|
||||
aptly publish -config="${APTLY_CONFIG_FILE}" show "${DISTRIBUTION}" "${PUBLISH_PATH_PREFIX}"
|
||||
if [ \$? -ne 0 ]; then exit 1; fi
|
||||
"""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
post {
|
||||
always {
|
||||
echo 'Post-build'
|
||||
}
|
||||
failure {
|
||||
echo 'Failed build'
|
||||
}
|
||||
unstable {
|
||||
echo 'Unstable build'
|
||||
}
|
||||
success {
|
||||
echo 'Succeeded build'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
182
Common_scripts/publish/promptingpublish.groovy
Normal file
182
Common_scripts/publish/promptingpublish.groovy
Normal file
|
|
@ -0,0 +1,182 @@
|
|||
pipeline {
|
||||
agent { label AGENT_LABEL }
|
||||
stages {
|
||||
stage('Initial setup') {
|
||||
steps {
|
||||
script {
|
||||
autobuilderscript = load("${WORKSPACE}/autobuild/Common_scripts/autobuilder.groovy")
|
||||
meta = autobuilderscript.startnonbuild(this)
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Clean folders') {
|
||||
steps {
|
||||
script {
|
||||
cleanfolders = [
|
||||
]
|
||||
cleaner = load("${autobuilder.commonscripts()}/clean/clean.groovy")
|
||||
cleaner.clean(cleanfolders)
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Checkout release repo') {
|
||||
steps {
|
||||
script {
|
||||
configurationhelper = autobuilder.configurationhelper()
|
||||
|
||||
SOURCEURL = RELEASE_REPO
|
||||
SOURCEREVISION = "origin/master"
|
||||
SOURCEDIR = "${WORKSPACE}/whole"
|
||||
configurationhelper.gitCheckoutAndRegister(meta, 'whole', SOURCEURL, SOURCEREVISION, SOURCEDIR, '', 0, false)
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Identify customer to publish to') {
|
||||
steps {
|
||||
script {
|
||||
hostedftb = load("${autobuilder.commonscripts()}/remoteaccess/hostedftp.groovy")
|
||||
def List<String> customers = hostedftb.getCustomerList()
|
||||
timeout(time: 10, unit: 'MINUTES') {
|
||||
customer = input(
|
||||
message: 'Please select customer to publish to',
|
||||
ok: 'Ok',
|
||||
parameters: [
|
||||
choice(name: 'customer', choices: customers, description: 'Which customer?')
|
||||
]
|
||||
)
|
||||
echo "Chosen customer is: ${customer}"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Identify software release to publish') {
|
||||
steps {
|
||||
script {
|
||||
gh = load("${autobuilder.commonscripts()}/versioncontrol/git.groovy")
|
||||
def allreleases = gh.gettaglist(SOURCEDIR)
|
||||
def releases = new ArrayList<String>()
|
||||
if (FILTER_REDUNDANT_RELEASES == 'false') {
|
||||
echo("Showing all releases")
|
||||
releases = allreleases
|
||||
} else {
|
||||
echo("Showing filtered releases")
|
||||
for (release in allreleases) {
|
||||
if (!release.toLowerCase().startsWith("superceded") &&
|
||||
!release.toLowerCase().startsWith("superseded") &&
|
||||
!release.toLowerCase().startsWith("erroneous") &&
|
||||
!release.toLowerCase().startsWith("faulty") &&
|
||||
!release.toLowerCase().startsWith("ignore") &&
|
||||
!release.toLowerCase().startsWith("inmainline")) {
|
||||
echo("Showing release: ${release}")
|
||||
releases.add(release)
|
||||
} else {
|
||||
echo("Not showing release: ${release}")
|
||||
}
|
||||
}
|
||||
}
|
||||
timeout(time: 10, unit: 'MINUTES') {
|
||||
release = input(
|
||||
message: 'Please select the software version',
|
||||
ok: 'Ok',
|
||||
parameters: [
|
||||
choice(name: 'release', choices: releases, description: 'Which software release?')
|
||||
]
|
||||
)
|
||||
echo "Chosen software version is: ${release}"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Checkout release repo at selected software version') {
|
||||
steps {
|
||||
script {
|
||||
SOURCEURL = RELEASE_REPO
|
||||
SOURCEREVISION = "refs/tags/${release}"
|
||||
SOURCEDIR = "${WORKSPACE}/whole"
|
||||
configurationhelper.gitCheckoutAndRegister(meta, 'whole', SOURCEURL, SOURCEREVISION, SOURCEDIR, '', 0, false)
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Get release artifact info') {
|
||||
steps {
|
||||
script {
|
||||
def mfs = autobuilderscript.getmetafolderscript()
|
||||
releasemeta = mfs.metafromfolder(SOURCEDIR)
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Select which items from software release to publish') {
|
||||
steps {
|
||||
script {
|
||||
publishitems = load("${autobuilder.commonscripts()}/publish/publishitems.groovy")
|
||||
timeout(time: 10, unit: 'MINUTES') {
|
||||
def itemsobject = publishitems.createItemSelector(
|
||||
'Select software items',
|
||||
'Software items',
|
||||
releasemeta,
|
||||
SOURCEDIR,
|
||||
ITEMSDEFAULTLIST,
|
||||
MAX_META_DEPTH,
|
||||
'20',
|
||||
'PT_MULTI_SELECT')
|
||||
selecteditems = input(
|
||||
message: 'Select which items from the release are to be published',
|
||||
ok: 'Ok',
|
||||
parameters: [
|
||||
itemsobject.multiSelect()
|
||||
]
|
||||
)
|
||||
echo "Chosen items are: ${selecteditems}"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Publish components') {
|
||||
steps {
|
||||
script {
|
||||
def publisher = load("${autobuilder.commonscripts()}/publish/do.groovy")
|
||||
def hostedftpsiteinfo = hostedftb.getHostedFTPSiteInfo()
|
||||
(summarystring, markunstable, unstablereason) = publisher.publishhierarchy(hostedftpsiteinfo, releasemeta, SOURCEDIR, selecteditems, customer, release, MAX_META_DEPTH)
|
||||
if (markunstable) {
|
||||
env.unstablereason = unstablereason
|
||||
currentBuild.result = 'UNSTABLE'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Archiving artifacts') {
|
||||
steps {
|
||||
script {
|
||||
def artifactlist = meta.generateartifacts()
|
||||
artifactarchiver = load("${autobuilder.commonscripts()}/artifacts/archiver.groovy")
|
||||
artifactarchiver.archive("summary/**,${artifactlist}")
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Summarise') {
|
||||
steps {
|
||||
script {
|
||||
echo "Summary:\n${summarystring}\n"
|
||||
if (env.unstablereason) {
|
||||
echo "Instability reason: ${env.unstablereason}"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
post {
|
||||
always {
|
||||
echo 'Post-build'
|
||||
}
|
||||
failure {
|
||||
echo 'Failed build'
|
||||
}
|
||||
unstable {
|
||||
echo 'Unstable build'
|
||||
}
|
||||
success {
|
||||
echo 'Succeeded build'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
92
Common_scripts/publish/publish.groovy
Normal file
92
Common_scripts/publish/publish.groovy
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
pipeline {
|
||||
agent { label AGENT_LABEL }
|
||||
stages {
|
||||
stage('Initial setup') {
|
||||
steps {
|
||||
script {
|
||||
autobuilderscript = load("${WORKSPACE}/autobuild/Common_scripts/autobuilder.groovy")
|
||||
meta = autobuilderscript.startbuild(this, PRODUCT_NAME, SUBCOMPONENT_NAME, RELEASE_REPO)
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Clean folders') {
|
||||
steps {
|
||||
script {
|
||||
cleanfolders = [
|
||||
]
|
||||
cleaner = load("${autobuilder.commonscripts()}/clean/clean.groovy")
|
||||
cleaner.clean(cleanfolders)
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Checkout release repo') {
|
||||
steps {
|
||||
script {
|
||||
configurationhelper = autobuilder.configurationhelper()
|
||||
|
||||
SOURCEURL = RELEASE_REPO
|
||||
SOURCEREVISION = "refs/tags/${SOFTWARE_RELEASE}"
|
||||
SOURCEDIR = "${WORKSPACE}/whole"
|
||||
SOURCEROOTDIR = 'whole'
|
||||
configurationhelper.gitCheckoutAndRegister(meta, 'whole', SOURCEURL, SOURCEREVISION, SOURCEDIR, SOURCEROOTDIR, 0, false)
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Get release artifact meta') {
|
||||
steps {
|
||||
script {
|
||||
def mfs = autobuilderscript.getmetafolderscript()
|
||||
releasemeta = mfs.metafromfolder(SOURCEDIR)
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Publish components') {
|
||||
steps {
|
||||
script {
|
||||
def publisher = load("${autobuilder.commonscripts()}/publish/do.groovy")
|
||||
def hostedftb = load("${autobuilder.commonscripts()}/remoteaccess/hostedftp.groovy")
|
||||
def hostedftpsiteinfo = hostedftb.getHostedFTPSiteInfo()
|
||||
(summarystring, markunstable, unstablereason) = publisher.publishhierarchy(hostedftpsiteinfo, releasemeta, ITEMS_TO_PUBLISH, CUSTOMER, SOFTWARE_RELEASE, MAX_META_DEPTH)
|
||||
if (markunstable) {
|
||||
env.unstablereason = unstablereason
|
||||
currentBuild.result = 'UNSTABLE'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Archiving artifacts') {
|
||||
steps {
|
||||
script {
|
||||
def artifactlist = meta.generateartifacts()
|
||||
artifactarchiver = load("${autobuilder.commonscripts()}/artifacts/archiver.groovy")
|
||||
artifactarchiver.archive("summary/**,${artifactlist}")
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Summarise') {
|
||||
steps {
|
||||
script {
|
||||
echo "Summary:\n${summarystring}\n"
|
||||
if (env.unstablereason) {
|
||||
echo "Instability reason: ${env.unstablereason}"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
post {
|
||||
always {
|
||||
echo 'Post-build'
|
||||
}
|
||||
failure {
|
||||
echo 'Failed build'
|
||||
}
|
||||
unstable {
|
||||
echo 'Unstable build'
|
||||
}
|
||||
success {
|
||||
echo 'Succeeded build'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
129
Common_scripts/publish/publishitems.groovy
Normal file
129
Common_scripts/publish/publishitems.groovy
Normal file
|
|
@ -0,0 +1,129 @@
|
|||
import com.cwctravel.hudson.plugins.extended_choice_parameter.ExtendedChoiceParameterDefinition
|
||||
|
||||
class PublishableItemsSelection {
|
||||
def script
|
||||
def ArrayList<String> preselectedmenuitems
|
||||
def ArrayList<String> menuitemdescriptions
|
||||
def ArrayList<String> menuitemsfull
|
||||
def ExtendedChoiceParameterDefinition multiselect
|
||||
|
||||
PublishableItemsSelection(script) {
|
||||
this.script = script
|
||||
preselectedmenuitems = new ArrayList<String>()
|
||||
menuitemdescriptions = new ArrayList<String>()
|
||||
menuitemsfull = new ArrayList<String>()
|
||||
}
|
||||
|
||||
def init(
|
||||
String name,
|
||||
String description,
|
||||
releasemeta,
|
||||
String releasemetapath,
|
||||
String preselectedext,
|
||||
String metalevelsstringext,
|
||||
String visibleItemCountExt,
|
||||
String controltype) {
|
||||
outputSelectionfromPreselect(preselectedmenuitems, preselectedext)
|
||||
def Integer metalevelsext = metalevelsstringext.toInteger()
|
||||
def Integer visibleItemCount = visibleItemCountExt.toInteger()
|
||||
def metaitems = releasemeta.releasewalkerunique(metalevelsext, '', releasemetapath)
|
||||
for (key in metaitems.keySet()) {
|
||||
def releaseinfo = metaitems[key]
|
||||
outputDescription(menuitemdescriptions, releaseinfo)
|
||||
outputSelection(menuitemsfull, releaseinfo)
|
||||
}
|
||||
|
||||
script.echo("name is: ${name}")
|
||||
script.echo("description is: ${description}")
|
||||
script.echo("menuitemsfull is: ${menuitemsfull}")
|
||||
script.echo("preselectedmenuitems is: ${preselectedmenuitems}")
|
||||
script.echo("menuitemdescriptions is: ${menuitemdescriptions}")
|
||||
script.echo("visibleItemCount is: ${visibleItemCount}")
|
||||
script.echo("controltype is: ${controltype}")
|
||||
|
||||
def seperator = ","
|
||||
visibleItemCount = Math.min(visibleItemCount, menuitemsfull.size())
|
||||
script.echo("visibleItemCount is now: ${visibleItemCount}")
|
||||
|
||||
multiselect = new ExtendedChoiceParameterDefinition(
|
||||
name, // String name
|
||||
controltype, // String type
|
||||
menuitemsfull.join(seperator), // String value
|
||||
"project name", // String projectName
|
||||
"", // String propertyFile
|
||||
"", // String groovyScript
|
||||
"", // String groovyScriptFile
|
||||
"", // String bindings
|
||||
"", // String groovyClasspath
|
||||
"", // String propertyKey
|
||||
preselectedmenuitems.join(seperator),// String defaultValue
|
||||
"", // String defaultPropertyFile
|
||||
"", // String defaultGroovyScript
|
||||
"", // String defaultGroovyScriptFile
|
||||
"", // String defaultBindings
|
||||
"", // String defaultGroovyClasspath
|
||||
"", // String defaultPropertyKey
|
||||
menuitemdescriptions.join(seperator),// String descriptionPropertyValue
|
||||
"", // String descriptionPropertyFile
|
||||
"", // String descriptionGroovyScript
|
||||
"", // String descriptionGroovyScriptFile
|
||||
"", // String descriptionBindings
|
||||
"", // String descriptionGroovyClasspath
|
||||
"", // String descriptionPropertyKey
|
||||
"", // String javascriptFile
|
||||
"", // String javascript
|
||||
false, // boolean saveJSONParameterToFile
|
||||
false, // boolean quoteValue
|
||||
visibleItemCount, // int visibleItemCount
|
||||
description, // String description
|
||||
seperator) // String multiSelectDelimiter
|
||||
}
|
||||
|
||||
def outputSelectionfromPreselect(menuitems, preselectedext) {
|
||||
script.echo ("preselectext: ${preselectedext}")
|
||||
def menuitemstemp = preselectedext.split(',')
|
||||
script.echo ("Menuitemstemp: ${menuitemstemp}")
|
||||
|
||||
for (menuitem in menuitemstemp) {
|
||||
menuitems.add(menuitem.trim())
|
||||
}
|
||||
}
|
||||
|
||||
def outputDescription(menuitems, releaseinfo) {
|
||||
def meta = releaseinfo.metainfo
|
||||
|
||||
for (publishableitem in meta.publishableinfo) {
|
||||
menuitems.add("${meta.productinfo.productname} ${meta.productinfo.subcomponentname} ${publishableitem.filepath}")
|
||||
}
|
||||
}
|
||||
|
||||
def outputSelection(menuitems, releaseinfo) {
|
||||
def meta = releaseinfo.metainfo
|
||||
|
||||
for (publishableitem in meta.publishableinfo) {
|
||||
menuitems.add("${meta.productinfo.productname}#${meta.productinfo.subcomponentname}#${publishableitem.filepath}")
|
||||
}
|
||||
}
|
||||
|
||||
def multiSelect() {
|
||||
return multiselect
|
||||
}
|
||||
}
|
||||
|
||||
PublishableItemsSelection createItemSelector(
|
||||
String name,
|
||||
String description,
|
||||
releasemeta,
|
||||
String releasemetapath,
|
||||
String preselectedext,
|
||||
String metalevelsstringext,
|
||||
String visibleItemCountExt = '20',
|
||||
String type = 'PT_CHECKBOX') { // Could also be "PT_MULTI_SELECT"
|
||||
PublishableItemsSelection pis = new PublishableItemsSelection(this)
|
||||
|
||||
pis.init(name, description, releasemeta, releasemetapath, preselectedext, metalevelsstringext, visibleItemCountExt, type)
|
||||
|
||||
return pis
|
||||
}
|
||||
|
||||
return this;
|
||||
27
Common_scripts/publishing/utils.groovy
Normal file
27
Common_scripts/publishing/utils.groovy
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
|
||||
|
||||
// The filepath must end in "<folder>/**" or "<folder>/" - Glob wildcard - as a git sparse checkout
|
||||
def allowed(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) {
|
||||
if (filepath != meta.METAARTIFACTS) {
|
||||
allowed(filepath)
|
||||
}
|
||||
meta.addPublishable(filepath)
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
458
Common_scripts/release/do.groovy
Normal file
458
Common_scripts/release/do.groovy
Normal file
|
|
@ -0,0 +1,458 @@
|
|||
gh = load("${autobuilder.commonscripts()}/versioncontrol/git.groovy")
|
||||
|
||||
markunstable = false
|
||||
unstablereason = ""
|
||||
|
||||
summaryfolder = "${WORKSPACE}/summary"
|
||||
summaryfile = "${summaryfolder}/summary.txt"
|
||||
summarystring = ""
|
||||
repoandtagsfile = "${summaryfolder}/repoandtags.txt"
|
||||
repoandtagsstring = ""
|
||||
releaserepofolder = "${WORKSPACE}/releaserepos"
|
||||
sourcerepofolder = "${WORKSPACE}/sourcerepos"
|
||||
tempfolder = "${WORKSPACE}/temp"
|
||||
gitrevparseoutputfile = "${tempfolder}/gitrevparse.out"
|
||||
|
||||
metascript = autobuilder.getmetafolderscript()
|
||||
|
||||
def resetfolders() {
|
||||
dir(summaryfolder) {
|
||||
deleteDir()
|
||||
}
|
||||
dir(releaserepofolder) {
|
||||
deleteDir()
|
||||
}
|
||||
dir(tempfolder) {
|
||||
deleteDir()
|
||||
}
|
||||
}
|
||||
|
||||
def preconditions() {
|
||||
markunstable = false
|
||||
unstablereason = ""
|
||||
summarystring = ""
|
||||
writeFile(file: summaryfile, text: "Release summary: \n")
|
||||
repoandtagsstring = ""
|
||||
writeFile(file: repoandtagsfile, text: "Repository summary: \n")
|
||||
}
|
||||
|
||||
def setunstable(String reason) {
|
||||
markunstable = true
|
||||
unstablereason += reason + "\n"
|
||||
echo "Marked build as unstable: Reason: ${reason}"
|
||||
}
|
||||
|
||||
def summaryappend(String summary) {
|
||||
def String currentsummarycontents = readFile(file: summaryfile)
|
||||
writeFile(file: summaryfile, text: currentsummarycontents + summary)
|
||||
summarystring += summary
|
||||
}
|
||||
|
||||
def repoandtagsappend(String summary) {
|
||||
def String repoandtagscontents = readFile(file: repoandtagsfile)
|
||||
writeFile(file: repoandtagsfile, text: repoandtagscontents + summary)
|
||||
repoandtagsstring += summary
|
||||
}
|
||||
|
||||
def getpreviousreleasemeta(buildmeta, String checkoutfolder) {
|
||||
def previousreleasemeta = buildmeta.getNewMetaObject(this)
|
||||
// See if there is meta data file from the current release
|
||||
def String releasemetafolderpath = "${checkoutfolder}/${buildmeta.folder()}"
|
||||
if (fileExists(releasemetafolderpath)) {
|
||||
previousreleasemeta = metascript.metafromfolder(checkoutfolder)
|
||||
}
|
||||
return previousreleasemeta
|
||||
}
|
||||
|
||||
def checkoutreleaserepo(buildmeta, String checkoutfolder) {
|
||||
def String releaserepo = buildmeta.releaseinfo.releaserepoURL
|
||||
// Get the latest head revision of the release repo without checking out working copy; Check out to a folder unique to component; Extract any meta
|
||||
repoandtagsappend(" Release repo: ${releaserepo}")
|
||||
def previousreleasemeta = buildmeta.getNewMetaObject(this)
|
||||
dir(releaserepofolder) {
|
||||
sh("git clone ${releaserepo} ${checkoutfolder}")
|
||||
}
|
||||
previousreleasemeta = getpreviousreleasemeta(buildmeta, checkoutfolder)
|
||||
dir(checkoutfolder) {
|
||||
// Clear all existing files - Note that this does not remove .git*
|
||||
sh("git rm -r *")
|
||||
}
|
||||
return previousreleasemeta
|
||||
}
|
||||
|
||||
def checkoutsourcerepo(buildmeta, String checkoutfolder) {
|
||||
def String sourcerepo = buildmeta.gitinfo.remoteurl
|
||||
if (sourcerepo) {
|
||||
repoandtagsappend(" Source repo: ${sourcerepo}")
|
||||
// Get the latest revision of the source repo without checking out working copy; Check out to a folder unique to component
|
||||
if (fileExists(checkoutfolder)) {
|
||||
dir(checkoutfolder) {
|
||||
sh("""
|
||||
git reset --hard
|
||||
git clean -fdx
|
||||
git pull
|
||||
# Remove all tags that are not already on the remote
|
||||
git tag -l | xargs git tag -d >/dev/null
|
||||
git fetch -t >/dev/null
|
||||
"""
|
||||
)
|
||||
}
|
||||
}
|
||||
else {
|
||||
dir(sourcerepofolder) {
|
||||
sh("git clone ${sourcerepo} ${checkoutfolder}")
|
||||
}
|
||||
}
|
||||
} else {
|
||||
repoandtagsappend(" Source repo: None")
|
||||
}
|
||||
}
|
||||
|
||||
def boolean getcomponentartifacts(toplevelbuildmeta, buildinfo, String repofolder, String tempfolder) {
|
||||
// Copy relevant artifacts to temp folder
|
||||
summaryappend("Artifacts: ")
|
||||
def boolean result = true
|
||||
for (artifactfilter in buildinfo.metainfo.releaseinfo.releaseitems) {
|
||||
def filterpath = artifactfilter
|
||||
if (buildinfo.accumulatedpath) {
|
||||
filterpath = buildinfo.accumulatedpath + '/' + artifactfilter
|
||||
}
|
||||
// Copy relevant artifacts to temp folder
|
||||
echo "Copying artifacts: Filter path: ${filterpath} to ${tempfolder} from job: ${toplevelbuildmeta.jenkinsbuildinfo.buildjobname} #${toplevelbuildmeta.jenkinsbuildinfo.buildnumber}"
|
||||
try {
|
||||
copyArtifacts(
|
||||
filter: filterpath,
|
||||
projectName: toplevelbuildmeta.jenkinsbuildinfo.buildjobname,
|
||||
selector: [
|
||||
$class: 'ParameterizedBuildSelector',
|
||||
parameterName: "<SpecificBuildSelector plugin='copyartifact@1.46.2'><buildNumber>${toplevelbuildmeta.jenkinsbuildinfo.buildnumber}</buildNumber></SpecificBuildSelector>"
|
||||
],
|
||||
target: tempfolder
|
||||
)
|
||||
} catch (Exception e) {
|
||||
echo "Exception occurred while copying artifacts from ${toplevelbuildmeta.jenkinsbuildinfo.buildjobname}: ${e.getMessage()}"
|
||||
result = false
|
||||
summaryappend("Does not exist:")
|
||||
}
|
||||
if (result) {
|
||||
// Move relevant artifacts from temp folder to release position
|
||||
def originalrootdir = tempfolder + "/" + buildinfo.accumulatedpath
|
||||
dir(originalrootdir) {
|
||||
sh("mv -v * ${repofolder}")
|
||||
}
|
||||
}
|
||||
summaryappend("${artifactfilter},")
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
def releasegitadd() {
|
||||
// Add anything new
|
||||
sh("git add .")
|
||||
summaryappend("Add,")
|
||||
}
|
||||
|
||||
def releasegitreset() {
|
||||
// Add anything new
|
||||
sh("git reset --hard")
|
||||
sh("git clean -fdx")
|
||||
summaryappend("Reset,")
|
||||
}
|
||||
|
||||
def releasegitcommit(String buildstamp) {
|
||||
sh("git commit -a -m ${buildstamp}")
|
||||
summaryappend("Commit,")
|
||||
}
|
||||
|
||||
// Determine if there has been a change by comparing the sha code in previous release meta and the build meta
|
||||
def boolean checkforchange(buildmeta, previousreleasemeta) {
|
||||
String buildsha = buildmeta.gitinfo.gitrevision
|
||||
String previoussha = previousreleasemeta.gitinfo.gitrevision
|
||||
|
||||
def boolean shachanged = (buildsha != previoussha)
|
||||
echo "buildsha: ${buildsha} previoussha: ${previoussha} changed: ${shachanged}"
|
||||
|
||||
String buildstamp = buildmeta.buildstampinfo.buildstamp
|
||||
String previousbuildstamp = previousreleasemeta.buildstampinfo.buildstamp
|
||||
|
||||
def boolean buildstampchanged = (buildstamp != previousbuildstamp)
|
||||
echo "buildstamp: ${buildstamp} previousbuildstamp: ${previousbuildstamp} changed: ${buildstampchanged}"
|
||||
|
||||
def boolean changed = (shachanged | buildstampchanged)
|
||||
echo "changed: ${changed}"
|
||||
|
||||
return changed
|
||||
}
|
||||
|
||||
def ArrayList<String> maketaglist(buildmeta, String buildstamp, String otherreleasetags) {
|
||||
def ArrayList<String> taglist = new ArrayList<String>()
|
||||
taglist.add(buildstamp)
|
||||
|
||||
def ArrayList<String> othertaglist = otherreleasetags.split(',')
|
||||
for (othertagitem in othertaglist) {
|
||||
if (othertagitem?.trim()) {
|
||||
def componentothertagitem = "${othertagitem.trim()}_${buildmeta.productinfo.productname}_${buildmeta.productinfo.subcomponentname}"
|
||||
taglist.add(componentothertagitem)
|
||||
}
|
||||
}
|
||||
return taglist
|
||||
}
|
||||
|
||||
def String releasegitgetshacode(String tag) {
|
||||
def existingshacode = ""
|
||||
// Check if tag exists already
|
||||
def int gitrevparsestatus = sh(script: "git rev-parse \"${tag}\" >\"${gitrevparseoutputfile}\" 2>/dev/null", returnStatus: true)
|
||||
if (gitrevparsestatus == 0) { // Tag exists
|
||||
existingshacode = readFile(file: gitrevparseoutputfile).trim()
|
||||
}
|
||||
return existingshacode
|
||||
}
|
||||
|
||||
def boolean releasegittag(String postcommitshacode, String tag) {
|
||||
def boolean tagadded = false
|
||||
// Check if tag exists already
|
||||
def String existingshacode = releasegitgetshacode(tag)
|
||||
if (existingshacode) { // Tag exists
|
||||
if (existingshacode != postcommitshacode) { // If the existing tag is not associated with the one expected
|
||||
// This is a problem - The tag is already at another position in git repo
|
||||
setunstable("The release tag ${tag} has been used at another commit other than one expected - You must decide what to do with it - Not good practice to delete it or move it (Existing sha code: ${existingshacode} Post commit sha code: ${postcommitshacode})")
|
||||
summaryappend("(${tag} - Could not add!)")
|
||||
} else {
|
||||
summaryappend("(${tag} - Already added)")
|
||||
}
|
||||
} else { // If tag does not exist already
|
||||
// Tag
|
||||
sh("git tag \"${tag}\"")
|
||||
summaryappend("(${tag})")
|
||||
tagadded = true
|
||||
}
|
||||
return tagadded
|
||||
}
|
||||
|
||||
def boolean releasegittags(String postcommitshacode, ArrayList<String> taglist) {
|
||||
boolean tagadded = false
|
||||
|
||||
summaryappend("Rel Tag ")
|
||||
for (tag in taglist) {
|
||||
if (releasegittag(postcommitshacode, tag)) {
|
||||
echo "Tag added: ${tag} with sha: ${postcommitshacode}"
|
||||
tagadded = true
|
||||
}
|
||||
}
|
||||
return tagadded
|
||||
}
|
||||
|
||||
def boolean sourcegittag(String shacode, String tag) {
|
||||
def boolean tagadded = false
|
||||
// Check if tag exists already
|
||||
def int gitrevparsestatus = sh(script: "git rev-parse \"${tag}\" >\"${gitrevparseoutputfile}\" 2>/dev/null", returnStatus: true)
|
||||
if (gitrevparsestatus == 0) { // Tag exists
|
||||
def existingshacode = readFile(file: gitrevparseoutputfile).trim()
|
||||
if (existingshacode != shacode) { // 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 source tag ${tag} has been used at another commit (${existingshacode}) - You must decide what to do with it - Not good practice to delete it or move it (Existing sha code: ${existingshacode} Post commit sha code: ${shacode})")
|
||||
summaryappend("(${tag} - Could not add!)")
|
||||
}
|
||||
else {
|
||||
summaryappend("(${tag} - Already added)")
|
||||
}
|
||||
}
|
||||
else { // If tag does not exist already
|
||||
// Tag
|
||||
sh("git tag \"${tag}\" ${shacode}")
|
||||
summaryappend("(${tag})")
|
||||
tagadded = true
|
||||
}
|
||||
return tagadded
|
||||
}
|
||||
|
||||
def sourcegittags(String buildsha, List taglist) {
|
||||
boolean tagadded = false
|
||||
|
||||
summaryappend(",Src Tag ")
|
||||
for (tag in taglist) {
|
||||
if (sourcegittag(buildsha, tag)) {
|
||||
tagadded = true
|
||||
}
|
||||
}
|
||||
return tagadded
|
||||
}
|
||||
|
||||
def releasegitpush(String dryrunpush ) {
|
||||
sh("git remote -v")
|
||||
if (dryrunpush == "true") {
|
||||
sh("git push -n --tags origin master")
|
||||
summaryappend(",Dry-Run-Push")
|
||||
setunstable("The artifact(s) have not been pushed/saved (\"Dry run push\" parameter/option is selected)")
|
||||
}
|
||||
else {
|
||||
sh("git push --tags origin master")
|
||||
summaryappend(",Push")
|
||||
}
|
||||
}
|
||||
|
||||
def sourcegitpush(String dryrunpush ) {
|
||||
sh("git remote -v")
|
||||
if (dryrunpush == "true") {
|
||||
sh("git push -n --tags")
|
||||
summaryappend(",Src-Dry-Run-Push")
|
||||
setunstable("The source tag(s) have not been pushed/saved (\"Dry run push\" parameter/option is selected)")
|
||||
}
|
||||
else {
|
||||
sh("git push --tags")
|
||||
summaryappend(",Src Push")
|
||||
}
|
||||
}
|
||||
|
||||
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()
|
||||
|
||||
dir(releaserepo) {
|
||||
def String precommitshacode = sh(script: "git rev-parse --verify HEAD", returnStdout: true).trim()
|
||||
echo "Pre commit sha code: ${precommitshacode}"
|
||||
|
||||
def boolean alreadyreleased = isalreadyreleased(buildmeta, buildstamptag)
|
||||
|
||||
def String postcommitshacode
|
||||
def boolean changed = false
|
||||
if (alreadyreleased) {
|
||||
summaryappend("Already-released,")
|
||||
postcommitshacode = releasegitgetshacode(buildstamptag)
|
||||
echo "Previous release sha code: ${postcommitshacode}"
|
||||
} else {
|
||||
releasegitadd()
|
||||
|
||||
changed = checkforchange(buildmeta, previousreleasemeta)
|
||||
if (changed) {
|
||||
releasegitcommit(buildstamptag)
|
||||
} else {
|
||||
releasegitreset()
|
||||
summaryappend("No-commit,")
|
||||
}
|
||||
|
||||
postcommitshacode = sh(script: "git rev-parse --verify HEAD", returnStdout: true).trim()
|
||||
echo "Post commit sha code: ${postcommitshacode}"
|
||||
}
|
||||
|
||||
ArrayList<String> taglist = maketaglist(buildmeta, buildstamptag, otherreleasetags)
|
||||
def tagadded = releasegittags(postcommitshacode, taglist)
|
||||
|
||||
if (changed || tagadded) {
|
||||
releasegitpush(dryrunpush)
|
||||
}
|
||||
}
|
||||
dir(sourcerepo) {
|
||||
def String srcbuildstamptag = buildmeta.globalreleasetag()
|
||||
def String buildsha = buildmeta.gitinfo.gitrevision
|
||||
|
||||
if (buildsha) {
|
||||
def ArrayList<String> srctaglist = maketaglist(buildmeta, srcbuildstamptag, otherreleasetags)
|
||||
def tagadded = sourcegittags(buildsha, srctaglist)
|
||||
if (tagadded) {
|
||||
sourcegitpush(dryrunpush)
|
||||
}
|
||||
} else {
|
||||
summaryappend(",No Src ")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def releasecomponent(toplevelbuildmeta, buildinfo, String otherreleasetags, String dryrunpush) {
|
||||
def buildmeta = buildinfo.metainfo
|
||||
def uriconverted = gh.uniquereporootname(buildmeta.gitinfo.remoteurl)
|
||||
def String uniquefolder = "${buildmeta.productinfo.productname}_${buildmeta.productinfo.subcomponentname}_${uriconverted}"
|
||||
def String uniquefolderforrepo = "${releaserepofolder}/${uniquefolder}"
|
||||
def String uniquefoldertemp = "${tempfolder}/${uniquefolder}"
|
||||
def String uniquefolderforsourcerepo = "${sourcerepofolder}/${uniquefolder}"
|
||||
|
||||
summaryappend("${buildmeta.productinfo.productname} ${buildmeta.productinfo.subcomponentname}: ")
|
||||
repoandtagsappend("${buildmeta.productinfo.productname} ${buildmeta.productinfo.subcomponentname}: ")
|
||||
def previousreleasemeta = checkoutreleaserepo(buildmeta, uniquefolderforrepo)
|
||||
|
||||
checkoutsourcerepo(buildmeta, uniquefolderforsourcerepo)
|
||||
|
||||
if (getcomponentartifacts(toplevelbuildmeta, buildinfo, uniquefolderforrepo, uniquefoldertemp)) {
|
||||
gitrelease(buildmeta, previousreleasemeta, uniquefolderforrepo, uniquefolderforsourcerepo, otherreleasetags, dryrunpush)
|
||||
}
|
||||
|
||||
summaryappend("\n")
|
||||
repoandtagsappend("\n")
|
||||
}
|
||||
|
||||
def releasehierarchy(String buildfolder, String metafolder, buildmeta, String maxdepth, String otherreleasetags, String dryrunpush) {
|
||||
def int md = maxdepth.toInteger()
|
||||
resetfolders()
|
||||
preconditions()
|
||||
|
||||
// Walk the meta information to a max depth, looking for components to release
|
||||
def componentReleaseInfo = buildmeta.releasewalkerunique(md, buildfolder, metafolder)
|
||||
echo "Unique components:"
|
||||
def String versioncomponent = ""
|
||||
for (key in componentReleaseInfo.keySet()) {
|
||||
versioncomponent += "${key}\n"
|
||||
}
|
||||
echo versioncomponent
|
||||
|
||||
// Walk the meta information to a max depth, looking for components to release
|
||||
def componentReleaseInfoVersionUnique = buildmeta.releasewalkerversionunique(md, buildfolder, metafolder)
|
||||
def String versionuniquecomponent = ''
|
||||
def String versionwithpathscomponent = ''
|
||||
for (key in componentReleaseInfoVersionUnique.keySet()) {
|
||||
versionuniquecomponent += "${key}\n"
|
||||
versionwithpathscomponent += "${key}: path: ${componentReleaseInfoVersionUnique[key].accumulatedpath} meta path: ${componentReleaseInfoVersionUnique[key].accumulatedmetapath}\n"
|
||||
}
|
||||
echo 'Version unique components:'
|
||||
echo versionuniquecomponent
|
||||
|
||||
echo 'Version unique components with paths:'
|
||||
echo versionwithpathscomponent
|
||||
|
||||
if (DO_INTEGRITY_CHECK == "true") {
|
||||
if (componentReleaseInfo.size() != componentReleaseInfoVersionUnique.size()) {
|
||||
error "There are 2 or more versions of the same component being used in this hierarchy: Is this correct? (If you ignore this issue, you will get an error much later because the system cannot tag 2 different commits of the associated source code with the same label)"
|
||||
}
|
||||
}
|
||||
|
||||
for (key in componentReleaseInfo.keySet()) {
|
||||
def buildinfo = componentReleaseInfo[key]
|
||||
if (!buildinfo.metainfo.jenkinsbuildinfo.isFullBuild()) {
|
||||
error "The subcomponent: ${buildinfo.componentidentifier()} is not a full build (Some artifacts are missing)"
|
||||
}
|
||||
}
|
||||
|
||||
def toplevelid = buildmeta.componentidentifier()
|
||||
// For each component
|
||||
for (key in componentReleaseInfo.keySet()) {
|
||||
def buildinfo = componentReleaseInfo[key]
|
||||
echo "Releasing component: ${buildinfo.metainfo.componentidentifier()}"
|
||||
if (buildinfo.metainfo.componentidentifier() != '___' && buildinfo.metainfo.componentidentifier() != '_') {
|
||||
if (toplevelid != key) {
|
||||
releasecomponent(buildmeta, buildinfo, otherreleasetags, dryrunpush)
|
||||
}
|
||||
}
|
||||
}
|
||||
// Do the top level last
|
||||
def toplevelbuildinfo = componentReleaseInfo[toplevelid]
|
||||
releasecomponent(buildmeta, toplevelbuildinfo, otherreleasetags, dryrunpush)
|
||||
|
||||
return [summarystring, markunstable, unstablereason]
|
||||
}
|
||||
|
||||
return this;
|
||||
12
Common_scripts/release/registerrepo.groovy
Normal file
12
Common_scripts/release/registerrepo.groovy
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
|
||||
vc = load("${autobuilder.commonscripts()}/versioncontrol/git.groovy")
|
||||
|
||||
// Prove the existence of the release repo - otherwise there is a large wait to cycle the build to correct the meta data
|
||||
def registerrepo(meta, String releaserepo) {
|
||||
if (releaserepo?.trim()) {
|
||||
vc.checkRepoExists(releaserepo)
|
||||
}
|
||||
meta.releaseinfo.set(releaserepo)
|
||||
}
|
||||
|
||||
return this;
|
||||
87
Common_scripts/release/release.groovy
Normal file
87
Common_scripts/release/release.groovy
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
pipeline {
|
||||
agent { label AGENT_LABEL }
|
||||
stages {
|
||||
stage('Initial setup') {
|
||||
steps {
|
||||
script {
|
||||
autobuilderscript = load("${WORKSPACE}/autobuild/Common_scripts/autobuilder.groovy")
|
||||
meta = autobuilderscript.startnonbuild(this)
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Clean exports') {
|
||||
steps {
|
||||
script {
|
||||
cleanfolders = [
|
||||
"${WORKSPACE}/build_artifacts",
|
||||
]
|
||||
cleaner = load("${autobuilder.commonscripts()}/clean/clean.groovy")
|
||||
cleaner.clean(cleanfolders)
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Get build artifact meta') {
|
||||
steps {
|
||||
script {
|
||||
importer = load("${autobuilder.commonscripts()}/import/importer.groovy")
|
||||
|
||||
BUILD_ARTIFACTS = 'build'
|
||||
|
||||
def importoptions = importer.getNewImportOptions()
|
||||
importoptions.jenkinsjob(BUILD_JOB, BUILD_JOB_SELECTOR)
|
||||
importoptions.setincrementversionnumber(false)
|
||||
importoptions.setfilter('meta/**')
|
||||
importoptions.setappendtoparentmeta(false)
|
||||
buildmeta = importer.artifactimport(meta, importoptions, BUILD_ARTIFACTS)
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Release components') {
|
||||
steps {
|
||||
script {
|
||||
def releaser = load("${autobuilder.commonscripts()}/release/do.groovy")
|
||||
// Place the top level build stamp on all
|
||||
OTHER_RELEASE_TAGS = "${buildmeta.globalreleasetag()},${OTHER_RELEASE_TAGS}"
|
||||
(summarystring, markunstable, unstablereason) = releaser.releasehierarchy('', BUILD_ARTIFACTS, buildmeta, MAX_META_DEPTH, OTHER_RELEASE_TAGS, DRY_RUN_PUSH)
|
||||
if (markunstable) {
|
||||
env.unstablereason = unstablereason
|
||||
currentBuild.result = 'UNSTABLE'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Archiving artifacts') {
|
||||
steps {
|
||||
script {
|
||||
def artifactlist = meta.generateartifacts()
|
||||
artifactarchiver = load("${autobuilder.commonscripts()}/artifacts/archiver.groovy")
|
||||
artifactarchiver.archive("summary/**,${artifactlist}")
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Summarise') {
|
||||
steps {
|
||||
script {
|
||||
echo "Summary:\n${summarystring}\n"
|
||||
if (env.unstablereason) {
|
||||
echo "Instability reason: ${env.unstablereason}"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
post {
|
||||
always {
|
||||
echo 'Post-build'
|
||||
}
|
||||
failure {
|
||||
echo 'Failed build'
|
||||
}
|
||||
unstable {
|
||||
echo 'Unstable build'
|
||||
}
|
||||
success {
|
||||
echo 'Succeeded build'
|
||||
}
|
||||
}
|
||||
}
|
||||
32
Common_scripts/remoteaccess/ftp.groovy
Normal file
32
Common_scripts/remoteaccess/ftp.groovy
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
import org.apache.commons.net.ftp.FTPClient
|
||||
|
||||
class FTPSiteInfo {
|
||||
String url
|
||||
String username
|
||||
String password
|
||||
String workingdirectory
|
||||
|
||||
FTPSiteInfo(String url, String username, String password, String workingdirectory) {
|
||||
this.url = url
|
||||
this.username = username
|
||||
this.password = password
|
||||
this.workingdirectory = workingdirectory
|
||||
}
|
||||
}
|
||||
|
||||
FTPSiteInfo createFTPSiteInfo(String url, String username, String password, String workingdirectory) {
|
||||
FTPSiteInfo ftpsiteinfo = new FTPSiteInfo(url, username, password, workingdirectory)
|
||||
return ftpsiteinfo
|
||||
}
|
||||
|
||||
FTPClient createFTPClient(FTPSiteInfo ftpsiteinfo) {
|
||||
FTPClient ftpclient = new FTPClient()
|
||||
ftpclient.connect(ftpsiteinfo.url)
|
||||
ftpclient.enterLocalPassiveMode()
|
||||
ftpclient.login(ftpsiteinfo.username, ftpsiteinfo.password)
|
||||
ftpclient.changeWorkingDirectory(ftpsiteinfo.workingdirectory)
|
||||
|
||||
return ftpclient
|
||||
}
|
||||
|
||||
return this;
|
||||
28
Common_scripts/remoteaccess/hostedftp.groovy
Normal file
28
Common_scripts/remoteaccess/hostedftp.groovy
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
ftpremote = load("${autobuilder.commonscripts()}/remoteaccess/ftp.groovy")
|
||||
|
||||
def getHostedFTPSiteInfo() {
|
||||
hostedftpsiteinfo =
|
||||
ftpremote.createFTPSiteInfo("ftp.hostedftp.com",
|
||||
"ftp@globalinkjetsystems.com",
|
||||
"ramshorn42",
|
||||
"/Customers/")
|
||||
return hostedftpsiteinfo
|
||||
}
|
||||
|
||||
def getCustomerList() {
|
||||
def List<String> customerfilenames = new ArrayList<String>()
|
||||
def List<String> customers = new ArrayList<String>()
|
||||
|
||||
def ftpsiteinfo = getHostedFTPSiteInfo()
|
||||
def ftpclient = ftpremote.createFTPClient(ftpsiteinfo)
|
||||
|
||||
customerfilenames = ftpclient.listNames()
|
||||
for(customer in customerfilenames) {
|
||||
def String converted = new String(customer.getBytes("ISO-8859-1"), "UTF-8")
|
||||
customers.add(converted)
|
||||
}
|
||||
ftpclient.disconnect()
|
||||
return customers
|
||||
}
|
||||
|
||||
return this;
|
||||
85
Common_scripts/staticanalysis/ccm.groovy
Normal file
85
Common_scripts/staticanalysis/ccm.groovy
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
pipeline {
|
||||
agent { label AGENT_LABEL }
|
||||
stages {
|
||||
stage('Initial setup') {
|
||||
steps {
|
||||
script {
|
||||
meta = load("${WORKSPACE}/autobuild/Common_scripts/autobuilder.groovy").startnonbuild(this)
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Checkout dependencies') {
|
||||
steps {
|
||||
script {
|
||||
configurationhelper = autobuilder.configurationhelper()
|
||||
|
||||
CCMURL = 'git@hydra:tools/ccm.git'
|
||||
CCMBRANCH = 'origin/master'
|
||||
CCMDIR = "${WORKSPACE}/ccm"
|
||||
configurationhelper.gitCheckoutAndRegister(meta, 'ccm', CCMURL, CCMBRANCH, CCMDIR)
|
||||
CCM = "${CCMDIR}/bin/CCM.exe"
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Checkout source') {
|
||||
steps {
|
||||
script {
|
||||
SOURCEDIR = "${WORKSPACE}/source"
|
||||
configurationhelper.gitCheckoutAndRegister(meta, 'source', SOURCEURL, SOURCE_REVISION, SOURCEDIR, '', 0, false)
|
||||
}
|
||||
}
|
||||
}
|
||||
stage("Clean exports") {
|
||||
steps {
|
||||
script {
|
||||
RESULTS = 'results'
|
||||
cleanfolders = [
|
||||
RESULTS,
|
||||
]
|
||||
cleaner = load("${autobuilder.commonscripts()}/clean/clean.groovy")
|
||||
cleaner.clean(cleanfolders)
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Static analysis') {
|
||||
steps {
|
||||
script {
|
||||
def ccmconfigurationfile = "${WORKSPACE}/ccm.xml"
|
||||
writeFile(file: ccmconfigurationfile, text: CCM_CONFIGURATION)
|
||||
echo "Configuration file: ${ccmconfigurationfile} contains:\n${CCM_CONFIGURATION}"
|
||||
|
||||
dir(RESULTS) {
|
||||
echo "Executing: ${CCM} ${ccmconfigurationfile} > ccm.xml"
|
||||
if (isUnix()) {
|
||||
sh """#!/bin/bash
|
||||
${CCM}" "${ccmconfigurationfile}" > ccm.xml
|
||||
"""
|
||||
} else {
|
||||
echo "Executing: ${WINDOWS_COMMANDLINE_ENVIRONMENT} \"${CCM}\" \"${ccmconfigurationfile}\" > ccm.xml"
|
||||
bat """
|
||||
${WINDOWS_COMMANDLINE_ENVIRONMENT} "${CCM}" "${ccmconfigurationfile}" > ccm.xml
|
||||
"""
|
||||
}
|
||||
}
|
||||
recordIssues(tools: [
|
||||
ccm(pattern: "**/ccm.xml", reportEncoding: 'UTF-8'),
|
||||
])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
post {
|
||||
always {
|
||||
echo 'Post-build'
|
||||
}
|
||||
failure {
|
||||
echo 'Failed build'
|
||||
}
|
||||
unstable {
|
||||
echo 'Unstable build'
|
||||
}
|
||||
success {
|
||||
echo 'Succeeded build'
|
||||
}
|
||||
}
|
||||
}
|
||||
152
Common_scripts/staticanalysis/cpd.groovy
Normal file
152
Common_scripts/staticanalysis/cpd.groovy
Normal file
|
|
@ -0,0 +1,152 @@
|
|||
pipeline {
|
||||
agent { label AGENT_LABEL }
|
||||
stages {
|
||||
stage('Initial setup') {
|
||||
steps {
|
||||
script {
|
||||
meta = load("${WORKSPACE}/autobuild/Common_scripts/autobuilder.groovy").startnonbuild(this)
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Checkout dependencies') {
|
||||
steps {
|
||||
script {
|
||||
configurationhelper = autobuilder.configurationhelper()
|
||||
|
||||
PYTHONURL = 'git@hydra:tools/python.git'
|
||||
if (isUnix()) {
|
||||
PYTHONBRANCH = 'origin/3.6.3_linux'
|
||||
} else {
|
||||
PYTHONBRANCH = 'origin/3.6.3_windows'
|
||||
}
|
||||
PYTHONDIR = "${WORKSPACE}/python"
|
||||
configurationhelper.gitCheckoutAndRegister(meta, 'python', PYTHONURL, PYTHONBRANCH, PYTHONDIR)
|
||||
env.PYTHON = "${PYTHONDIR}/ver/python.exe"
|
||||
|
||||
JAVAURL = 'git@hydra:tools/openjdk.git'
|
||||
if (isUnix()) {
|
||||
JAVABRANCH = 'origin/openjdk-11.0.2_linux-x64_bin'
|
||||
} else {
|
||||
JAVABRANCH = 'origin/openjdk-11.0.2_windows-x64_bin'
|
||||
}
|
||||
JAVADIR = "${WORKSPACE}/java"
|
||||
configurationhelper.gitCheckoutAndRegister(meta, 'java', JAVAURL, JAVABRANCH, JAVADIR)
|
||||
JAVA = "${JAVADIR}/ver/bin"
|
||||
if (isUnix()) {
|
||||
env.PATH = JAVA + ':' + PATH
|
||||
} else {
|
||||
env.PATH = JAVA + ';' + PATH
|
||||
}
|
||||
|
||||
PPDURL = 'git@hydra:tools/pmd.git'
|
||||
PPDBRANCH = 'origin/master'
|
||||
PPDDIR = "${WORKSPACE}/ppd"
|
||||
configurationhelper.gitCheckoutAndRegister(meta, 'ppd', PPDURL, PPDBRANCH, PPDDIR)
|
||||
PPD = "${PPDDIR}/bin"
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Checkout source') {
|
||||
steps {
|
||||
script {
|
||||
SOURCEREVISION = "${SOURCE_REVISION}"
|
||||
SOURCEDIR = "${WORKSPACE}/source"
|
||||
configurationhelper.gitCheckoutAndRegister(meta, 'source', SOURCEURL, SOURCEREVISION, SOURCEDIR, '', 0, false)
|
||||
SOURCE_PATH = "${SOURCEDIR}"
|
||||
SRC = "${SOURCE_PATH}"
|
||||
if (SOURCE_OFFSET_PATH) {
|
||||
SRC += "/${SOURCE_OFFSET_PATH}"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
stage("Clean exports") {
|
||||
steps {
|
||||
script {
|
||||
STATICANALYSIS = 'staticanalysis'
|
||||
cleanfolders = [
|
||||
STATICANALYSIS,
|
||||
]
|
||||
cleaner = load("${autobuilder.commonscripts()}/clean/clean.groovy")
|
||||
cleaner.clean(cleanfolders)
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Generating version info') {
|
||||
steps {
|
||||
script {
|
||||
version = load("${autobuilder.commonscripts()}/versionnumbering/generate.groovy")
|
||||
version.generate(meta, SOURCE_REVISION, SOURCE_PATH)
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Static analysis') {
|
||||
steps {
|
||||
script {
|
||||
def PPDFOLDER = "${STATICANALYSIS}/ppd"
|
||||
def EXCLUDE_PARAM = ''
|
||||
if (EXCLUDE_PATHS) {
|
||||
EXCLUDE_PARAM = '--exclude "'
|
||||
def exclude_path_list = EXCLUDE_PATHS.split(',')
|
||||
for (exclude_path in exclude_path_list) {
|
||||
EXCLUDE_PARAM += "${SRC}/${exclude_path.trim()},"
|
||||
}
|
||||
EXCLUDE_PARAM += '"'
|
||||
}
|
||||
if (isUnix()) {
|
||||
sh """#!/bin/bash
|
||||
set -ev
|
||||
|
||||
mkdir -p "${PPDFOLDER}"
|
||||
export PMD_JAVA_OPTS=-Xmx65536m
|
||||
"${PPD}/run.sh" cpd --minimum-tokens 100 --files "${SRC}" --language cpp --format xml ${EXCLUDE_PARAM} --failOnViolation false > "${PPDFOLDER}/cpd.xml"
|
||||
"""
|
||||
} else {
|
||||
bat """
|
||||
mkdir -p "${PPDFOLDER}"
|
||||
set PMD_JAVA_OPTS=-Xmx2048m
|
||||
"${PPD}/cpd.bat" --minimum-tokens 100 --files "${SRC}" --language cpp --format xml ${EXCLUDE_PARAM} --failOnViolation false > "${PPDFOLDER}/cpd.xml"
|
||||
"""
|
||||
}
|
||||
recordIssues(tools: [
|
||||
cpd(pattern: "**/cpd.xml", reportEncoding: 'UTF-8'),
|
||||
])
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Classifying publishable artifacts') {
|
||||
steps {
|
||||
script {
|
||||
def publishable = [
|
||||
]
|
||||
publishutils = load("${autobuilder.commonscripts()}/publishing/utils.groovy")
|
||||
publishutils.generatelist(meta, publishable)
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Archiving artifacts') {
|
||||
steps {
|
||||
script {
|
||||
ArrayList<String> itemsForRelease = ["${STATICANALYSIS}/**"]
|
||||
def artifactlist = meta.generateartifacts(itemsForRelease)
|
||||
artifactarchiver = load("${autobuilder.commonscripts()}/artifacts/archiver.groovy")
|
||||
artifactarchiver.archive(meta, artifactlist)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
post {
|
||||
always {
|
||||
echo 'Post-build'
|
||||
}
|
||||
failure {
|
||||
echo 'Failed build'
|
||||
}
|
||||
unstable {
|
||||
echo 'Unstable build'
|
||||
}
|
||||
success {
|
||||
echo 'Succeeded build'
|
||||
}
|
||||
}
|
||||
}
|
||||
114
Common_scripts/staticanalysis/cppcheck.groovy
Normal file
114
Common_scripts/staticanalysis/cppcheck.groovy
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
pipeline {
|
||||
agent { label AGENT_LABEL }
|
||||
stages {
|
||||
stage('Initial setup') {
|
||||
steps {
|
||||
script {
|
||||
meta = load("${WORKSPACE}/autobuild/Common_scripts/autobuilder.groovy").startnonbuild(this)
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Checkout dependencies') {
|
||||
steps {
|
||||
script {
|
||||
configurationhelper = autobuilder.configurationhelper()
|
||||
|
||||
PYTHONURL = 'git@hydra:tools/python.git'
|
||||
PYTHONBRANCH = 'origin/3.6.3_windows'
|
||||
PYTHONDIR = "${WORKSPACE}/python"
|
||||
configurationhelper.gitCheckoutAndRegister(meta, 'python', PYTHONURL, PYTHONBRANCH, PYTHONDIR)
|
||||
env.PYTHON = "${PYTHONDIR}/ver/python.exe"
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Checkout source') {
|
||||
steps {
|
||||
script {
|
||||
SOURCEREVISION = "${SOURCE_REVISION}"
|
||||
SOURCEDIR = "${WORKSPACE}/source"
|
||||
configurationhelper.gitCheckoutAndRegister(meta, 'source', SOURCEURL, SOURCEREVISION, SOURCEDIR, '', 0, false)
|
||||
SOURCE_PATH = "${SOURCEDIR}"
|
||||
env.SRC = "${SOURCE_PATH}/${SOURCE_OFFSET_PATH}"
|
||||
}
|
||||
}
|
||||
}
|
||||
stage("Clean exports") {
|
||||
steps {
|
||||
script {
|
||||
STATICANALYSIS = 'staticanalysis'
|
||||
cleanfolders = [
|
||||
STATICANALYSIS,
|
||||
]
|
||||
cleaner = load("${autobuilder.commonscripts()}/clean/clean.groovy")
|
||||
cleaner.clean(cleanfolders)
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Generating version info') {
|
||||
steps {
|
||||
script {
|
||||
version = load("${autobuilder.commonscripts()}/versionnumbering/generate.groovy")
|
||||
version.generate(meta, SOURCE_REVISION, SOURCE_PATH)
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Static analysis') {
|
||||
steps {
|
||||
script {
|
||||
def CPPCHECKFOLDER = "${STATICANALYSIS}/cppcheck"
|
||||
dir(CPPCHECKFOLDER) {
|
||||
echo "Executing: ${CPPCHECK} --xml --xml-version=2 ${SRC} 2> cppcheck.xml"
|
||||
if (isUnix()) {
|
||||
sh """#!/bin/bash
|
||||
set -e
|
||||
|
||||
"${CPPCHECK}" --xml --xml-version=2 "${SRC}" 2> cppcheck.xml
|
||||
"""
|
||||
} else {
|
||||
bat """
|
||||
"${CPPCHECK}" --xml --xml-version=2 "${SRC}" 2> cppcheck.xml
|
||||
"""
|
||||
}
|
||||
}
|
||||
recordIssues(tools: [
|
||||
cppCheck(pattern: "**/cppcheck.xml", reportEncoding: 'UTF-8'),
|
||||
])
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Classifying publishable artifacts') {
|
||||
steps {
|
||||
script {
|
||||
def publishable = [
|
||||
]
|
||||
publishutils = load("${autobuilder.commonscripts()}/publishing/utils.groovy")
|
||||
publishutils.generatelist(meta, publishable)
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Archiving artifacts') {
|
||||
steps {
|
||||
script {
|
||||
ArrayList<String> itemsForRelease = ["${STATICANALYSIS}/**"]
|
||||
def artifactlist = meta.generateartifacts(itemsForRelease)
|
||||
artifactarchiver = load("${autobuilder.commonscripts()}/artifacts/archiver.groovy")
|
||||
artifactarchiver.archive(meta, artifactlist)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
post {
|
||||
always {
|
||||
echo 'Post-build'
|
||||
}
|
||||
failure {
|
||||
echo 'Failed build'
|
||||
}
|
||||
unstable {
|
||||
echo 'Unstable build'
|
||||
}
|
||||
success {
|
||||
echo 'Succeeded build'
|
||||
}
|
||||
}
|
||||
}
|
||||
204
Common_scripts/test/testethernetproduct.groovy
Normal file
204
Common_scripts/test/testethernetproduct.groovy
Normal file
|
|
@ -0,0 +1,204 @@
|
|||
import jenkins.model.Jenkins
|
||||
|
||||
pipeline {
|
||||
agent { label AGENT_LABEL }
|
||||
stages {
|
||||
stage ("Initial Setup") {
|
||||
steps{
|
||||
script {
|
||||
meta = load("${WORKSPACE}/autobuild/Common_scripts/autobuilder.groovy").startnonbuild(this)
|
||||
}
|
||||
}
|
||||
}
|
||||
stage ("Checkout test environment") {
|
||||
steps {
|
||||
script {
|
||||
toolsimporter = load("${autobuilder.commonscripts()}/configuration/tools.groovy")
|
||||
|
||||
def TEST_ENVIRONMENT_URL = 'git@hydra:gistest/jenkins-ethernet-test-environment.git'
|
||||
def TEST_ENVIRONMENT_DIR = 'TestEnvironmentDir'
|
||||
def TEST_ENVIRONMENT_REVISION = 'origin/master'
|
||||
|
||||
def environmentoptions = toolsimporter.getNewToolOptions()
|
||||
environmentoptions.toolName('Ethernet product test environment')
|
||||
environmentoptions.toolRepo(TEST_ENVIRONMENT_URL, TEST_SOURCE_REVISION)
|
||||
toolsimporter.getTool(meta, environmentoptions, TEST_ENVIRONMENT_DIR)
|
||||
|
||||
TEST_ENVIRONMENT_FILE = "${TEST_ENVIRONMENT_DIR}/environment.json"
|
||||
def alltestenvironment = readJSON(file: "${TEST_ENVIRONMENT_FILE}")
|
||||
TEST_ENVIRONMENT = alltestenvironment[ETHERNET_PRODUCT_TO_RUN_TEST]
|
||||
echo "Selected environment:\n${TEST_ENVIRONMENT}"
|
||||
}
|
||||
}
|
||||
}
|
||||
stage ('Setup') {
|
||||
agent { label TEST_ENVIRONMENT['FTDI_AGENT'] }
|
||||
stages {
|
||||
stage ("Checkout dependencies") {
|
||||
steps {
|
||||
script {
|
||||
def PYTHON_URL = 'git@hydra:tools/python.git'
|
||||
if (isUnix()) {
|
||||
PYTHON_REVISION = 'origin/3.6.3_linux'
|
||||
}
|
||||
else {
|
||||
PYTHON_REVISION = 'origin/3.8.10_windows_for_test'
|
||||
}
|
||||
PYTHONDIR = "${WORKSPACE}/python"
|
||||
|
||||
def pythonimportoptions = toolsimporter.getNewToolOptions()
|
||||
pythonimportoptions.toolName('Python')
|
||||
pythonimportoptions.toolRepo(PYTHON_URL, PYTHON_REVISION)
|
||||
toolsimporter.getTool(meta, pythonimportoptions, PYTHONDIR)
|
||||
if (isUnix()) {
|
||||
env.PYTHON = "${PYTHONDIR}/usr/local/bin/python3"
|
||||
}
|
||||
else {
|
||||
env.PYTHON = "${PYTHONDIR}/ver/python.exe"
|
||||
}
|
||||
|
||||
def TEST_SOURCE_URL = 'git@hydra:hmb_regression/hmb_tests.git'
|
||||
TEST_SUITE_DIR = 'TestSuiteDir'
|
||||
env.GIS_TEST_SUITE_HOME = "${WORKSPACE}/${TEST_SUITE_DIR}"
|
||||
|
||||
def regressiontestimportoptions = toolsimporter.getNewToolOptions()
|
||||
regressiontestimportoptions.toolName('Tests')
|
||||
regressiontestimportoptions.toolRepo(TEST_SOURCE_URL, TEST_SOURCE_REVISION)
|
||||
toolsimporter.getTool(meta, regressiontestimportoptions, GIS_TEST_SUITE_HOME)
|
||||
|
||||
env.HISTORY_FOLDER = "${WORKSPACE}/testhistory"
|
||||
|
||||
def resultimportoptions = toolsimporter.getNewToolOptions()
|
||||
resultimportoptions.toolName('Test history')
|
||||
resultimportoptions.toolRepo(HISTORY_REPO, HISTORY_REVISION)
|
||||
toolsimporter.getTool(meta, resultimportoptions, HISTORY_FOLDER)
|
||||
|
||||
def CORE_SOURCE_URL = 'git@hydra:gistest/giscorelite.git'
|
||||
env.GIS_TEST_SUITE_CORE = "${WORKSPACE}/GisCore"
|
||||
|
||||
def coreimportoptions = toolsimporter.getNewToolOptions()
|
||||
coreimportoptions.toolName('Test core')
|
||||
coreimportoptions.toolRepo(CORE_SOURCE_URL, CORE_SOURCE_REVISION)
|
||||
toolsimporter.getTool(meta, coreimportoptions, GIS_TEST_SUITE_CORE)
|
||||
|
||||
def FTDI_SOURCE_URL = 'git@hydra:python_scripts/ftdi_relay.git'
|
||||
def FTDI_SOURCE_REVISION = 'origin/Core-98'
|
||||
FTDI_SOURCE_DIR = "${WORKSPACE}/PowerController"
|
||||
|
||||
def ftdiimportoptions = toolsimporter.getNewToolOptions()
|
||||
ftdiimportoptions.toolName('FTDI relay driver')
|
||||
ftdiimportoptions.toolRepo(FTDI_SOURCE_URL, FTDI_SOURCE_REVISION)
|
||||
toolsimporter.getTool(meta, ftdiimportoptions, FTDI_SOURCE_DIR)
|
||||
|
||||
def HISTORY_PROCESSING_REPO = 'git@hydra:gistestresults/ethernet-products-history-processing.git'
|
||||
HISTORY_PROCESSING_DIR = "${WORKSPACE}/HistoryProcessing"
|
||||
|
||||
def resultprocessingoptions = toolsimporter.getNewToolOptions()
|
||||
resultprocessingoptions.toolName('History processing')
|
||||
resultprocessingoptions.toolRepo(HISTORY_PROCESSING_REPO, HISTORY_PROCESSING_REVISION)
|
||||
toolsimporter.getTool(meta, resultprocessingoptions, HISTORY_PROCESSING_DIR)
|
||||
}
|
||||
}
|
||||
}
|
||||
stage ("Import application to test") {
|
||||
steps {
|
||||
script {
|
||||
importer = load("${autobuilder.commonscripts()}/import/importer.groovy")
|
||||
|
||||
APPLICATION_UNDER_TEST = 'application_under_test'
|
||||
env.APPLICATION_ARTIFACT_FOLDER = "${WORKSPACE}/${APPLICATION_UNDER_TEST}"
|
||||
|
||||
def applicationimportoptions = importer.getNewImportOptions()
|
||||
applicationimportoptions.jenkinsjob(APPLICATION_ARTIFACT_PROJECT, APPLICATION_ARTIFACT_SELECTOR)
|
||||
applicationimportoptions.setfilter('app_package/**,control_package/**')
|
||||
applicationmeta = importer.artifactimport(meta, applicationimportoptions, APPLICATION_ARTIFACT_FOLDER)
|
||||
|
||||
meta.productinfo.set(applicationmeta.productinfo)
|
||||
meta.productinfo.subcomponentname = "${applicationmeta.productinfo.subcomponentname}_TEST"
|
||||
meta.gitinfo.set(applicationmeta.gitinfo)
|
||||
meta.buildstampinfo.set(applicationmeta.buildstampinfo)
|
||||
}
|
||||
}
|
||||
}
|
||||
stage("Clean") {
|
||||
steps {
|
||||
script {
|
||||
LOGGING_ROOT = 'Logging'
|
||||
env.GIS_TEST_OUTPUT_LOGGING_ROOT = "${WORKSPACE}/${LOGGING_ROOT}"
|
||||
cleanfolders = [
|
||||
GIS_TEST_OUTPUT_LOGGING_ROOT,
|
||||
]
|
||||
cleaner = load("${autobuilder.commonscripts()}/clean/clean.groovy")
|
||||
cleaner.clean(cleanfolders)
|
||||
}
|
||||
}
|
||||
}
|
||||
stage ('Test') {
|
||||
steps {
|
||||
script {
|
||||
lock(TEST_ENVIRONMENT['RESOURCE_LOCK']) {
|
||||
if (POWER_CYCLE_HARDWARE == 'true') {
|
||||
dir(FTDI_SOURCE_DIR) {
|
||||
bat """
|
||||
"${PYTHON}" "${FTDI_SOURCE_DIR}/RegressionPower.py" -d ${TEST_ENVIRONMENT['FTDI_RELAY_DEVICE']} -o True
|
||||
"""
|
||||
}
|
||||
}
|
||||
if (UPDATE_HARDWARE == 'true') {
|
||||
dir(GIS_TEST_SUITE_CORE) {
|
||||
bat """
|
||||
"${PYTHON}" "${GIS_TEST_SUITE_CORE}/HMBCommon/hmbPackageDeployer.py" -p "${APPLICATION_ARTIFACT_FOLDER}" -t "${TEST_ENVIRONMENT['IP_ADDRESS']}"
|
||||
"""
|
||||
rc = bat (script:"""
|
||||
"${PYTHON}" "${GIS_TEST_SUITE_CORE}/HMBCommon/hmbinspectstate.py"
|
||||
""",
|
||||
returnStatus: true)
|
||||
if (rc == 1) {
|
||||
unstable('FAILED while inspecting state of hardware')
|
||||
}
|
||||
}
|
||||
}
|
||||
if (DO_TEST == 'true') {
|
||||
rc = bat(script:"""
|
||||
${PYTHON} "${GIS_TEST_SUITE_CORE}/GISTestMaster.py" -w ${PRODUCT_LOCATION_UNDER_TEST} -fl --include ${TEST_INCLUDE_FILTER}
|
||||
""",
|
||||
returnStatus: true
|
||||
)
|
||||
if (rc == 1) {
|
||||
unstable('FAILED while running tests')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
stage("Archive Test History") {
|
||||
steps{
|
||||
script {
|
||||
dir(HISTORY_FOLDER) {
|
||||
rc = bat (script:"""
|
||||
"${PYTHON}" "${HISTORY_PROCESSING_DIR}/GitCyclicPush.py"
|
||||
""",
|
||||
returnStatus: true
|
||||
)
|
||||
if (rc == 1) {
|
||||
unstable('FAILED to process history')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
stage("Archive test artifacts"){
|
||||
steps{
|
||||
script {
|
||||
def artifactlist = meta.generateartifacts([ "${LOGGING_ROOT}/**"])
|
||||
artifactarchiver = load("${autobuilder.commonscripts()}/artifacts/archiver.groovy")
|
||||
artifactarchiver.archive(meta, artifactlist)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
8
Common_scripts/textutils/subst.groovy
Normal file
8
Common_scripts/textutils/subst.groovy
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
|
||||
def substitute(String filepath, pattern, String subst) {
|
||||
fileText = readFile(file: filepath, encoding: 'UTF-8')
|
||||
def converted = fileText.replaceAll(pattern, subst)
|
||||
writeFile(file: filepath, text: converted, encoding: 'UTF-8')
|
||||
}
|
||||
|
||||
return this;
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
"version": "1.0",
|
||||
"components": [
|
||||
"Microsoft.VisualStudio.Workload.ManagedDesktop",
|
||||
"Microsoft.VisualStudio.Workload.NativeDesktop",
|
||||
"Microsoft.VisualStudio.Workload.NetWeb",
|
||||
"Microsoft.VisualStudio.Workload.NetCoreTools",
|
||||
"microsoft.net.componentgroup.targetingpacks.common",
|
||||
"microsoft.componentgroup.blend",
|
||||
"microsoft.visualstudio.component.entityframework",
|
||||
"microsoft.visualstudio.component.debugger.justintime",
|
||||
"microsoft.visualstudio.component.wcf.tooling",
|
||||
"microsoft.visualstudio.component.vc.diagnostictools",
|
||||
"microsoft.visualstudio.component.vc.cmake.project",
|
||||
"microsoft.visualstudio.component.vc.testadapterforboosttest",
|
||||
"microsoft.visualstudio.component.vc.testadapterforgoogletest",
|
||||
"microsoft.visualstudio.component.vc.atlmfc",
|
||||
"microsoft.visualstudio.component.appinsights.tools",
|
||||
"microsoft.visualstudio.component.diagnostictools",
|
||||
"microsoft.visualstudio.componentgroup.web.cloudtools",
|
||||
"microsoft.visualstudio.component.aspnet45",
|
||||
"microsoft.visualstudio.component.webdeploy",
|
||||
"microsoft.visualstudio.component.nuget.buildtools"
|
||||
]
|
||||
}
|
||||
377
Common_scripts/versioncontrol/git.groovy
Normal file
377
Common_scripts/versioncontrol/git.groovy
Normal file
|
|
@ -0,0 +1,377 @@
|
|||
import hudson.plugins.git.*
|
||||
import hudson.plugins.git.extensions.*
|
||||
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 = powershell(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')
|
||||
}
|
||||
}
|
||||
|
||||
ArrayList<String> gettaglist(String workingSetRootPath) {
|
||||
ArrayList<String> taglist = new ArrayList<String>()
|
||||
dir(workingSetRootPath) {
|
||||
def tagliststring = clh.getCommandOutput('git tag --sort=-version:refname')
|
||||
taglist = tagliststring.split('\\n')
|
||||
}
|
||||
return taglist
|
||||
}
|
||||
|
||||
@NonCPS
|
||||
def ArrayList<SparseCheckoutPath> sparsecheckoutconfig(ArrayList<String> paths) {
|
||||
ArrayList<SparseCheckoutPath> sparsecheckoutpaths = new ArrayList<SparseCheckoutPath>()
|
||||
for (path in paths) {
|
||||
sparsecheckoutpaths.add(new SparseCheckoutPath(path))
|
||||
}
|
||||
return sparsecheckoutpaths
|
||||
}
|
||||
|
||||
def String uniquereporootname(String gitURL) {
|
||||
def uniquename = gitURL.replaceAll("[^A-Za-z0-9]", "_")
|
||||
echo "Unique reporoot name for URL: ${gitURL} is: ${uniquename}"
|
||||
return uniquename
|
||||
}
|
||||
|
||||
// The REPO_ROOT is a folder where a cache of git checkouts can be kept - each subfolder name is unique to a particular git repo
|
||||
def String checkouttoreporoot(String gitURL) {
|
||||
def String reporootsubfolder
|
||||
def String reporootenv = env.REPO_ROOT
|
||||
if (!reporootenv) {
|
||||
reporootsubfolder = ""
|
||||
echo "To improve Git performance: Define the REPO_ROOT enviroment to a path where a cache of git repositories can be placed on this slave"
|
||||
} else {
|
||||
def reporootname = uniquereporootname(gitURL)
|
||||
reporootsubfolder = "${reporootenv}/${reporootname}"
|
||||
|
||||
if (!fileExists(reporootsubfolder)) {
|
||||
echo "Checking out ${gitURL} to ${reporootsubfolder}"
|
||||
checkout([
|
||||
$class: 'GitSCM',
|
||||
userRemoteConfigs: [
|
||||
[url: gitURL]
|
||||
],
|
||||
branches: [
|
||||
[name: 'origin/master']
|
||||
],
|
||||
doGenerateSubmoduleConfigurations: false,
|
||||
extensions: [
|
||||
[$class: 'GitLFSPull'],
|
||||
[$class: 'CleanBeforeCheckout'],
|
||||
[$class: 'CheckoutOption', timeout: 180],
|
||||
[$class: 'RelativeTargetDirectory', relativeTargetDir: reporootsubfolder],
|
||||
],
|
||||
submoduleCfg: [],
|
||||
])
|
||||
} else {
|
||||
echo "Found ${gitURL} checked out at ${reporootsubfolder}"
|
||||
/*
|
||||
dir(reporootsubfolder) {
|
||||
if (isUnix()) {
|
||||
sh """
|
||||
git status
|
||||
if [ \$? -ne 0 ]; then exit 1; fi
|
||||
"""
|
||||
} else {
|
||||
powershell """
|
||||
git status
|
||||
if (\$lastexitcode -ge 1) { exit 1 }
|
||||
"""
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
return reporootsubfolder
|
||||
}
|
||||
|
||||
def checkgitlfsinstall() {
|
||||
if (isUnix()) {
|
||||
sh """
|
||||
git lfs install
|
||||
if [ \$? -ne 0 ]; then exit 1; fi
|
||||
"""
|
||||
|
||||
} else {
|
||||
powershell """
|
||||
git lfs install
|
||||
if (\$lastexitcode -ge 1) { exit 1 }
|
||||
"""
|
||||
}
|
||||
}
|
||||
|
||||
//No credentials specified
|
||||
//Cloning the remote Git repository
|
||||
//Cloning repository git@hydra:print-server-releases/print_server_whole.git
|
||||
//> git init /home/jenkins_user/jenkins/jobs/Print_Server_publish_to_customer/ws/whole # timeout=10
|
||||
//Using reference repository: /home/jenkins_user/reporoot/git_hydra_print_server_releases_print_server_whole_git
|
||||
//Fetching upstream changes from git@hydra:print-server-releases/print_server_whole.git
|
||||
// > git --version # timeout=10
|
||||
// > git fetch --tags --progress git@hydra:print-server-releases/print_server_whole.git +refs/heads/*:refs/remotes/origin/* # timeout=120
|
||||
// > git config remote.origin.url git@hydra:print-server-releases/print_server_whole.git # timeout=10
|
||||
// > git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10
|
||||
// > git config remote.origin.url git@hydra:print-server-releases/print_server_whole.git # timeout=10
|
||||
// Cleaning workspace
|
||||
// > git rev-parse --verify HEAD # timeout=10
|
||||
// No valid HEAD. Skipping the resetting
|
||||
// > git clean -fdx # timeout=10
|
||||
// Fetching upstream changes from git@hydra:print-server-releases/print_server_whole.git
|
||||
// > git fetch --tags --progress git@hydra:print-server-releases/print_server_whole.git +refs/heads/*:refs/remotes/origin/* # timeout=120
|
||||
// > git rev-parse refs/tags/2.10180.7389.21125_7^{commit} # timeout=10
|
||||
// > git rev-parse refs/remotes/origin/refs/tags/2.10180.7389.21125_7^{commit} # timeout=10
|
||||
// Checking out Revision 64cac35e9a7603c060135f61f91b3f809bbdf160 (refs/tags/2.10180.7389.21125_7)
|
||||
// Enabling Git LFS pull
|
||||
// > git config core.sparsecheckout # timeout=10
|
||||
// > git checkout -f 64cac35e9a7603c060135f61f91b3f809bbdf160 # timeout=120
|
||||
// > git config --get remote.origin.url # timeout=10
|
||||
// > git lfs pull origin # timeout=120
|
||||
// Commit message: "2.10180.7389.21125_7"
|
||||
// > git rev-list --no-walk 64cac35e9a7603c060135f61f91b3f809bbdf160 # timeout=10
|
||||
|
||||
|
||||
// > git rev-parse --is-inside-work-tree # timeout=10
|
||||
// Fetching changes from the remote Git repository
|
||||
// > git config remote.origin.url git@hydra:releases/print-server-installer.git # timeout=10
|
||||
// Cleaning workspace
|
||||
// > git rev-parse --verify HEAD # timeout=10
|
||||
// Resetting working tree
|
||||
// > git reset --hard # timeout=10
|
||||
// > git clean -fdx # timeout=10
|
||||
// Using shallow fetch with depth 1
|
||||
// Fetching upstream changes from git@hydra:releases/print-server-installer.git
|
||||
// > git --version # timeout=10
|
||||
// > git fetch --tags --progress git@hydra:releases/print-server-installer.git +refs/heads/*:refs/remotes/origin/* --depth=1 # timeout=120
|
||||
// > git rev-parse refs/remotes/origin/master^{commit} # timeout=10
|
||||
// > git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
|
||||
// Checking out Revision d0788d22622862e441c5995a22629846573c39f3 (refs/remotes/origin/master)
|
||||
// Enabling Git LFS pull
|
||||
// > git config core.sparsecheckout # timeout=10
|
||||
// > git read-tree -mu HEAD # timeout=10
|
||||
// > git checkout -f d0788d22622862e441c5995a22629846573c39f3 # timeout=120
|
||||
// > git config --get remote.origin.url # timeout=10
|
||||
// > git lfs pull origin # timeout=120
|
||||
// Commit message: "2.10180.7389.21125_3"
|
||||
// > git rev-list --no-walk d0788d22622862e441c5995a22629846573c39f3 # timeout=10
|
||||
|
||||
def String lfsinstallandreporoot(String gitURL) {
|
||||
checkgitlfsinstall()
|
||||
return checkouttoreporoot(gitURL)
|
||||
}
|
||||
|
||||
def showsparseitemlist(ArrayList<String> sparseitemlist = new ArrayList<String>()) {
|
||||
if (!sparseitemlist.isEmpty()) {
|
||||
def itemstring = "Items in sparse item list:\n"
|
||||
for (item in sparseitemlist) {
|
||||
itemstring += item + "\n"
|
||||
}
|
||||
echo itemstring
|
||||
}
|
||||
}
|
||||
|
||||
def docheckout(String gitURL, String revision, int cloneDepth, String reporootpath, boolean shallowClone, String targetDir, sparseitemlist) {
|
||||
echo "Git: Checking out: URL: ${gitURL} Revision: ${revision} to: ${targetDir}"
|
||||
checkout([
|
||||
$class: 'GitSCM',
|
||||
userRemoteConfigs: [
|
||||
[url: gitURL]
|
||||
],
|
||||
branches: [
|
||||
[name: revision]
|
||||
],
|
||||
extensions: [
|
||||
[$class: 'GitLFSPull'],
|
||||
[$class: 'CleanBeforeCheckout'],
|
||||
[$class: 'CloneOption', depth: cloneDepth, noTags: false, reference: reporootpath, shallow: shallowClone, timeout: 120],
|
||||
[$class: 'CheckoutOption', timeout: 120],
|
||||
[$class: 'RelativeTargetDirectory', relativeTargetDir: targetDir],
|
||||
[$class: 'SparseCheckoutPaths', sparseCheckoutPaths: sparsecheckoutconfig(sparseitemlist)],
|
||||
[$class: 'PruneStaleBranch'],
|
||||
],
|
||||
submoduleCfg: [],
|
||||
])
|
||||
}
|
||||
|
||||
// gitCheckout (below) cannot handle sparse checkout and lfs at the moment - see https://issues.jenkins-ci.org/browse/JENKINS-43427 - see gitCheckoutAlt()
|
||||
def gitCheckout(String gitURL, String revision, String targetDir, String repoRootSuffix = "", int cloneDepth = 1, boolean shallowClone = true, ArrayList<String> sparseitemlist = new ArrayList<String>()) {
|
||||
def String reporootpath = lfsinstallandreporoot(gitURL)
|
||||
showsparseitemlist(sparseitemlist)
|
||||
docheckout(gitURL, revision, cloneDepth, reporootpath, shallowClone, targetDir, sparseitemlist)
|
||||
}
|
||||
|
||||
def gitinit(String targetDir, String reporootpath) {
|
||||
if (!fileExists("${targetDir}/.git")) { // Git folder does not already exist
|
||||
echo "git init ${targetDir}"
|
||||
if (isUnix()) {
|
||||
sh """
|
||||
git init "${targetDir}"
|
||||
"""
|
||||
} else {
|
||||
powershell """
|
||||
git init "${targetDir}"
|
||||
"""
|
||||
}
|
||||
}
|
||||
echo "Writing ${reporootpath}/.git/objects to ${targetDir}/.git/objects/info/alternates"
|
||||
dir("${targetDir}/.git/objects/info") {
|
||||
writeFile(file: 'alternates', text: "${reporootpath}/.git/objects")
|
||||
}
|
||||
}
|
||||
|
||||
def setlfsfetchinclude(String targetDir, ArrayList<String> sparseitemlist) {
|
||||
def String sparseitemliststring = ""
|
||||
if (!sparseitemlist.isEmpty()) {
|
||||
for (item in sparseitemlist) {
|
||||
sparseitemliststring += "${item},"
|
||||
}
|
||||
echo "git config lfs.fetchinclude ${sparseitemliststring}"
|
||||
dir(targetDir) {
|
||||
if (isUnix()) {
|
||||
sh """
|
||||
git config lfs.fetchinclude "${sparseitemliststring}"
|
||||
"""
|
||||
} else {
|
||||
powershell """
|
||||
git config lfs.fetchinclude "${sparseitemliststring}"
|
||||
"""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def gitsparserestore(String targetDir) {
|
||||
echo "Clean out full fetch; Force a sparse fetch"
|
||||
dir(targetDir) {
|
||||
if (isUnix()) {
|
||||
sh """
|
||||
git rm -rf . > /dev/null
|
||||
git clean -fxd > /dev/null
|
||||
git reset --hard > /dev/null
|
||||
"""
|
||||
} else {
|
||||
powershell """
|
||||
git rm -rf . > \$null
|
||||
git clean -fxd > \$null
|
||||
git reset --hard > \$null
|
||||
"""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def List convertSparseItemsString(String itemstopublish) {
|
||||
def List sparsepaths = []
|
||||
|
||||
boolean nonempty = itemstopublish?.trim()
|
||||
if (nonempty) {
|
||||
def String[] items = itemstopublish.trim().split(',')
|
||||
def String allpaths = ""
|
||||
for(String item : items) {
|
||||
sparsepaths.add(item)
|
||||
allpaths += "${item}\n"
|
||||
}
|
||||
echo "Selected item to publish:\n${allpaths}"
|
||||
}
|
||||
return sparsepaths
|
||||
}
|
||||
|
||||
def gitCheckoutAlt(String gitURL, String revision, String targetDir, String repoRootSuffix = "", int cloneDepth = 1, boolean shallowClone = true, ArrayList<String> sparseitemlist = new ArrayList<String>()) {
|
||||
echo "Performing alternative checkout"
|
||||
def String reporootpath = lfsinstallandreporoot(gitURL)
|
||||
showsparseitemlist(sparseitemlist)
|
||||
if (!sparseitemlist.isEmpty()) {
|
||||
gitinit(targetDir, reporootpath)
|
||||
setlfsfetchinclude(targetDir, sparseitemlist)
|
||||
}
|
||||
docheckout(gitURL, revision, cloneDepth, reporootpath, shallowClone, targetDir, sparseitemlist)
|
||||
if (!sparseitemlist.isEmpty()) {
|
||||
gitsparserestore(targetDir)
|
||||
}
|
||||
}
|
||||
|
||||
def checkRepoExists(String gitURL) {
|
||||
def int result = 0
|
||||
if (isUnix()) {
|
||||
result = sh( script: """
|
||||
git ls-remote "${gitURL}" CHECK_GIT_REMOTE_URL_REACHABILITY
|
||||
""",
|
||||
returnStatus: true
|
||||
)
|
||||
} else {
|
||||
result = powershell( script: """
|
||||
git ls-remote "${gitURL}" CHECK_GIT_REMOTE_URL_REACHABILITY
|
||||
""",
|
||||
returnStatus: true
|
||||
)
|
||||
}
|
||||
echo "git ls-remote return result: ${result}"
|
||||
if (result > 0) {
|
||||
error("The release repo: ${gitURL} cannot be found. Please ensure this exists before building")
|
||||
} else {
|
||||
echo "The release repo: ${gitURL} exists"
|
||||
}
|
||||
}
|
||||
|
||||
String getSHAFromVersion(String versionFolder) {
|
||||
dir (versionFolder) {
|
||||
srcRevision = readFile("gitrevision.txt").trim()
|
||||
}
|
||||
return srcRevision
|
||||
}
|
||||
|
||||
boolean checkAllVersionsAgree(java.util.LinkedHashMap versions) {
|
||||
def keys = versions.keySet()
|
||||
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
|
||||
}
|
||||
|
||||
def stripgithistory(String rootfolder) {
|
||||
echo "Stripping git history out of ${rootfolder}"
|
||||
dir(rootfolder) {
|
||||
if (isUnix()) {
|
||||
sh """#!/bin/bash
|
||||
pwd
|
||||
find . -type d -name ".git" | xargs -iXX rm -rf XX
|
||||
find . -name ".gitignore" | xargs -iXX rm -rf XX
|
||||
find . -name ".gitmodules" | xargs -iXX rm -rf XX
|
||||
find . -iname ".gitattributes" | xargs -iXX rm -rf XX
|
||||
find . -iname "*@tmp" | xargs -iXX rm -rf XX
|
||||
"""
|
||||
} else {
|
||||
echo "Not supporting git stripping in Windows at the moment"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return this
|
||||
23
Common_scripts/versionnumbering/do.groovy
Normal file
23
Common_scripts/versionnumbering/do.groovy
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
|
||||
def stamp(convertdetails) {
|
||||
for (convertdetail in convertdetails) {
|
||||
def filetoconvert = convertdetail[0]
|
||||
def pattern = convertdetail[1]
|
||||
def replacement = convertdetail[2]
|
||||
echo "Converting any instances of pattern: ${pattern} with replacement: ${replacement} in file: ${filetoconvert}"
|
||||
def stampscript = "${autobuilder.commonscripts()}/versionstamping/versionstamper.py"
|
||||
echo "Using python: ${PYTHON} and script: ${stampscript}"
|
||||
if (isUnix()) {
|
||||
sh """
|
||||
"${PYTHON}" -u "${stampscript}" -f "${filetoconvert}" -p "${pattern}" -s "${replacement}"
|
||||
"""
|
||||
}
|
||||
else {
|
||||
powershell """
|
||||
& "${PYTHON}" -u "${stampscript}" -f "${filetoconvert}" -p "${pattern}" -s "${replacement}"
|
||||
"""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
180
Common_scripts/versionnumbering/generate.groovy
Normal file
180
Common_scripts/versionnumbering/generate.groovy
Normal file
|
|
@ -0,0 +1,180 @@
|
|||
gh = load("${autobuilder.commonscripts()}/versioncontrol/git.groovy")
|
||||
|
||||
def int maxversionnumber() {
|
||||
def int MAXVERSIONNUMBER = 65535
|
||||
return MAXVERSIONNUMBER
|
||||
}
|
||||
|
||||
int incrementrevision(int current, int increment) {
|
||||
def int newrevision = (current + increment) % (maxversionnumber() + 1)
|
||||
echo "Current revision: ${current} Increment: ${increment} New revision: ${newrevision}"
|
||||
return newrevision
|
||||
}
|
||||
|
||||
def getGitRevision(String gitrootpath, int basebuildnumber) {
|
||||
def int adjustedchangecount
|
||||
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()) {
|
||||
changecount = sh(returnStdout: true, script: "git rev-list HEAD --count").trim().toInteger()
|
||||
}
|
||||
else {
|
||||
changecount = powershell(returnStdout: true, script: "git rev-list HEAD --count").trim().toInteger()
|
||||
}
|
||||
echo "Change count: ${changecount}"
|
||||
def int mvnp1 = maxversionnumber() + 1
|
||||
basebuildnumber = (basebuildnumber < 0) ? mvnp1 - (basebuildnumber.abs() % mvnp1) : basebuildnumber
|
||||
adjustedchangecount = incrementrevision(changecount, basebuildnumber)
|
||||
echo "Adjusted change count: ${adjustedchangecount}"
|
||||
if (isUnix()) {
|
||||
gitrevision = sh(returnStdout: true, script: "git rev-parse HEAD").trim()
|
||||
}
|
||||
else {
|
||||
gitrevision = powershell(returnStdout: true, script: "git rev-parse HEAD").trim()
|
||||
}
|
||||
echo "Revision: ${gitrevision}"
|
||||
if (isUnix()) {
|
||||
remoteinfo = sh(returnStdout: true, script: "git remote show origin").trim()
|
||||
}
|
||||
else {
|
||||
remoteinfo = powershell(returnStdout: true, script: "git remote show origin").trim()
|
||||
}
|
||||
echo "Remote info: ${remoteinfo}"
|
||||
if (isUnix()) {
|
||||
remoteurl = sh(returnStdout: true, script: "git config --get remote.origin.url").trim()
|
||||
}
|
||||
else {
|
||||
remoteurl = powershell(returnStdout: true, script: "git config --get remote.origin.url").trim()
|
||||
}
|
||||
echo "Remote URL: ${remoteurl}"
|
||||
}
|
||||
return [adjustedchangecount, gitrevision, remoteinfo, remoteurl]
|
||||
}
|
||||
|
||||
// Handle:
|
||||
// origin/master
|
||||
// origin/2.0.x
|
||||
def getVersionPrefix(String sourcebranch, boolean droptrailingdot = false) {
|
||||
echo "Determining version number prefix from source branch name: ${sourcebranch}"
|
||||
sourcebranch = sourcebranch.toLowerCase()
|
||||
|
||||
def defaultversionprefix = "0.30000.0."
|
||||
def splits = sourcebranch.split('/')
|
||||
if (splits.size() < 1) {
|
||||
echo "Source branch name is invalid. Defaulting to: ${defaultversionprefix}"
|
||||
return defaultversionprefix
|
||||
}
|
||||
|
||||
def mastertypeversionprefix = "0.20000.0."
|
||||
sourcebranch = splits.last()
|
||||
if (sourcebranch.toLowerCase().find("master") != null) {
|
||||
echo "Source branch name has 'master' in it. Defaulting to: ${mastertypeversionprefix}"
|
||||
return mastertypeversionprefix
|
||||
}
|
||||
|
||||
def splits2 = sourcebranch.split('\\.')
|
||||
if (splits2.size() < 1) {
|
||||
def thirdpartyversionprefix = "0.25000.0."
|
||||
echo "Source branch name has no dots in it (eg. 1.9.2). Defaulting to: ${thirdpartyversionprefix}"
|
||||
return thirdpartyversionprefix
|
||||
}
|
||||
|
||||
for (split in splits2) {
|
||||
if (split == "x") {
|
||||
echo "Source branch name has '.x' or 'x.' in it. Defaulting to: ${mastertypeversionprefix}"
|
||||
return mastertypeversionprefix
|
||||
}
|
||||
}
|
||||
|
||||
def integerstrings = sourcebranch.findAll(/\d+/)
|
||||
def integers = []
|
||||
for (integerstring in integerstrings) {
|
||||
if (integerstring.length() > 6) {
|
||||
integerstring = integerstring.substring(0, 5)
|
||||
}
|
||||
int integer = integerstring.toInteger()
|
||||
integer = integer % (maxversionnumber() + 1)
|
||||
integers.add(integer)
|
||||
}
|
||||
|
||||
def versionprefix = ""
|
||||
if (integers.size() < 1) {
|
||||
echo "This source branch name has no numbers in its name so defaulting to: ${defaultversionprefix}"
|
||||
versionprefix = defaultversionprefix
|
||||
}
|
||||
else {
|
||||
def int integernumbercount = 0
|
||||
for (integer in integers) {
|
||||
versionprefix += integer + "."
|
||||
integernumbercount += 1
|
||||
if (integernumbercount > 2) {
|
||||
break
|
||||
}
|
||||
}
|
||||
if (integernumbercount == 0) {
|
||||
echo "No leading numbers were found in source branch name so defaulting to: ${defaultversionprefix}"
|
||||
versionprefix = defaultversionprefix
|
||||
}
|
||||
else if (integernumbercount == 1) {
|
||||
versionprefix += "0.0."
|
||||
}
|
||||
else if (integernumbercount == 2) {
|
||||
versionprefix += "0."
|
||||
}
|
||||
}
|
||||
if (droptrailingdot == true) {
|
||||
versionprefix = versionprefix.substring(0, versionprefix.length() - 1);
|
||||
}
|
||||
echo "Determined version prefix to be: ${versionprefix}"
|
||||
return versionprefix
|
||||
}
|
||||
|
||||
String generate(meta, String sourcerevision, String sourcepath, int basebuildnumber = 1000) {
|
||||
def int gitrevisioncount
|
||||
def String gitrevision
|
||||
def String remoteinfo
|
||||
def String remoteurl
|
||||
|
||||
(gitrevisioncount, gitrevision, remoteinfo, remoteurl) = getGitRevision(sourcepath, basebuildnumber)
|
||||
|
||||
def versionprefix = getVersionPrefix(sourcerevision)
|
||||
|
||||
def buildstamp = versionprefix + gitrevisioncount.toString()
|
||||
echo "Build stamp is: ${buildstamp}"
|
||||
|
||||
meta.gitinfo.set(sourcepath, sourcerevision, gitrevision, remoteurl, remoteinfo)
|
||||
meta.buildstampinfo.set(versionprefix, gitrevisioncount, buildstamp)
|
||||
|
||||
return buildstamp
|
||||
}
|
||||
|
||||
String pregenerated(meta, String sourcerevision, String sourcepath, String pregeneratedbuildstamp, int basebuildnumber = 1000) {
|
||||
generate(meta, sourcerevision, sourcepath, basebuildnumber)
|
||||
meta.buildstampinfo.override(pregeneratedbuildstamp)
|
||||
|
||||
return pregeneratedbuildstamp
|
||||
}
|
||||
|
||||
String generate(meta, String sourcerevision, String sourcepath, String basebuildnumber) {
|
||||
def int bbn = basebuildnumber.trim().toInteger()
|
||||
return generate(meta, sourcerevision, sourcepath, bbn)
|
||||
}
|
||||
|
||||
String copyfrom(meta, othermeta) {
|
||||
// Deep copy
|
||||
meta.gitinfo.set(othermeta.gitinfo.sourcepath, othermeta.gitinfo.sourcerevision, othermeta.gitinfo.gitrevision, othermeta.gitinfo.remoteurl, othermeta.gitinfo.remoteinfo)
|
||||
meta.buildstampinfo.set(othermeta.buildstampinfo.buildstampprefix, othermeta.buildstampinfo.revision, othermeta.buildstampinfo.buildstamp)
|
||||
|
||||
return meta.buildstampinfo.buildstamp
|
||||
}
|
||||
|
||||
return this;
|
||||
17
Common_scripts/versionstamping/.project
Normal file
17
Common_scripts/versionstamping/.project
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>versionstamping</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.python.pydev.PyDevBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.python.pydev.pythonNature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
8
Common_scripts/versionstamping/.pydevproject
Normal file
8
Common_scripts/versionstamping/.pydevproject
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<?eclipse-pydev version="1.0"?><pydev_project>
|
||||
<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
|
||||
<path>/${PROJECT_DIR_NAME}</path>
|
||||
</pydev_pathproperty>
|
||||
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 3.0</pydev_property>
|
||||
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">python35</pydev_property>
|
||||
</pydev_project>
|
||||
38
Common_scripts/versionstamping/versionstamper.py
Normal file
38
Common_scripts/versionstamping/versionstamper.py
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
import argparse
|
||||
import sys
|
||||
import shutil
|
||||
from builtins import FileNotFoundError
|
||||
|
||||
def main(argv):
|
||||
parser = argparse.ArgumentParser(description="Look for version number pattern in file and replace with autobuild version number")
|
||||
|
||||
# Call once arguments to allow or disallow something
|
||||
parser.add_argument('-f', '--filetoconvert', help='The file to convert')
|
||||
parser.add_argument('-p', '--pattern', default='0.30000.0.0', help='The pattern to search for and replace')
|
||||
parser.add_argument('-s', '--substitute', help='The new version number that will substitute the pattern')
|
||||
|
||||
args = parser.parse_args(argv)
|
||||
|
||||
filetoconvert = args.filetoconvert
|
||||
pattern = args.pattern
|
||||
substitute = args.substitute
|
||||
|
||||
print("Converting instances of {0} with {1} in file: {2}\n".format(pattern, substitute, filetoconvert))
|
||||
|
||||
with open(filetoconvert,'r') as c:
|
||||
fileread = c.read()
|
||||
|
||||
count = 0
|
||||
with open(filetoconvert, 'w') as f:
|
||||
print("Detected %s instances of %s pre-conversion"%(fileread.count(pattern),pattern))
|
||||
converted = fileread.replace(pattern, substitute)
|
||||
count = converted.count(substitute)
|
||||
print("Confirmed %s instances of %s post-conversion"%(count,substitute))
|
||||
f.write(converted)
|
||||
|
||||
if count == 0:
|
||||
return 1
|
||||
return 0
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main(sys.argv[1:]))
|
||||
Loading…
Add table
Add a link
Reference in a new issue