Merge branch 'master' of hydra:GIS_Embedded_Logic/fw_development_tools

This commit is contained in:
David Steele 2023-01-25 14:49:07 +00:00
commit 461b0ee4de
25 changed files with 3741 additions and 276 deletions

View file

@ -11,10 +11,6 @@
"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"
@ -69,7 +65,7 @@ def getActionJobName(postbuildactions, String action, String alternativeparamnam
if (params[alternativeparamname]) {
jobname = params[alternativeparamname]
}
}
}
}
if (jobname) {
def jobitem = Jenkins.instance.getItemByFullName(jobname)
@ -125,7 +121,6 @@ def performSuccessfulBuildActions(meta) {
def String buildselector = "<SpecificBuildSelector plugin='copyartifact@1.46.2'><buildNumber>${BUILD_NUMBER}</buildNumber></SpecificBuildSelector>"
deployjob(meta, buildselector, postbuildactions, 'Deploy documentation', 'DOXYGEN_DEPLOY_JOB', 'BUILD_JOB_WITH_DOXYGEN_ARTIFACTS', 'BUILD_JOB_WITH_DOXYGEN_ARTIFACTS_SELECTOR')
deployjob(meta, buildselector, postbuildactions, 'Static analysis', 'STATIC_ANALYSIS_JOB', 'BUILD_JOB_TO_ANALYSE', 'BUILD_JOB_TO_ANALYSE_SELECTOR' )
deployjob(meta, buildselector, postbuildactions, 'Unit test', 'UNIT_TEST_JOB', 'BUILD_JOB_TO_TEST', 'BUILD_JOB_TO_TEST_SELECTOR')
deployjob(meta, buildselector, postbuildactions, 'Regression test', 'REGRESSION_TEST_JOB', 'BUILD_JOB_TO_TEST', 'BUILD_JOB_TO_TEST_SELECTOR')
deployjob(meta, buildselector, postbuildactions, 'Update differences', 'DIFF_JOB', 'LATER_BUILD_JOB', 'LATER_BUILD_SELECTOR', 'TOP_LEVEL_META_REPOSITORY')
deployjob(meta, buildselector, postbuildactions, 'Release to git', 'RELEASE_TO_GIT_JOB', 'BUILD_JOB', 'BUILD_JOB_SELECTOR')

View file

@ -3,7 +3,7 @@ versiongenerator = load("${autobuilder.commonscripts()}/versionnumbering/generat
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
@ -20,7 +20,7 @@ class ImportOptions {
String m_repo
String m_revision
boolean m_showdetails
ImportOptions(script,
@ -48,7 +48,7 @@ class ImportOptions {
m_appendtoparentmeta = appendtoparentmeta
m_showdetails = showdetails
}
String show() {
return """m_incrementversionnumber: ${m_incrementversionnumber}
m_filter: ${m_filter}
@ -66,7 +66,7 @@ class ImportOptions {
m_revision: ${m_revision}
"""
}
void setsourceselect(String sourceselect) {
sourceselect = sourceselect.trim()
switch (sourceselect) {
@ -105,7 +105,7 @@ class ImportOptions {
void flattenimports(boolean flatten = true) {
m_flatten = flatten
}
void includemetainfilter(boolean includemetainfilter = true) {
m_includemetainfilter = includemetainfilter
}
@ -118,16 +118,52 @@ class ImportOptions {
m_appendtoparentmeta = appendtoparentmeta
}
void jenkinsjob(String jobname, String buildnumberorselector) {
void jenkinsjob(String jobname, java.util.LinkedHashMap selector) {
m_script.echo("Jenkins job: ${jobname} Selector (${selector.getClass()}): ${selector}")
m_jobname = jobname.trim()
m_buildnumberorselector = [
$class: 'ParameterizedBuildSelector',
parameterName: buildnumberorselector
]
m_buildnumberorselector = selector
setsourceselect('Jenkins job artifact')
}
void jenkinsjob(String jobname, String buildnumberorselector) {
m_script.echo("Jenkins job: ${jobname} Selector (String): ${buildnumberorselector}")
m_jobname = jobname.trim()
// Yuk - nasty
// https://javadoc.jenkins.io/plugin/copyartifact/hudson/plugins/copyartifact/BuildSelector.html
// This selects buildselector class based on what is in the string parameter
if (buildnumberorselector.contains('<SpecificBuildSelector')) {
m_script.echo("Prebuilt specific build selector")
m_buildnumberorselector = [
$class: 'ParameterizedBuildSelector',
parameterName: "${buildnumberorselector}"
]
} else if (buildnumberorselector.contains('<StatusBuildSelector')) {
m_script.echo("Prebuilt status build selector")
m_buildnumberorselector = [
$class: 'ParameterizedBuildSelector',
parameterName: "${buildnumberorselector}"
]
} else if (buildnumberorselector.contains('<stable>')) {
m_script.echo("Constructing status build selector")
m_buildnumberorselector = [
$class: 'ParameterizedBuildSelector',
parameterName: "<StatusBuildSelector plugin='copyartifact@1.46.2'>${buildnumberorselector}</StatusBuildSelector>"
]
} else {
m_script.echo("Constructing specific build selector")
m_buildnumberorselector = [
$class: 'ParameterizedBuildSelector',
parameterName: "<SpecificBuildSelector plugin='copyartifact@1.46.2'><buildNumber>${buildnumberorselector}</buildNumber></SpecificBuildSelector>"
]
}
setsourceselect('Jenkins job artifact')
}
void jenkinsjob(String jobname, int buildnumberorselector) {
m_script.echo("Jenkins job: ${jobname} Selector (int): ${buildnumberorselector}")
m_jobname = jobname.trim()
m_buildnumberorselector = [
$class: 'ParameterizedBuildSelector',
@ -233,11 +269,14 @@ def hierarchyartifactimportfromrepo(meta, ImportOptions importoptions, String de
}
echo "Cloning associated repos inside path: ${destpath}"
int offset = 0
for(def collectedmeta in collectedmetalist) {
def relatedmeta = collectedmeta.metainfo
def relatedoffsetpath = collectedmeta.accumulatedpath
def cloneurl = relatedmeta.releaseinfo.releaserepoURL
def clonerevision = "refs/tags/${relatedmeta.releasetag()}"
// The first entry in the list is the highest parent in the meta tree so use the tag provided in the import options
// This is because the revision that is recalled here could have been renamed since it was created during the release process
def clonerevision = (offset == 0) ? rootrevision : "refs/tags/${relatedmeta.releasetag()}"
def clonepath = "${destpath}/${relatedoffsetpath}"
if (relatedmeta.componentidentifier() != '_' &&
cloneurl != '') {
@ -250,12 +289,13 @@ def hierarchyartifactimportfromrepo(meta, ImportOptions importoptions, String de
} else {
echo "Not importing component that would be placed at path: ${clonepath}"
}
offset += 1
}
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))
}
@ -278,7 +318,7 @@ def artifactimportfromrepo(meta, ImportOptions importoptions, String destpath) {
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}"
@ -332,7 +372,7 @@ def artifactimport(meta,
} else {
importoptions.jenkinsjob(childmeta.jenkinsbuildinfo.buildjobname, childmeta.jenkinsbuildinfo.buildnumber)
}
childmeta2 = importer.artifactimport(meta, importoptions, destinationfolder)
childmeta2 = artifactimport(meta, importoptions, destinationfolder)
} else {
error("Could not find meta associated with child: Product: ${childproduct} Sub-component: ${childsubcomponent}")
}

View file

@ -1,16 +1,19 @@
import java.nio.file.Paths
import java.nio.file.Path
import groovy.json.JsonSlurperClassic
import java.time.format.DateTimeFormatter
import java.time.LocalDateTime
import java.time.LocalDate
abstract class GISJsonSerialised implements Serializable {
def script
GISJsonSerialised(script) {
this.script = script
}
abstract LinkedHashMap serialisationdata()
abstract void deserialiseJson(rawmeta)
def saveJsonSerialised(String outputfile, int prettylevel = 4) {
@ -127,7 +130,7 @@ class GitInfo extends GISJsonSerialised {
this.remoteurl = another.remoteurl
this.remoteinfo = another.remoteinfo
}
void set(String sourcepath, String sourcerevision, String gitrevision, String remoteurl, String remoteinfo) {
this.sourcepath = sourcepath
this.sourcerevision = sourcerevision
@ -170,14 +173,14 @@ class JenkinsBuildParameter extends GISJsonSerialised {
private String name
private String valuetype
private String value
JenkinsBuildParameter(script, String name = '', String valuetype = '', String value = '') {
super(script)
this.name = name
this.valuetype = valuetype
this.value = value
}
void set(String name, String valuetype, String value) {
this.name = name
this.valuetype = valuetype
@ -227,11 +230,11 @@ class JenkinsBuildInfo extends GISJsonSerialised {
this.builddate = builddate
this.isfullbuild = isfullbuild
}
void set(boolean isfullbuild) {
this.isfullbuild = isfullbuild
}
boolean isFullBuild() {
return isfullbuild
}
@ -242,6 +245,16 @@ class JenkinsBuildInfo extends GISJsonSerialised {
return p
}
LocalDateTime buildDateAsLocalDateTime() {
DateTimeFormatter builddateformatter = DateTimeFormatter.ofPattern('EEE LLL dd HH:mm:ss VV yyyy')
return LocalDateTime.parse(builddate, builddateformatter)
}
LocalDate buildDateAsLocalDate() {
return buildDateAsLocalDateTime().toLocalDate()
}
void deserialiseJson(rawmeta) {
//format = rawmeta['format']
buildjobname = rawmeta['buildjobname']
@ -330,7 +343,7 @@ class BuildStampInfo extends GISJsonSerialised {
def String buildstampcommasep = buildstamp.replace(".", ",")
return buildstampcommasep
}
void changerevision(int newrevision) {
script.echo("Build stamp currently ${buildstamp}")
revision = newrevision
@ -357,7 +370,7 @@ class BuildStampInfo extends GISJsonSerialised {
revision = rawmeta['revision']
buildstamp = rawmeta['buildstamp']
}
LinkedHashMap serialisationdata() {
def data = [
'format' : format,
@ -460,7 +473,7 @@ class ConfigurationInfo extends GISJsonSerialised {
class ChecksumPair extends GISJsonSerialised {
private String filepath
private String sum
ChecksumPair(script, String filepath = '', String sum = '') {
super(script)
this.filepath = filepath
@ -485,14 +498,14 @@ class ChecksumSet extends GISJsonSerialised {
private String format
private String artifactpath
private ArrayList<ChecksumPair> checksumpairs
ChecksumSet(script, artifactpath = '') {
super(script)
this.format = '0.1'
this.artifactpath = artifactpath
checksumpairs = new ArrayList<ChecksumPair>()
}
ChecksumPair addChecksumPair(String filepath, String sum) {
def cp = new ChecksumPair(script, filepath, sum)
checksumpairs.add(cp)
@ -541,7 +554,7 @@ class ChecksumInfo extends GISJsonSerialised {
checksumsets.add(cs)
return cs
}
List checksumsetsserialised() {
def associated = []
for (cs in checksumsets) {
@ -615,7 +628,7 @@ class MetaInfo extends GISJsonSerialised {
private MetaInfo meta
private String offsetpath
private String uniqueid
RelatedMetaInfo_v0_1(script, String offsetpath = '', MetaInfo meta = null, String uniqueid = UUID.randomUUID().toString()) {
super(script, '0.1')
this.offsetpath = offsetpath
@ -639,7 +652,7 @@ class MetaInfo extends GISJsonSerialised {
]
return data
}
String getrelatedid() {
return uniqueid
}
@ -860,7 +873,7 @@ class MetaInfo extends GISJsonSerialised {
}
return mi
}
def copyrelatedmeta() {
script.echo("Copying related input meta data to output meta")
for (relatedmetainfo in associatedmeta) {
@ -915,7 +928,7 @@ class MetaInfo extends GISJsonSerialised {
String componentidentifier() {
return productinfo.productname + "_" + productinfo.subcomponentname
}
String productvariant() {
if (!productinfo.variant) {
return productinfo.productname
@ -927,11 +940,19 @@ class MetaInfo extends GISJsonSerialised {
String componentversionuniqueidentifier() {
return componentidentifier() + "_" + buildstampinfo.buildstamp
}
String globalreleasetag() {
return componentversionuniqueidentifier() + "_" + jenkinsbuildinfo.buildnumber
}
String globalreleasevarianttag() {
if (!productinfo.variant) {
return globalreleasetag()
} else {
return globalreleasetag() + "_" + productinfo.variant
}
}
String releasetag() {
return buildstampinfo.buildstamp + "_" + jenkinsbuildinfo.buildnumber
}
@ -944,14 +965,14 @@ class MetaInfo extends GISJsonSerialised {
private MetaInfo metainfo
private String accumulatedpath
private String accumulatedmetapath
CollectedMeta(MetaInfo metainfo, String accumulatedpath = '', String accumulatedmetapath = '') {
this.metainfo = metainfo
this.accumulatedpath = accumulatedpath
this.accumulatedmetapath = accumulatedmetapath
}
}
class IterationInfo {
private ArrayList<CollectedMeta> metacollection
private Map<String, CollectedMeta> metamap
@ -962,7 +983,7 @@ class MetaInfo extends GISJsonSerialised {
private boolean limiteddepth
private int maxdepth
private boolean markasreleased
IterationInfo(ArrayList<CollectedMeta> metacollection,
Map<String, CollectedMeta> metamap,
String comment = '',
@ -982,17 +1003,17 @@ class MetaInfo extends GISJsonSerialised {
this.maxdepth = maxdepth
this.markasreleased = markasreleased
}
String show() {
return "Iteration:\nLevel: ${level}\nGathered path: ${gatheredpath}\nGathered meta path: ${gatheredmetapath}\nLimited depth: ${limiteddepth}\nMax depth: ${maxdepth}\nMark as released: ${markasreleased}"
}
void add(CollectedMeta item) {
metacollection.add(item)
metamap.put(item.metainfo.productinfo.uniqueid, item)
}
}
def openchildmeta(IterationInfo ii, RelatedMetaInfo relatedmetainfo) {
def MetaInfo mi = new MetaInfo(script)
@ -1059,7 +1080,7 @@ class MetaInfo extends GISJsonSerialised {
}
return [ 'metacollection' : ii.metacollection, 'metamap' : ii.metamap, 'comment': ii.comment ]
}
def walkrelated(IterationInfo ii) {
//script.echo("Walk related: ${ii.show()}")
if (!ii.limiteddepth || ii.maxdepth > 0) {
@ -1116,7 +1137,7 @@ class MetaInfo extends GISJsonSerialised {
def Map<String, CollectedMeta> metamap = new LinkedHashMap<String, CollectedMeta>()
return walkrelated(new IterationInfo(metacollection, metamap, '', 0, '', metapath))
}
ArrayList<CollectedMeta> releasewalker(int maxdepth, String startpath = '', String startmetapath = '') {
def ArrayList<CollectedMeta> metacollection = new ArrayList<CollectedMeta>()
def Map<String, CollectedMeta> metamap = new LinkedHashMap<String, CollectedMeta>()
@ -1156,7 +1177,7 @@ class MetaInfo extends GISJsonSerialised {
return versionuniquecollection
}
Map<String, MetaInfo> releasewalkerunique(int maxdepth, String startpath = '', String startmetapath = '') {
def ArrayList<CollectedMeta> metacollection = releasewalker(maxdepth, startpath, "${startmetapath}/${METAFOLDERNAME}")
@ -1168,7 +1189,7 @@ class MetaInfo extends GISJsonSerialised {
return uniquecollection
}
MetaInfo getNewMetaObject(script) {
return new MetaInfo(script)
}

View file

@ -0,0 +1,265 @@
pipeline {
agent { label AGENT_LABEL }
stages {
stage('Initial setup') {
steps {
script {
if (env.RELEASE_REPO_VARIANT_SUFFIX) {
meta = load("${WORKSPACE}/autobuild/Common_scripts/autobuilder.groovy").startbuild(
this,
PRODUCT_NAME,
SUBCOMPONENT_NAME,
RELEASE_REPO,
RELEASE_REPO_VARIANT_SUFFIX
)
} else {
meta = load("${WORKSPACE}/autobuild/Common_scripts/autobuilder.groovy").startbuild(
this,
PRODUCT_NAME,
SUBCOMPONENT_NAME,
RELEASE_REPO
)
}
}
}
}
stage('Checkout dependencies') {
steps {
script {
configurationhelper = autobuilder.configurationhelper()
importer = load("${autobuilder.commonscripts()}/import/importer.groovy")
}
}
}
stage('Checkout source') {
steps {
script {
ESWDIR = 'esw'
SOURCEREVISION = SOURCE_REVISION.trim()
SOURCENAME = 'embedded software'
configurationhelper.gitCheckoutAndRegister(meta, SOURCENAME, SOURCE_REPO, SOURCEREVISION, ESWDIR, '', 0, false)
COREDIR = 'core'
CORESOURCEREVISION = CORE_SOURCE_REVISION.trim()
CORESOURCENAME = 'core software'
configurationhelper.gitCheckoutAndRegister(meta, CORESOURCENAME, CORE_SOURCE_REPO, CORESOURCEREVISION, COREDIR, '', 0, false)
}
}
}
stage('Clean exports') {
steps {
script {
env.EXPORT = 'devjsclient'
cleanfolders = [
EXPORT,
]
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, ESWDIR)
}
}
}
stage('Version stamp files') {
steps {
script {
convertdetails = [
// File to convert Pattern to replace New string
]
versionnumbering = load("${autobuilder.commonscripts()}/versionnumbering/do.groovy")
versionnumbering.stamp(convertdetails)
}
}
}
stage('Build package') {
steps {
script {
def absexportpath = "${WORKSPACE}/${EXPORT}"
plainzipname = 'export.zip'
if (env.RELEASE_REPO_VARIANT_SUFFIX) {
jsclientzipname = "${PRODUCT_NAME}_${RELEASE_REPO_VARIANT_SUFFIX}_${meta.buildstampinfo.buildstamp}_${plainzipname}"
} else {
jsclientzipname = "${PRODUCT_NAME}_${meta.buildstampinfo.buildstamp}_${plainzipname}"
}
// This is required to deal with cases such as HMB-FD-HV-SG600/SG1024
combined_auto_json_file = "${WORKSPACE}/${ESWDIR}/HAL_Generator/combined_auto.json"
if (env.RELEASE_REPO_VARIANT_SUFFIX) {
combined_auto_json_file = "${WORKSPACE}/${ESWDIR}/HAL_Generator/${RELEASE_REPO_VARIANT_SUFFIX}/combined_auto.json"
}
// Another special case? This value is set in DHB-KM-XI (at least) for historical reasons.
// else if (env.PRINTHEAD_SOFTWARE_VARIANT) {
// combined_auto_json_file = "${WORKSPACE}/${ESWDIR}/HAL_Generator/${PRINTHEAD_SOFTWARE_VARIANT}/combined_auto.json"
// }
// Some jiggery pokers to manufacture devjsclient folder for distribution.
if (isUnix()) {
def DEVJSDIR = "${WORKSPACE}/${ESWDIR}/devjsclient"
sh """
#!bin/bash --verbose
# Preserve the contents of devjsclient so that unmodified products are unaffected.
# Recreate the folder so that we can populate it from the source folders.
if [ -d "${WORKSPACE}/${ESWDIR}/devjsclient" ]
then
echo "INF: Moving existing devjsclient folder to devjsclient_org"
mv ${WORKSPACE}/${ESWDIR}/devjsclient ${WORKSPACE}/${ESWDIR}/devjsclient_org
else
echo "INF: No existing devjsclient folder to preserve"
fi
mkdir ${WORKSPACE}/${ESWDIR}/devjsclient
# Copy in the common Javascript and related files which live in the core repo.
if [ -d "${WORKSPACE}/${COREDIR}/client/javascript" ]
then
echo "INF: Copying core javascript files to devjsclient"
cp -r ${WORKSPACE}/${COREDIR}/client/javascript/* ${WORKSPACE}/${ESWDIR}/devjsclient
else
echo "ERR: Core javascript files don't exist!!!"
fi
# Copy over the product-specific Javascript and related files. This may overwrite
# some or all of the core files, as well as adding new ones.
if [ -d "${WORKSPACE}/${ESWDIR}/client/javascript" ]
then
echo "INF: Copying product-specific javascript files over devjsclient"
cp -r ${WORKSPACE}/${ESWDIR}/client/javascript/* ${WORKSPACE}/${ESWDIR}/devjsclient
else
echo "INF: No product-specific javascript files to copy over devjsclient"
fi
# Create (or overwrite) registers.js in the JS folder using the FPGA register definitions
# from the product repository. We also copy combined_auto.json (elsewhere) into the product
# distribution to go on the board, so dumptruck can download it.
echo "fpga_registers =" > ${DEVJSDIR}/registers.js
if [ -e ${combined_auto_json_file} ]
then
cat ${combined_auto_json_file} >> ${DEVJSDIR}/registers.js
else
# Fall back to default if variant subfolder does not exist (e.g. AHB-KM1024a).
cat ${WORKSPACE}/${ESWDIR}/HAL_Generator/combined_auto.json >> ${DEVJSDIR}/registers.js
fi
echo ";" >> ${DEVJSDIR}/registers.js
# Restore the original devjsclient files, if it existed. This may overwrite some or all of the
# files from the previous steps. This included so the script will work for both
# modified and unmodified product repos. We can gradually trim out files which
# are duplicates of those in core, and also move files at some point to
# product/client/javascript
if [ -d "${WORKSPACE}/${ESWDIR}/devjsclient_org" ]
then
echo "INF: Copying original devjsclient files over recreated devjsclient"
cp -r ${WORKSPACE}/${ESWDIR}/devjsclient_org/* ${WORKSPACE}/${ESWDIR}/devjsclient
fi
"""
}
else {
bat """
echo "Cannot be built on windows at the moment"
exit 1
"""
}
dir(ESWDIR) {
if (isUnix()) {
sh """#!/bin/bash -v
mkdir "${absexportpath}"
if [ \$? -ne 0 ]; then exit 1; fi
zip -r "${absexportpath}/${plainzipname}" -P "${ZIP_PASSWORD}" devjsclient
if [ \$? -ne 0 ]; then exit 1; fi
zip -r "${absexportpath}/${jsclientzipname}" -P "${ZIP_PASSWORD}" devjsclient
if [ \$? -ne 0 ]; then exit 1; fi
"""
}
else {
bat """
echo "Cannot be built on windows at the moment"
exit 1
"""
}
}
dir(EXPORT) {
if (isUnix()) {
sh """#!/bin/bash -v
md5sum "${plainzipname}" > "${absexportpath}/${plainzipname}.md5"
if [ \$? -ne 0 ]; then exit 1; fi
sha256sum "${plainzipname}" > "${absexportpath}/${plainzipname}.sha256"
if [ \$? -ne 0 ]; then exit 1; fi
md5sum "${jsclientzipname}" > "${absexportpath}/${jsclientzipname}.md5"
if [ \$? -ne 0 ]; then exit 1; fi
sha256sum "${jsclientzipname}" > "${absexportpath}/${jsclientzipname}.sha256"
if [ \$? -ne 0 ]; then exit 1; fi
"""
}
else {
bat """
echo "Cannot be built on windows at the moment"
exit 1
"""
}
}
}
}
}
stage('Checksum artifacts') {
steps {
script {
def checksummable = [
"${EXPORT}/${plainzipname}",
"${EXPORT}/${plainzipname}.zip.md5",
"${EXPORT}/${plainzipname}.zip.sha256",
"${EXPORT}/${jsclientzipname}",
"${EXPORT}/${jsclientzipname}.zip.md5",
"${EXPORT}/${jsclientzipname}.zip.sha256",
]
checksumutils = load("${autobuilder.commonscripts()}/checksum/utils.groovy")
checksumutils.generatelist(meta, checksummable)
}
}
}
stage('Classifying publishable artifacts') {
steps {
script {
def publishable = [
"${EXPORT}/**"
]
publishutils = load("${autobuilder.commonscripts()}/publishing/utils.groovy")
publishutils.generatelist(meta, publishable)
}
}
}
stage('Archiving artifacts') {
steps {
script {
def artifacts = [
"${EXPORT}/**"
]
def artifactlist = meta.generateartifacts(artifacts)
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'
}
}
}

View file

@ -95,7 +95,7 @@ def publish(hostedftpsiteinfo, String customer, String finalreleaserepofolder =
tree -a .
"""
summaryappend("FTP operations: Transferring to ${ftproot}")
echo "Executing: ncftpput -u ${hostedftpsiteinfo.username} -p ${hostedftpsiteinfo.password} -R ${hostedftpsiteinfo.url} \"${ftproot}\" ."
echo "Executing: ncftpput -u ${hostedftpsiteinfo.username} -p ******** -R ${hostedftpsiteinfo.url} \"${ftproot}\" ."
sh """#!/bin/bash
ncftpput -u ${hostedftpsiteinfo.username} -p ${hostedftpsiteinfo.password} -R ${hostedftpsiteinfo.url} "${ftproot}" .
"""

View file

@ -0,0 +1,89 @@
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.JSCLIENT = "jsclient"
cleanfolders = [
JSCLIENT,
]
cleaner = load("${autobuilder.commonscripts()}/clean/clean.groovy")
cleaner.clean(cleanfolders)
}
}
}
stage('Import JS client artifacts') {
steps {
script {
importer = load("${autobuilder.commonscripts()}/import/importer.groovy")
def importoptions = importer.getNewImportOptions()
importoptions.jenkinsjob(PACKAGE_CREATE_JOB, PACKAGE_CREATE_JOB_SELECTOR)
jsclientmeta = importer.artifactimportfrombuildjob(meta, importoptions, JSCLIENT)
productname = jsclientmeta.productinfo.productname
productvariant = jsclientmeta.productvariant()
buildstampprefix = jsclientmeta.buildstampinfo.buildstampprefix
echo "JS client imported for product: ${productvariant} and build stamp prefix: ${buildstampprefix}"
}
}
}
stage('Copy JS client to server') {
steps {
script {
jsclientsource = "${JSCLIENT}/${ARTIFACT_PATH_TO_JSCLIENT_ROOT}"
pathonserver = "${ROOT_PATH_ON_SERVER.trim()}/${productvariant}/${buildstampprefix}"
echo "Copying from ${jsclientsource} 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 "${jsclientsource}"/* "${pathonserver}"
mv -v "${jsclientsource}"/* "${pathonserver}"/
if [ \$? -ne 0 ]; then exit 1; fi
"""
dir(pathonserver) {
sh """#!/bin/bash
mkdir -v unpacked
if [ \$? -ne 0 ]; then exit 1; fi
unzip -P "${ZIP_PASSWORD}" export.zip -d unpacked
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'
}
}
}

View file

@ -133,7 +133,7 @@ def boolean getcomponentartifacts(toplevelbuildmeta, buildinfo, String repofolde
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
@ -180,19 +180,23 @@ def boolean checkforchange(buildmeta, previousreleasemeta) {
def boolean changed = (shachanged | buildstampchanged)
echo "changed: ${changed}"
return changed
}
def ArrayList<String> maketaglist(buildmeta, String buildstamp, String otherreleasetags) {
def ArrayList<String> maketaglist(buildmeta, boolean includebuildstamp, String buildstamp, String otherreleasetags) {
def ArrayList<String> taglist = new ArrayList<String>()
taglist.add(buildstamp)
if (includebuildstamp) {
taglist.add(buildstamp)
echo "Adding: ${buildstamp} to taglist"
}
def ArrayList<String> othertaglist = otherreleasetags.split(',')
for (othertagitem in othertaglist) {
if (othertagitem?.trim()) {
def componentothertagitem = "${othertagitem.trim()}_${buildmeta.productvariant()}_${buildmeta.productinfo.subcomponentname}"
taglist.add(componentothertagitem)
echo "Adding: ${componentothertagitem} to taglist"
}
}
return taglist
@ -231,7 +235,7 @@ def boolean releasegittag(String postcommitshacode, String tag) {
def boolean releasegittags(String postcommitshacode, ArrayList<String> taglist) {
boolean tagadded = false
summaryappend("Rel Tag ")
for (tag in taglist) {
if (releasegittag(postcommitshacode, tag)) {
@ -268,7 +272,7 @@ def boolean sourcegittag(String shacode, String tag) {
def sourcegittags(String buildsha, List taglist) {
boolean tagadded = false
summaryappend(",Src Tag ")
for (tag in taglist) {
if (sourcegittag(buildsha, tag)) {
@ -311,7 +315,7 @@ def boolean isalreadyreleased(buildmeta, tag) {
} else {
String commitshacode = releasegitgetshacode(tag)
if (commitshacode) {
echo "Tag: ${tag} already exists in this repo therefore marking as already released"
echo "Tag: ${tag} already exists in this repo therefore marking as already released"
alreadyreleased = true
} else {
alreadyreleased = false
@ -325,46 +329,41 @@ def gitrelease(buildmeta, previousreleasemeta, String releaserepo, String source
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}"
summaryappend("Already-released.")
echo "Already released: Previous release sha code: ${releasegitgetshacode(buildstamptag)}"
} else {
def boolean changed = false
def String precommitshacode = sh(script: "git rev-parse --verify HEAD", returnStdout: true).trim()
echo "Not released: Pre commit sha code: ${precommitshacode}"
releasegitadd()
changed = checkforchange(buildmeta, previousreleasemeta)
if (changed) {
releasegitcommit(buildstamptag)
releasegitcommit(buildstamptag)
} else {
releasegitreset()
summaryappend("No-commit,")
}
postcommitshacode = sh(script: "git rev-parse --verify HEAD", returnStdout: true).trim()
def String 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)
def ArrayList<String> taglist = maketaglist(buildmeta, true, buildstamptag, otherreleasetags)
def boolean tagadded = releasegittags(postcommitshacode, taglist)
if (changed || tagadded) {
releasegitpush(dryrunpush)
}
}
}
dir(sourcerepo) {
def String srcbuildstamptag = buildmeta.globalreleasetag()
def String srcbuildstamptag = buildmeta.globalreleasevarianttag()
def String buildsha = buildmeta.gitinfo.gitrevision
if (buildsha) {
def ArrayList<String> srctaglist = maketaglist(buildmeta, srcbuildstamptag, otherreleasetags)
def tagadded = sourcegittags(buildsha, srctaglist)
def ArrayList<String> srctaglist = maketaglist(buildmeta, true, srcbuildstamptag, otherreleasetags)
def boolean tagadded = sourcegittags(buildsha, srctaglist)
if (tagadded) {
sourcegitpush(dryrunpush)
}

View file

@ -1,11 +1,16 @@
ftpremote = load("${autobuilder.commonscripts()}/remoteaccess/ftp.groovy")
def getHostedFTPSiteInfo() {
hostedftpsiteinfo =
ftpremote.createFTPSiteInfo("ftp.hostedftp.com",
"ftp@globalinkjetsystems.com",
"ramshorn42",
"/Customers/")
echo "Using ftp site credentials: ${HOSTEDFTP_CREDENTIALS_ID}"
withCredentials([usernamePassword(credentialsId: HOSTEDFTP_CREDENTIALS_ID,
usernameVariable: 'SUDO_USERNAME',
passwordVariable: 'SUDO_PASSWORD')]) {
hostedftpsiteinfo =
ftpremote.createFTPSiteInfo("ftp.hostedftp.com",
SUDO_USERNAME,
SUDO_PASSWORD,
"/Customers/")
}
return hostedftpsiteinfo
}

View file

@ -1,3 +1,85 @@
def sourceinfostore = null
/* Example expected JSON
{
"Sources": [
{
"name": "core",
"gituri": "git@hydra:core-presto/core-presto-embedded-software-subtree.git",
"revision": "origin/release"
},
{
"name": "dhb-km-1024i",
"gituri": "git@hydra:dhb-km-1024i-source/dhb-km-1024i-embedded-software-subtree.git",
"revision": "origin/master"
},
{
"name": "dhb-tt-cf3",
"gituri": "git@hydra:dhb-tt-cf3-source/dhb-tt-cf3-embedded-software-subtree.git",
"revision": "origin/master"
},
{
"name": "emb",
"gituri": "git@hydra:emb-source/emb-source-embedded-software-subtree.git",
"revision": "origin/master"
},
{
"name": "hmb-fd-hv-sg1024",
"gituri": "git@hydra:hmb-fd-hv-source/hmb-fd-hv-embedded-software-subtree.git",
"revision": "origin/master_sg1024"
},
{
"name": "hmb-fd-hv-sg600",
"gituri": "git@hydra:hmb-fd-hv-source/hmb-fd-hv-embedded-software-subtree.git",
"revision": "origin/master_sg600"
},
{
"name": "hmb-si-1536",
"gituri": "git@hydra:hmb-si-1536-source/hmb-si-1536-embedded-software-subtree.git",
"revision": "origin/master"
},
{
"name": "sm-200",
"gituri": "git@hydra:sm-200-source/sm-200-source-embedded-software-subtree.git",
"revision": "origin/master"
},
{
"name": "hmb-xr-5601",
"gituri": "git@hydra:hmb-xr-5601-source/hmb-xr-5601-embedded-software-subtree.git",
"revision": "origin/master"
}
],
"Exclude_paths": [
"core/utility/thirdparty"
]
}
*/
def String asJsonText() {
return writeJSON(returnText: true, json: sourceinfostore, pretty: 1)
}
def boolean exists() {
return (sourceinfostore != null)
}
def set(String jsontext) {
sourceinfostore = readJSON(text: jsontext)
echo "Source info:\n${asJsonText()}"
}
def get() {
return sourceinfostore
}
def sources() {
return sourceinfostore['Sources']
}
def excludepaths() {
return sourceinfostore['Exclude_paths']
}
pipeline {
agent { label AGENT_LABEL }
stages {
@ -5,6 +87,8 @@ pipeline {
steps {
script {
meta = load("${WORKSPACE}/autobuild/Common_scripts/autobuilder.groovy").startnonbuild(this)
set(SOURCE_INFO)
}
}
}
@ -13,16 +97,6 @@ pipeline {
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'
@ -46,25 +120,13 @@ pipeline {
}
}
}
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 {
SRC = "${WORKSPACE}/cd"
STATICANALYSIS = 'staticanalysis'
cleanfolders = [
SRC,
STATICANALYSIS,
]
cleaner = load("${autobuilder.commonscripts()}/clean/clean.groovy")
@ -72,11 +134,22 @@ pipeline {
}
}
}
stage('Generating version info') {
stage('Checkout product source') {
steps {
script {
version = load("${autobuilder.commonscripts()}/versionnumbering/generate.groovy")
version.generate(meta, SOURCE_REVISION, SOURCE_PATH)
if (SOURCE_OFFSET_PATH) {
SRC += "/${SOURCE_OFFSET_PATH}"
}
for(item in sources()) {
configurationhelper.gitCheckoutAndRegister(meta,
item['name'].trim(),
item['gituri'].trim(),
item['revision'].trim(),
"${SRC}/${item['name'].trim()}",
'',
0,
false)
}
}
}
}
@ -85,10 +158,9 @@ pipeline {
script {
def PPDFOLDER = "${STATICANALYSIS}/ppd"
def EXCLUDE_PARAM = ''
if (EXCLUDE_PATHS) {
if (excludepaths()) {
EXCLUDE_PARAM = '--exclude "'
def exclude_path_list = EXCLUDE_PATHS.split(',')
for (exclude_path in exclude_path_list) {
for (exclude_path in excludepaths()) {
EXCLUDE_PARAM += "${SRC}/${exclude_path.trim()},"
}
EXCLUDE_PARAM += '"'
@ -104,7 +176,7 @@ pipeline {
} else {
bat """
mkdir -p "${PPDFOLDER}"
set PMD_JAVA_OPTS=-Xmx2048m
set PMD_JAVA_OPTS=-Xmx65536m
"${PPD}/cpd.bat" --minimum-tokens 100 --files "${SRC}" --language cpp --format xml ${EXCLUDE_PARAM} --failOnViolation false > "${PPDFOLDER}/cpd.xml"
"""
}
@ -129,8 +201,7 @@ pipeline {
script {
ArrayList<String> itemsForRelease = ["${STATICANALYSIS}/**"]
def artifactlist = meta.generateartifacts(itemsForRelease)
artifactarchiver = load("${autobuilder.commonscripts()}/artifacts/archiver.groovy")
artifactarchiver.archive(meta, artifactlist)
archiveArtifacts "${artifactlist}"
}
}
}
@ -145,7 +216,7 @@ pipeline {
unstable {
echo 'Unstable build'
}
success {
success {
echo 'Succeeded build'
}
}

View file

@ -0,0 +1,116 @@
import jenkins.model.Jenkins
def TEST_ENVIRONMENT;
pipeline {
agent { label AGENT_LABEL }
stages {
stage ("Initial Setup") {
steps{
script {
meta = load("${WORKSPACE}/autobuild/Common_scripts/autobuilder.groovy").startnonbuild(this)
subJobs = []
//Set the label of the build job to reflect what triggered the job to run.
try{
currentBuild.description = "Running On ${env.NODE_NAME}, Triggered by ${currentBuild.upstreamBuilds[0].getFullDisplayName()}"
}
catch(Throwable e){
currentBuild.description = "Running On ${env.NODE_NAME}, Triggered Directly"
}
}
}
}
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[PRODUCT_NAME]
echo "Selected environment:\n${TEST_ENVIRONMENT}"
}
}
}
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 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)
}
}
}
stage('Perform CORE ethernet regression tests') {
steps {
script {
lock(TEST_ENVIRONMENT['RESOURCE_LOCK']) {
if (RUN_ETH_TESTS == 'true') {
EthTestJob = build (
job: "HMB_SE_D3000_run_tests",
parameters: [
string(name: 'TEST_SOURCE_REVISION', value: TEST_SOURCE_REVISION),
string(name: 'BUILD_JOB_TO_TEST', value: BUILD_JOB_TO_TEST),
string(name: 'BUILD_JOB_TO_TEST_SELECTOR', value: BUILD_JOB_TO_TEST_SELECTOR),
string(name: 'CORE_SOURCE_REVISION', value: CORE_SOURCE_REVISION),
booleanParam(name: 'CLEAN_WORKSPACE', value: CLEAN_WORKSPACE),
string(name: 'RELEASE_REPO', value: RELEASE_REPO),
string(name: 'PRODUCT_NAME', value: PRODUCT_NAME)
],
propagate: false
)
EthTestJobResults = load("${WORKSPACE}/autobuild/Common_scripts/test/testUtils.groovy").CheckForTestFailures(EthTestJob)
subJobs<<[ PrintHwTestJob, "EthTestJob", false, ]
}
}
}
}
}
stage("Archive test artifacts"){
steps{
script {
def artifactlist = meta.generateartifacts([ "${LOGGING_ROOT}/**"])
artifactarchiver = load("${autobuilder.commonscripts()}/artifacts/archiver.groovy")
artifactarchiver.archive(meta, artifactlist)
}
}
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,58 @@
import java.time.LocalDateTime
def selectbuild(buildnumber) {
return "<SpecificBuildSelector plugin=\"copyartifact@1.46.2\"><buildNumber>${buildnumber}</buildNumber></SpecificBuildSelector>"
}
pipeline {
agent { label AGENT_LABEL }
stages {
stage('Initial setup') {
steps {
script {
meta = load("${WORKSPACE}/autobuild/Common_scripts/autobuilder.groovy").startnonbuild(this)
}
}
}
stage('Import build meta') {
steps {
script {
configurationhelper = autobuilder.configurationhelper()
importer = load("${autobuilder.commonscripts()}/import/importer.groovy")
BUILDFOLDER = "${WORKSPACE}/build"
def buildimportoptions = importer.getNewImportOptions()
buildimportoptions.jenkinsjob(BUILD_JOB_TO_TEST, BUILD_JOB_TO_TEST_SELECTOR)
buildimportoptions.setincrementversionnumber(false)
buildimportoptions.setfilter('meta/**')
buildmeta = importer.artifactimport(meta, buildimportoptions, BUILDFOLDER)
}
}
}
stage('Mock test') {
steps {
script {
echo "Mock test"
def srcpath = 'autobuild/Common_scripts/test/mocktestinfo/results/success'
def destpath = 'results'
echo("Copying from mock results folder: ${srcpath} to results folder: ${destpath} recursively")
fileOperations([
folderCreateOperation(folderPath: destpath),
folderCopyOperation(sourceFolderPath: srcpath, destinationFolderPath: destpath)
])
}
}
}
stage('Archiving artifacts') {
steps {
script {
def artifacts = ['results/**']
def artifactlist = meta.generateartifacts(artifacts)
artifactarchiver = load("${autobuilder.commonscripts()}/artifacts/archiver.groovy")
artifactarchiver.archive(meta, artifactlist)
}
}
}
}
}

View file

@ -0,0 +1,166 @@
//To Be called by the ethernet test jobs to perform REST actions against the relay controller
//Note, HTTP Calls only seem to be executed by the master node and not the slave. Therefore consider the networking environment.
import groovy.json.JsonSlurper
def RawGet(url,timeout=5000){
println(" Making Get to: " + url);
def returnObject = {};
try{
def get = new URL(url).openConnection();
get.setReadTimeout(timeout);
get.setConnectTimeout(timeout);
def returnCode = get.getResponseCode();
if (returnCode.equals(200)) {
r_returnString= get.getInputStream().getText();
}
returnObject = [
"code":returnCode,
"response":r_returnString];
}
catch (SocketTimeoutException | ConnectException e){
println("SocketTimeout or ConnectionException attempting to GET " + url);
returnObject = ["code":"0",
"response":"SocketTimeoutException"];
}
catch( Exception e){
println("Exception attempting to GET " + url);
returnObject = ["code":"0",
"response":"clientException"];
throw (e)
}
return returnObject
}
def HttpGet(url,timeout=5000){
println(" Making Get to: " + url);
def returnObject = {};
try{
def get = new URL(url).openConnection();
get.setReadTimeout(timeout);
get.setConnectTimeout(timeout);
def returnCode = get.getResponseCode();
if (returnCode.equals(200)) {
r_returnString= get.getInputStream().getText();
}
def parser = new JsonSlurper()
returnObject = [
"code":returnCode,
"response":parser.parseText(r_returnString)];
}
catch (SocketTimeoutException | ConnectException e){
println("SocketTimeout or ConnectionException attempting to GET " + url);
returnObject = ["code":"0",
"response":"SocketTimeoutException"];
}
catch( Exception e){
println("Exception attempting to GET " + url);
returnObject = ["code":"0",
"response":"clientException"];
throw (e)
}
return returnObject
}
def NullPost(url,timeout=5000){
println(" Making Post to: " + url);
def returnObject = {};
try{
def slurper = new JsonSlurper()
def post = new URL(url).openConnection();
def message = '""'
post.setReadTimeout(timeout);
post.setConnectTimeout(timeout);
post.setRequestMethod("POST");
post.setDoOutput(true);
post.setRequestProperty("Content-Type", "application/json");
post.getOutputStream().write(message.getBytes("UTF-8"));
def returnCode = post.getResponseCode();
if (returnCode.equals(200)) {
r_returnString= post.getInputStream().getText();
}
def parser = new JsonSlurper()
returnObject = [
"code":returnCode,
"response":parser.parseText(r_returnString)];
return returnObject
}
catch (SocketTimeoutException | ConnectException e){
println("SocketTimeout or ConnectionException attempting to POST " + url);
returnObject = ["code":"0",
"response":"SocketTimeoutException"];
}
catch( Exception e){
println("Exception attempting to POST " + url);
returnObject = ["code":"0",
"response":"clientException"];
throw (e)
}
return returnObject
}
def PowerDownHMB(Host,Device,Channel){
// Send a power up request to the relay controller and device addressed in the profile.
def path = "http://" + Host + ":9001/api/powercontrollers/" + Device + "/switchOff/" + Channel
def response = NullPost(path);
println("PowerdownPost code is: " + response["code"])
println("PowerdownPost reponse is: " + response["response"])
//Only Flag as working is the correct response it received.
if (response["response"]["name"] != "poweredDown"){
return false;
}
else {
return true
}
}
def PowerUpHMB(Host,Device,Channel){
// Send a power up request to the relay controller and device addressed in the profile.
def path = "http://" + Host + ":9001/api/powercontrollers/" + Device + "/switchOn/" + Channel
def response = NullPost(path);
println("PowerupPost code is: " + response["code"])
println("PowerupPost reponse is: " + response["response"])
//Only Flag as working is the correct response it received.
if (response["response"]["name"] != "poweredUp"){
return false;
}
else {
return true
}
}
def PollForLife(url, isJson = true,timeout = 24){
//Hardcode to 2 minute timeout. Need to work out default values for arguments.
//simple polling loop to establish if an endpoint is available.
def returnVal = false;
for (int i = 0; i<timeout; i++){
if (isJson){
if (HttpGet(url)["code"] == 200){
returnVal = true;
break;
}
}
else {
if (RawGet(url)["code"] == 200){
returnVal = true;
break;
}
}
}
return returnVal
}
def InspectHMBPowerState(HMBAddress){
def url = "http://"+ HMBAddress + ":8080/api/headmanagerboards/0/productinfo";
return PollForLife(url)
}
def InspectControlServiceState(HMBAddress){
def url = "http://"+ HMBAddress + ":8081";
return PollForLife(url,false)
}
powercontrollerutils = this;
return this;

View file

@ -0,0 +1,99 @@
def producttestinfostore = null
/* Example expected JSON
{
"Product_regression_test_job": {
"HMB-FD-HV": {
"sg1024": {
"<any_buildstampprefix>": "HMB_FD_HV_master/HMB_FD_HV_master_sg1024_run_tests",
"0.9.10.": "HMB_FD_HV_0.9.10/HMB_FD_HV_0.9.10_sg1024_run_tests"
},
"sg600": {
"<any_buildstampprefix>": "HMB_FD_HV_master/HMB_FD_HV_master_sg600_run_tests"
}
},
"PRINT_SERVER": {
"<any_variant>": {
"<any_buildstampprefix>": "Print_Server_master/Print_Server_master_test"
}
},
"<any_product>": {
"<any_variant>": {
"<any_buildstampprefix>": "Generic_regression_test_job"
}
}
}
}
*/
def String asJsonText() {
return writeJSON(returnText: true, json: producttestinfostore, pretty: 1)
}
def boolean exists() {
return (producttestinfostore != null)
}
def set(String jsontext) {
producttestinfostore = readJSON(text: jsontext)
echo "Product test info:\n${asJsonText()}"
}
def get() {
return producttestinfostore
}
def productdetails(String productname) {
echo "Looking for product details associated with: ${productname} in: ${asJsonText()}"
pd = producttestinfostore[productname]
if (!pd) {
pd = producttestinfostore['<any_product>']
echo 'Found product details for: <any_product>'
}
echo "Product details for: ${productname}: ${pd}"
return pd
}
def variantdetails(productdetails, String productvariant) {
echo "Looking for variant details associated with: ${productvariant} in ${productdetails}"
vd = productdetails[productvariant]
if (!vd) {
vd = productdetails['<any_variant>']
echo 'Found variant details for: <any_variant>'
}
echo "Variant details for: ${productvariant}: ${vd}"
return vd
}
def buildstampprefixdetails(variantdetails, String buildstampprefix) {
echo "Looking for build stamp prefix associated with: ${buildstampprefix} in ${variantdetails}"
bspd = variantdetails[buildstampprefix]
if (!bspd) {
bspd = variantdetails['<any_buildstampprefix>']
echo 'Found build stamp prefix details for: <any_buildstampprefix>'
}
echo "Build stamp prefix details for: ${buildstampprefix}: ${bspd}}"
return bspd
}
def getRegressionTestJobName(String productname, String productvariant, String buildstampprefix) {
if (!productname) { productname = '<any_product>' }
if (!productvariant) { productvariant = '<any_variant>' }
if (!buildstampprefix) { buildstampprefix = '<any_buildstampprefix>' }
echo "Looking for Test Job suitable for product: ${productname} variant: ${productvariant} build stamp prefix: ${buildstampprefix}"
productinfo = productdetails(productname)
if (productinfo) {
productvariantinfo = variantdetails(productinfo, productvariant)
if (productvariantinfo) {
buildstampprefixinfo = buildstampprefixdetails(productvariantinfo, buildstampprefix)
if (buildstampprefixinfo) {
echo "Test Job suitable for product: ${productname} variant: ${productvariant} build stamp prefix: ${buildstampprefix} is: ${buildstampprefixinfo}"
return buildstampprefixinfo
}
}
}
return ''
}
return this

View file

@ -0,0 +1,40 @@
import java.time.LocalDateTime
def m_testresultsstorepathroot = null
def selectbuild(buildnumber) {
return "<SpecificBuildSelector plugin=\"copyartifact@1.46.2\"><buildNumber>${buildnumber}</buildNumber></SpecificBuildSelector>"
}
def handleresults(buildmeta,
boolean testsuccess,
importer,
regression_test_job,
String testresultsstorepathroot) {
m_testresultsstorepathroot = testresultsstorepathroot
if (testsuccess) {
def resultsimportoptions = importer.getNewImportOptions()
resultsimportoptions.jenkinsjob(regression_test_job.getProjectName(), selectbuild(regression_test_job.getNumber()))
resultsimportoptions.setincrementversionnumber(false)
resultsimportoptions.setfilter('meta/**')
testmeta = importer.artifactimport(meta, resultsimportoptions, )
testdate = testmeta.jenkinsbuildinfo.buildDateAsLocalDate().toString()
} else {
testdate = buildmeta.jenkinsbuildinfo.buildDateAsLocalDate().toString()
}
productname = buildmeta.productinfo.productname
productvariant = buildmeta.productinfo.variant
buildstampprefix = buildmeta.buildstampinfo.buildstampprefix
RESULTS_FOLDER = "${m_testresultsstorepathroot}/${testdate}/${productname}/${(productvariant) ? productvariant : '-' }/${buildstampprefix}"
if (testsuccess) {
def resultsimportoptions2 = importer.getNewImportOptions()
resultsimportoptions2.jenkinsjob(regression_test_job.getProjectName(), selectbuild(regression_test_job.getNumber()))
resultsimportoptions2.setincrementversionnumber(false)
testmeta2 = importer.artifactimport(meta, resultsimportoptions2, RESULTS_FOLDER)
}
}
return this

View file

@ -0,0 +1,18 @@
//To be called by test master jobs, Evaluates the results of a lower meta build to identify if is passed of failed so that it will ripple up the stack.
def CheckForTestFailures(TestObject) {
if (TestObject.result == 'UNSTABLE') {
unstable("Tests Failed ${TestObject.getProjectName()}")
}
else if (TestObject.result == 'SUCCESS') {
echo("Tests Passed ${TestObject.getProjectName()}")
} else {
error("Tests Job ${TestObject.getProjectName()} Failure with result ${TestObject.result}! Investigate Job/Slave Setup")
}
}
//Setup like a model where you can return yourself allow access to methods and objects contained
testUtils = this;
return this;

View file

@ -1,12 +1,21 @@
import jenkins.model.Jenkins
def TEST_ENVIRONMENT;
pipeline {
agent { label AGENT_LABEL }
stages {
stage ("Initial Setup") {
steps{
script {
//Load the common build tools.
meta = load("${WORKSPACE}/autobuild/Common_scripts/autobuilder.groovy").startnonbuild(this)
subJobs = []
//Set the label of the build job to reflect what triggered the job to run.
try{
currentBuild.description = "Running On ${env.NODE_NAME}, Triggered by ${currentBuild.upstreamBuilds[0].getFullDisplayName()}"
}
catch(Throwable e){
currentBuild.description = "Running On ${env.NODE_NAME}, Triggered Directly"
}
}
}
}
@ -25,180 +34,240 @@ pipeline {
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]
def alltestenvironment = readJSON(file: TEST_ENVIRONMENT_FILE)
//TODO: Configure the build jobs to submit the product name only of the resource we wish to query e.g. HMB_SE_D3000, not HMB_SE_D3000_2
//TEST_ENVIRONMENT = load("${autobuilder.commonscripts()}/test/testresourceselector.groovy").LocateResources(ETHERNET_PRODUCT_TO_RUN_TEST)
TEST_ENVIRONMENT = alltestenvironment[PRODUCT_NAME]
//HMBUtils = load("${autobuilder.commonscripts()}/test/powercontrollerutils.groovy")
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 ("Checkout dependencies") {
steps {
script {
def PYTHON_URL = 'git@hydra:tools/python.git'
if (isUnix()) {
PYTHON_REVISION = 'origin/3.6.3_linux'
}
}
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)
}
else {
PYTHON_REVISION = 'origin/3.8.10_windows_for_test'
}
}
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)
}
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"
//HISTORY_REVISION =
//HISTORY_REPO
//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 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 ('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 ("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 ('Update HMB and Run Tests') {
steps {
script {
//Set 3 Hour timeout.
timeout(180){
//load the hmb utils onto the node that is using them.
HMBUtils = load("${autobuilder.commonscripts()}/test/powercontrollerutils.groovy");
env.SM_IP_ADDRESS = TEST_ENVIRONMENT["SM_200"]["IP_ADDRESS"];
env.HMB_IP_ADDRESS = TEST_ENVIRONMENT["IP_ADDRESS"];
SMReady = bat (script:"""
"${PYTHON}" "${GIS_TEST_SUITE_CORE}/HMBCommon/hmbpollforlife.py" -t "${SM_IP_ADDRESS}"
""",
returnStatus: true
)
if (0 != SMReady){
HMBUtils.PowerUpHMB(
TEST_ENVIRONMENT["SM_200"]['POWER_CONTROLLER']["HOST"],
TEST_ENVIRONMENT["SM_200"]['POWER_CONTROLLER']["NAME"],
TEST_ENVIRONMENT["SM_200"]['POWER_CONTROLLER']["CHANNEL"]);
SMReady = bat (script:"""
"${PYTHON}" "${GIS_TEST_SUITE_CORE}/HMBCommon/hmbpollforlife.py" -t "${SM_IP_ADDRESS}"
""",
returnStatus: true
);
println("SMReady is..." );
println(SMReady);
if (0 != SMReady ){
error("Unable to get SM200 into correct state.")
}
}
}
}
stage("Archive Test History") {
steps{
script {
dir(HISTORY_FOLDER) {
rc = bat (script:"""
"${PYTHON}" "${HISTORY_PROCESSING_DIR}/GitCyclicPush.py"
""",
returnStatus: true
else {
println("SM detected at ${SM_IP_ADDRESS}")
}
if (POWER_CYCLE_HARDWARE == 'true') {
println("Attempted to turn on HMB")
HMBUtils.PowerDownHMB(
TEST_ENVIRONMENT['POWER_CONTROLLER']["HOST"],
TEST_ENVIRONMENT['POWER_CONTROLLER']["NAME"],
TEST_ENVIRONMENT['POWER_CONTROLLER']["CHANNEL"]
)
}
//Always turn the hardware back on.
HMBUtils.PowerUpHMB(
TEST_ENVIRONMENT['POWER_CONTROLLER']["HOST"],
TEST_ENVIRONMENT['POWER_CONTROLLER']["NAME"],
TEST_ENVIRONMENT['POWER_CONTROLLER']["CHANNEL"]
)
Ready = bat (script:"""
"${PYTHON}" "${GIS_TEST_SUITE_CORE}/HMBCommon/hmbpollforlife.py" -t "${HMB_IP_ADDRESS}"
""",
returnStatus: true
)
if (Ready != 0){
error("unable to get hardware at address" + TEST_ENVIRONMENT["IP_ADDRESS"] + "into a known state before upgrade.");
}
else {
println("hardware at address" + TEST_ENVIRONMENT["IP_ADDRESS"] + "is available and ready for next steps.");
}
if (UPDATE_HARDWARE == 'true') {
println("Updating Hardware")
dir(GIS_TEST_SUITE_CORE) {
bat """
"${PYTHON}" "${GIS_TEST_SUITE_CORE}/HMBCommon/hmbPackageDeployer.py" -p "${APPLICATION_ARTIFACT_FOLDER}" -c -t "${TEST_ENVIRONMENT['IP_ADDRESS']}"
"""
Ready = bat (script:"""
"${PYTHON}" "${GIS_TEST_SUITE_CORE}/HMBCommon/hmbpollforlife.py" -t "${HMB_IP_ADDRESS}"
""",
returnStatus: true
)
if (rc == 1) {
unstable('FAILED to process history')
if (Ready != 0){
error("unable to get hardware at address" + TEST_ENVIRONMENT["IP_ADDRESS"] + "into a known state before upgrade.");
}
}
}
TestSuiteProfileUtils = load("${autobuilder.commonscripts()}/test/testprofileutils.groovy")
def TEST_PRODUCT_NAME = TestSuiteProfileUtils.LookUpProduct(PRODUCT_NAME)
def PRODUCT_UNDER_TEST = TestSuiteProfileUtils.LookUpTestArgument(PRODUCT_NAME)
def TEST_INCLUDE_FILTER = TestSuiteProfileUtils.LookUpTestFilter(PRODUCT_NAME)
println("Swapping target Ipaddress on target to match that which is configured in test profile.")
rc = bat(script:"""
${PYTHON} "${GIS_TEST_SUITE_CORE}/HMBCommon/swapconfig.py" -p ${TEST_PRODUCT_NAME} -t "${HMB_IP_ADDRESS}"
""",
returnStatus: true
)
if (rc != 0) {
error('Failed to update test profile, client will miss target hardware.')
}
if (DO_TEST == 'true') {
rc = bat(script:"""
${PYTHON} "${GIS_TEST_SUITE_CORE}/GISTestMaster.py" ${PRODUCT_UNDER_TEST} installed -fl --include ${TEST_INCLUDE_FILTER}
""",
returnStatus: true
)
if (rc == 1) {
unstable('FAILED while running tests')
}
}
}
}
stage("Archive test artifacts"){
steps{
script {
def artifactlist = meta.generateartifacts([ "${LOGGING_ROOT}/**"])
artifactarchiver = load("${autobuilder.commonscripts()}/artifacts/archiver.groovy")
artifactarchiver.archive(meta, artifactlist)
}
}
/*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)
}
}
}
}
}

View file

@ -0,0 +1,97 @@
import java.nio.file.Paths
import groovy.json.JsonSlurper
import groovy.json.JsonOutput
def SwapHMBTarget(testCoreRoot,profileName,product,NewTarget){
//To support both the static profile model and dynamic changing of target IP address, jenkins must swap the target Ip address of the file.
println("Updating ${product} IP for profile ${profileName} to ${NewTarget}.");
def parser = new JsonSlurper()
def ProfilePath = "${testCoreRoot}/CoreUtils/machineprofiles/${profileName}.json"
println("Selected path " + ProfilePath + " HMB IP address too " + NewTarget)
JsonData = parser.parse(new File (ProfilePath));
println(JsonData)
JsonData[product]["Address"] = NewTarget;
println(JsonData)
File Writefile = new File(ProfilePath);
Writefile.write(JsonOutput.prettyPrint(JsonOutput.toJson(JsonData)));
println("Updating " + ProfilePath + "Complete")
return;
}
def LookUpProduct(JenkinsProductKey,variant=""){
//TODO Unify this with test profiles to avoid repetition and mapping.
//Translates from Autobuild Product name to test profile HMB entity name.
def ProductLookup = [
"HMB-SE-D3000":"HMB_SE_D3000",
"HMB-SE-S800":"HMB_SE_S800",
"HMB-FD-HV":[
"sg600":"HMB_FD_HV",
"sg1024":"HMB_FD_HV",
],
"AHB-KM-1024A": [
"she":"AHB_KM_1024A",
"lhg":"AHB_KM_1024A"
],
"HMB-SI-1536":"HMB_SI_1536",
"HMB-KY-M16ST":"HMB_KY_M16ST"
];
return ProductLookup[JenkinsProductKey]
}
def LookUpTestArgument(JenkinsProductKey,variant=""){
//Translates from Autobuild Product name to include filter for tests targetting that product.
def TestFilters = [
"HMB-SE-D3000":"--hmbsed3000",
"HMB-SE-S800":"--hmbses800",
"HMB-FD-HV":[
"sg600":"--hmbsg600",
"sg1024":"hmbsg1024",
],
"AHB-KM-1024A": [
"she":"--hmbkm1024a",
"lhg":"--hmbkm1024a"
],
"HMB-SI-1536":"--hmbsi1536",
"HMB-KY-M16ST":"--hmbkym16st"
];
return TestFilters[JenkinsProductKey]
}
def LookUpTestFilter(JenkinsProductKey,variant=""){
//Translates from Autobuild Product name to include filter for tests targetting that product.
def TestFilters = [
"HMB-SE-D3000":".*d3000",
"HMB-SE-D3000":".*s800",
"HMB-FD-HV":[
"sg600":".*sg600",
"sg1024":".*sg1024",
],
"AHB-KM-1024A": [
"she":".*km1024a",
"lhg":".*km1024a"
],
"HMB-SI-1536":".*si1536",
"HMB-KY-M16ST":".*kym16st"
];
if (variant == ""){
return TestFilters[JenkinsProductKey]
}
else{
TestFilters[JenkinsProductKey][variant]
}
}
def ReverseProduct(TestProductKey){
//TODO Unify this with test profiles to avoid repetition and mapping.
//Translates from test profile HMB entity name to Autobuild Product name.
def ReverseProductLookup = ["HMB_SE_D3000":"HMB-SE-D3000",
];
return ReverseProductLookup[JenkinsProductKey]
}
testprofileutilsutils = this;
return this;

View file

@ -0,0 +1,23 @@
//To be called by the ethernet test script to query for a usable resource.
def LocateResources(AllTestEnvironmentPath,TargetHardware){
def AllTestEnvironements = readJSON(AllTestEnvironmentPath);
}
// GET
def DoGET(url){
def get = new URL(url).openConnection();
def getRC = get.getResponseCode();
if (getRC.equals(200)) {
def Response = get.getInputStream().getText();
}
else{
def Response = "Request Failed"
echo("REST: received ${getRC} from GET to ${url}");
}
echo("REST: received ${getRC} from GET to ${url}");
}
TestResourceUnpacker = this;
return this;

View file

@ -0,0 +1,37 @@
/*
* Install a list of packages though the usual apt-get system.
* This requires that the packages are available from the configured repos
*/
def installPackages(ArrayList<String> packageNames, String root_credentials_id) {
echo "Using credentials: ${root_credentials_id}"
withCredentials([usernamePassword(credentialsId: root_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"
sh """
${sudo_Sk} apt-get -y install ${packageNames.join(' ')}
"""
}
}
/*
* Install all system packages needed by the ESW build
* for x86 (i.e. not cross-compilation) targets
*/
def installX86EswBuildDeps(String root_credentials_id) {
def packages = [
"build-essential",
"lld"
]
// This should at least contain the x86 counterpart to the ARM compiler
def gccPackages = ["gcc-10", "g++-10"]
def allPackages = packages + gccPackages
installPackages(allPackages, root_credentials_id)
}
return this;

View file

@ -102,7 +102,7 @@ def String checkouttoreporoot(String gitURL) {
branches: [
[name: 'origin/master']
],
doGenerateSubmoduleConfigurations: false,
doGenerateSubmoduleConfigurations: false,
extensions: [
[$class: 'GitLFSPull'],
[$class: 'CleanBeforeCheckout'],
@ -134,6 +134,7 @@ def String checkouttoreporoot(String gitURL) {
}
def checkgitlfsinstall() {
echo "Doing: git lfs install"
if (isUnix()) {
sh """
git lfs install
@ -142,6 +143,7 @@ def checkgitlfsinstall() {
} else {
powershell """
git config --unset core.hooksPath
git lfs install
if (\$lastexitcode -ge 1) { exit 1 }
"""
@ -307,7 +309,7 @@ def gitsparserestore(String targetDir) {
def List convertSparseItemsString(String itemstopublish) {
def List sparsepaths = []
boolean nonempty = itemstopublish?.trim()
if (nonempty) {
def String[] items = itemstopublish.trim().split(',')

View file

@ -1,5 +1,5 @@
gh = load("${autobuilder.commonscripts()}/versioncontrol/git.groovy")
def int maxversionnumber() {
def int MAXVERSIONNUMBER = 65535
return MAXVERSIONNUMBER
@ -21,7 +21,7 @@ def getGitRevision(String gitrootpath, int basebuildnumber = 0) {
if (isShallowCloned) {
error("Cannot generate a version number from a shallow cloned repo at ${gitrootpath}")
}
dir( gitrootpath) {
def int changecount = 0
if (isUnix()) {
@ -88,10 +88,11 @@ def getVersionPrefix(String sourcebranch, boolean droptrailingdot = false) {
return thirdpartyversionprefix
}
def xtypeversionprefix = "0.21000.0."
for (split in splits2) {
if (split == "x") {
echo "Source branch name has '.x' or 'x.' in it. Defaulting to: ${mastertypeversionprefix}"
return mastertypeversionprefix
if (split.toLowerCase().startsWith("x")) {
echo "Source branch name has '.x' or 'x.' in it. Defaulting to: ${xtypeversionprefix}"
return xtypeversionprefix
}
}

View file

@ -0,0 +1,199 @@
def selectbuild(buildnumber) {
return "<buildNumber>${buildnumber}</buildNumber>"
}
pipeline {
agent { label AGENT_LABEL }
stages {
stage('Initial setup') {
steps {
script {
meta = load("${WORKSPACE}/autobuild/Common_scripts/autobuilder.groovy").startbuild(this, PRODUCT_NAME, SUBCOMPONENT_NAME, RELEASE_REPO)
subcomponentinfo = load("${autobuilder.commonscripts()}/vertical_stack/subcomponent_info.groovy")
subcomponentinfo.set(SUB_COMPONENT_INFO)
}
}
}
stage("Clean exports") {
steps {
script {
ATLASDEST = "atlas"
MCSDEST = "mcs"
PDFRSDEST = "pdfrs"
HMBDEST = "hmb"
SMDEST = "sm"
IMBDEST = "imb"
cleanfolders = [
ATLASDEST,
MCSDEST,
PDFRSDEST,
HMBDEST,
SMDEST,
IMBDEST,
]
cleaner = load("${autobuilder.commonscripts()}/clean/clean.groovy")
cleaner.clean(cleanfolders)
}
}
}
stage('Setup environment') {
steps {
script {
importer = load("${autobuilder.commonscripts()}/import/importer.groovy")
artifactFolders = new ArrayList<String>()
meta.buildstampinfo.set(BUILD_STAMP_PREFIX)
}
}
}
stage('Import') {
failFast true
parallel {
stage('Import Atlas UI and Atlas Services') {
steps {
script {
def atlasinfo = subcomponentinfo.namedartifactinfo('ATLAS_UI')
def atlasimportoptions = importer.getNewImportOptions()
subcomponentinfo.source(atlasimportoptions, atlasinfo)
atlasimportoptions.setincrementversionnumber(true)
atlasimportoptions.setnested(true)
atlasbuildmeta = importer.artifactimport(meta, atlasimportoptions, ATLASDEST)
artifactFolders.add("${ATLASDEST}/**")
mcsbuiltforatlasui = subcomponentinfo.useAtlasServicesBuiltWithAtlasUI()
if (mcsbuiltforatlasui) {
// Import MCS from the related component
def mcsimportoptions = importer.getNewImportOptions()
mcsimportoptions.setsourceselect(atlasinfo.artifactlocation())
mcsimportoptions.setincrementversionnumber(true)
mcsimportoptions.setnested(true)
asbuildmeta = importer.artifactimport(meta, atlasbuildmeta, ATLASDEST, 'ATLAS_SERVICES', 'WHOLE', mcsimportoptions, MCSDEST)
} else {
def mcsinfo = subcomponentinfo.namedartifactinfo('ATLAS_SERVICES')
// Import MCS from the component parameter
def mcsimportoptions = importer.getNewImportOptions()
subcomponentinfo.source(mcsimportoptions, mcsinfo)
mcsimportoptions.setincrementversionnumber(true)
mcsimportoptions.setnested(true)
asbuildmeta = importer.artifactimport(meta, mcsimportoptions, MCSDEST)
}
artifactFolders.add("${MCSDEST}/**")
}
}
}
stage('Import PDF RS') {
steps {
script {
def pdfrsinfo = subcomponentinfo.namedartifactinfo('PDF_RENDER_SERVER')
def pdfrsimportoptions = importer.getNewImportOptions()
subcomponentinfo.source(pdfrsimportoptions, pdfrsinfo)
pdfrsimportoptions.setincrementversionnumber(true)
pdfrsimportoptions.setnested(true)
importer.artifactimport(meta, pdfrsimportoptions, PDFRSDEST)
artifactFolders.add("${PDFRSDEST}/**")
}
}
}
stage('Import HMB') {
steps {
script {
def hmbinfo = subcomponentinfo.namedartifactinfo('HEAD_MANAGER_BOARD')
def hmbimportoptions = importer.getNewImportOptions()
subcomponentinfo.source(hmbimportoptions, hmbinfo)
hmbimportoptions.setincrementversionnumber(true)
hmbimportoptions.setnested(true)
importer.artifactimport(meta, hmbimportoptions, HMBDEST)
artifactFolders.add("${HMBDEST}/**")
}
}
}
stage('Import SM') {
steps {
script {
def sminfo = subcomponentinfo.namedartifactinfo('SYSTEM_MANAGER')
def smimportoptions = importer.getNewImportOptions()
subcomponentinfo.source(smimportoptions, sminfo)
smimportoptions.setincrementversionnumber(true)
smimportoptions.setnested(true)
importer.artifactimport(meta, smimportoptions, SMDEST)
artifactFolders.add("${SMDEST}/**")
}
}
}
stage('Import IMB') {
steps {
script {
def imbinfo = subcomponentinfo.namedartifactinfo('INK_MANAGER_BOARD')
def imbimportoptions = importer.getNewImportOptions()
subcomponentinfo.source(imbimportoptions, imbinfo)
imbimportoptions.setincrementversionnumber(true)
imbimportoptions.setnested(true)
importer.artifactimport(meta, imbimportoptions, IMBDEST)
artifactFolders.add("${IMBDEST}/**")
}
}
}
}
}
stage('Build integrity check') {
steps {
script {
def integrity = load("${autobuilder.commonscripts()}/build/integrity.groovy")
def results = integrity.check(meta)
if (!results.good) {
unstable("Build integrity check failed: \n ${results.comment}")
}
}
}
}
stage('Classifying publishable artifacts') {
steps {
script {
def publishable = []
def publishutils = load("${autobuilder.commonscripts()}/publishing/utils.groovy")
publishutils.generatelist(meta, publishable)
}
}
}
stage('Archiving artifacts') {
steps {
script {
def artifactlist = meta.generateartifacts([], artifactFolders)
artifactarchiver = load("${autobuilder.commonscripts()}/artifacts/archiver.groovy")
artifactarchiver.archive(meta, artifactlist)
}
}
}
}
post {
always {
echo 'Post-build'
}
failure {
echo 'Failed build'
script {
load("${autobuilder.commonscripts()}/build/postactions.groovy").performFailedBuildActions(meta)
}
}
unstable {
echo 'Unstable build'
}
success {
echo 'Succeeded build'
script {
load("${autobuilder.commonscripts()}/build/postactions.groovy").performSuccessfulBuildActions(meta)
}
}
}
}

View file

@ -0,0 +1,93 @@
def verticalstackinfostore = null
/* Example expected JSON
{
"COMPONENTS" : {
"ATLAS_UI": {
"ARTIFACT_LOCATION": "Release repository",
"BUILD_JOB": "Atlas_3.0.9/Atlas_3.0.9_build",
"BUILD_JOB_SELECTOR": "<stable>true</stable>",
"RELEASE_REPO": "git@hydra:atlas-ui-releases/atlas_ui_whole.git",
"RELEASE_REVISION": "refs/tags/3.0.9.52395_53"
},
"ATLAS_SERVICES": {
"ARTIFACT_LOCATION": "Release repository",
"BUILD_JOB": "MCS_1.0.9/MCS_1.0.9_build",
"BUILD_JOB_SELECTOR": "<stable>true</stable>",
"RELEASE_REPO": "git@hydra:atlas-services-releases/atlas_services_whole.git",
"RELEASE_REVISION": "refs/tags/1.0.3.1292_54"
},
"PDF_RENDER_SERVER": {
"ARTIFACT_LOCATION": "Release repository",
"BUILD_JOB": "PDF_Render_Server_1.0.3/PDF_Render_Server_1.0.3_build",
"BUILD_JOB_SELECTOR": "<stable>true</stable>",
"RELEASE_REPO": "git@hydra:pdf-render-server-releases/pdf_render_server_whole.git",
"RELEASE_REVISION": "refs/tags/1.0.3.1292_54"
},
"HEAD_MANAGER_BOARD": {
"ARTIFACT_LOCATION": "Release repository",
"BUILD_JOB": "HMB_SE_D3000_0.9.13/HMB_SE_D3000_0.9.13_build",
"BUILD_JOB_SELECTOR": "<stable>true</stable>",
"RELEASE_REPO": "git@hydra:hmb_se_d3000-releases/hmb_se_d3000_whole.git",
"RELEASE_REVISION": "refs/tags/0.9.9.8897_2"
},
"SYSTEM_MANAGER": {
"ARTIFACT_LOCATION": "Release repository",
"BUILD_JOB": "SM200_1.1.0/SM200_1.1.0_build",
"BUILD_JOB_SELECTOR": "<stable>true</stable>",
"RELEASE_REPO": "git@hydra:sm200-releases/sm200_whole.git",
"RELEASE_REVISION": "refs/tags/1.0.6.31386_8"
},
"INK_MANAGER_BOARD": {
"ARTIFACT_LOCATION": "Release repository",
"BUILD_JOB": "IMB_1.5.18/IMB_1.5.18_build",
"BUILD_JOB_SELECTOR": "<stable>true</stable>",
"RELEASE_REPO": "git@hydra:imb-releases/imb_whole.git",
"RELEASE_REVISION": "refs/tags/1.5.18.21422_40"
}
},
"USE_ATLAS_SERVICES_BUILT_WITH_ATLAS_UI": true
}
*/
def String asJsonText() {
return writeJSON(returnText: true, json: verticalstackinfostore, pretty: 1)
}
def boolean exists() {
return (verticalstackinfostore != null)
}
def set(String jsontext) {
verticalstackinfostore = readJSON(text: jsontext)
echo "Vertical stack info:\n${asJsonText()}"
}
def get() {
return verticalstackinfostore
}
def namedartifactinfo(componentname) {
return verticalstackinfostore['COMPONENTS'][componentname]
}
def String artifactlocation(namedartifactinfo) {
return namedartifactinfo['ARTIFACT_LOCATION']
}
def source(importoptions, namedartifactinfo) {
importoptions.source(
artifactlocation(namedartifactinfo),
namedartifactinfo['BUILD_JOB'],
namedartifactinfo['BUILD_JOB_SELECTOR'],
namedartifactinfo['RELEASE_REPO'],
namedartifactinfo['RELEASE_REVISION']
)
}
def boolean useAtlasServicesBuiltWithAtlasUI() {
return verticalstackinfostore['USE_ATLAS_SERVICES_BUILT_WITH_ATLAS_UI']
}
return this

View file

@ -39,10 +39,10 @@ protected:
uint32_t seq[] = NULL,
uint32_t seqLen = 0,
uint32_t pgSel = 0,
CPulseGenerator3Auto* pPulseGenIn = 0) // If pPulseGenIn is valid, it overides any selection from pgSel.
// Used to add > 4 Pulse Generators, where required.
CPulseGenerator3Auto* pPulseGenIn = 0, // If pPulseGenIn is valid, it overides any selection from pgSel.
bool reverse = false) // Used to add > 4 Pulse Generators, where required.
{
configPdEmulator (pCore, divRatio, encFreqKHz, clkFreqMHz);
configPdEmulator (pCore, divRatio, encFreqKHz, clkFreqMHz, reverse);
fpmConfig (pCore, divRatio, numSubPixPhases, seq, seqLen, pgSel, pPulseGenIn);
};
@ -131,9 +131,16 @@ protected:
// ------------------------------------
// Configure the product detect emulator
//
void configPdEmulator(CCoreAuto* pCore, double divRatio, double encFreqKHz, double clkFreqMHz = 100.0)
void configPdEmulator(CCoreAuto* pCore, double divRatio, double encFreqKHz, double clkFreqMHz, bool reverse)
{
pCore->pEncPdEmul1->pEncCtrl->SetSetAbsPos(1);
if (reverse) {
pCore->pEncPdEmul1->pEncCtrl->SetSetAbsPos(1);
pCore->pEncPdEmul1->pEncCtrl->SetEncDir(1);
}
else {
pCore->pEncPdEmul1->pEncCtrl->SetSetAbsPos(1);
pCore->pEncPdEmul1->pEncCtrl->SetEncDir(0);
}
// Select source of pulses
pCore->pFpmCtrl6->pSignalselection->SetFirePulseSel(1);
@ -150,13 +157,13 @@ protected:
// Generate a set of product detects
// spaced at a given period
//
void generatePDs(CCoreAuto* pCore, uint32_t numPDs, uint32_t periodNs)
void generatePDs(CCoreAuto* pCore, uint32_t numPDs, uint32_t periodNs, bool noStartupDelay = false)
{
for (int idx = 0; idx < numPDs; idx++)
{
issuePd(pCore->pEncPdEmul1);
if (idx == 0)
if ((idx == 0) && !noStartupDelay)
{
nsleepSim(periodNs - REG_WR_LATENCY_NS + STARTUP_LATENCY_NS);
}