113 lines
No EOL
3.7 KiB
Groovy
113 lines
No EOL
3.7 KiB
Groovy
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 |