Merge commit '5bc60a0ef8'
This commit is contained in:
commit
e0407fb027
5 changed files with 238 additions and 4 deletions
86
check/build_meta.groovy
Normal file
86
check/build_meta.groovy
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
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()
|
||||
archiveArtifacts "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
check/do_meta.groovy
Normal file
77
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.meta.componentversionuniqueidentifier()
|
||||
def offsetpath = entry.offsetpath
|
||||
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.offsetpath
|
||||
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;
|
||||
56
copy/logic.groovy
Normal file
56
copy/logic.groovy
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
pipeline {
|
||||
agent { label "${AGENT_LABEL}" }
|
||||
stages {
|
||||
stage('Initial setup') {
|
||||
steps {
|
||||
script {
|
||||
meta = load("${WORKSPACE}/autobuild/Common_scripts/autobuilder.groovy").startnonbuild(this)
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Clean exports') {
|
||||
steps {
|
||||
script {
|
||||
cleanfolders = [
|
||||
"${WORKSPACE}/logic",
|
||||
]
|
||||
cleaner = load("${autobuilder.commonscripts()}/clean/clean.groovy")
|
||||
cleaner.clean(cleanfolders)
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Copying logic artifacts') {
|
||||
steps {
|
||||
script {
|
||||
env.LOGICDEST = "${WORKSPACE}/logic"
|
||||
if (LOGIC_ARTIFACT_LOCATION == "Jenkins job artifact") {
|
||||
importer = load("${autobuilder.commonscripts()}/import/importer.groovy")
|
||||
importer.artifactimport(meta, LOGIC_ARTIFACT_PROJECT, LOGIC_ARTIFACT_BUILD_SELECTOR, LOGICDEST)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Archiving artifacts') {
|
||||
steps {
|
||||
script {
|
||||
def artifactlist = meta.generateartifacts(["logic/**"])
|
||||
archiveArtifacts "${artifactlist}"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
post {
|
||||
always {
|
||||
echo 'Post-build'
|
||||
}
|
||||
failure {
|
||||
echo 'Failed build'
|
||||
}
|
||||
unstable {
|
||||
echo 'Unstable build'
|
||||
}
|
||||
success {
|
||||
echo 'Succeeded build'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -687,6 +687,18 @@ class MetaInfo extends GISJsonSerialised {
|
|||
return productinfo.productname + "_" + productinfo.subcomponentname + "_" + buildstampinfo.buildstamp
|
||||
}
|
||||
|
||||
Map<String, RelatedMetaInfo> putwithshortestoffsetpath(Map<String, RelatedMetaInfo> releasemetacollection, String uniquestring, RelatedMetaInfo relatedmetainfo) {
|
||||
if (releasemetacollection.containsKey(uniquestring)) {
|
||||
def existingentry = releasemetacollection[uniquestring]
|
||||
if (existingentry.offsetpath.size() > relatedmetainfo.offsetpath.size()) {
|
||||
releasemetacollection.put(uniquestring, relatedmetainfo)
|
||||
}
|
||||
} else {
|
||||
releasemetacollection.put(uniquestring, relatedmetainfo)
|
||||
}
|
||||
return releasemetacollection
|
||||
}
|
||||
|
||||
Map<String, RelatedMetaInfo> releasewalkerunique(int maxdepth, String startpath = "") {
|
||||
def ArrayList<RelatedMetaInfo> releasemetacollection = new ArrayList<RelatedMetaInfo>()
|
||||
releasemetacollection = releasewalkerp(maxdepth, releasemetacollection, startpath)
|
||||
|
|
@ -694,7 +706,7 @@ class MetaInfo extends GISJsonSerialised {
|
|||
def Map<String, RelatedMetaInfo> releasemetauniquecollection = new LinkedHashMap<String, RelatedMetaInfo>()
|
||||
for (relatedmetainfo in releasemetacollection) {
|
||||
def String uniquestring = relatedmetainfo.meta.componentidentifier()
|
||||
releasemetauniquecollection.put(uniquestring, relatedmetainfo)
|
||||
releasemetauniquecollection = putwithshortestoffsetpath(releasemetauniquecollection, uniquestring, relatedmetainfo)
|
||||
}
|
||||
|
||||
return releasemetauniquecollection
|
||||
|
|
@ -707,7 +719,7 @@ class MetaInfo extends GISJsonSerialised {
|
|||
def Map<String, RelatedMetaInfo> releasemetaversionuniquecollection = new LinkedHashMap<String, RelatedMetaInfo>()
|
||||
for (relatedmetainfo in releasemetacollection) {
|
||||
def String uniquestring = relatedmetainfo.meta.componentversionuniqueidentifier()
|
||||
releasemetaversionuniquecollection.put(uniquestring, relatedmetainfo)
|
||||
releasemetaversionuniquecollection = putwithshortestoffsetpath(releasemetaversionuniquecollection, uniquestring, relatedmetainfo)
|
||||
}
|
||||
|
||||
return releasemetaversionuniquecollection
|
||||
|
|
|
|||
|
|
@ -26,15 +26,18 @@ def main(argv):
|
|||
print("Could not find file: {0}\n".format(filetoconvert))
|
||||
return 1
|
||||
|
||||
count = 0
|
||||
with open(filetoconvert, 'x') as f:
|
||||
with open(filecopy,'r') as c:
|
||||
fileread = c.read()
|
||||
print("Detected %s instances of %s pre-conversion"%(fileread.count(pattern),pattern))
|
||||
converted = fileread.replace(pattern, substitute)
|
||||
#print ("DEBUG: %s "%converted)
|
||||
print("Confirmed %s instances of %s post-conversion"%(converted.count(substitute),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__":
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue