Add a JSON object passing mechanism

This commit is contained in:
Dan Hawkins 2021-11-16 23:09:30 +00:00
commit ba2fa8cd05

View file

@ -1,10 +1,35 @@
def sominfostore = null
/* Example expected JSON
{
"SomType": {
"Som_BA4": {
"Artifact info": {
"Location": "Jenkins job artifact",
"Job": "HMB_FD_HV_0.9.6/0.9.6_SG1024_EL_syn_ba4",
"Job selector": "<stable>true</stable>",
"Release repo": "git@hydra:hmb_fd_hv-releases/sg1024/hmb_fd_hv_logic_ba4.git",
"Release repo revision": ""
}
},
"Som_FC5": {
"Artifact info": {
"Location": "Jenkins job artifact",
"Job": "HMB_FD_HV_0.9.6/0.9.6_SG1024_EL_syn_fc5",
"Job selector": "<stable>true</stable>",
"Release repo": "git@hydra:hmb_fd_hv-releases/sg1024/hmb_fd_hv_logic_fc5.git",
"Release repo revision": ""
}
}
}
}
*/
def String asJsonText() {
return writeJSON(returnText: true, json: sominfostore, pretty: 1)
}
def boolean isSet() {
def boolean exists() {
return (sominfostore != null)
}
@ -19,4 +44,39 @@ def get() {
return sominfostore
}
def somtypes() {
return sominfostore['SomType']
}
def artifactinfo(somtype) {
return somtype['Artifact info']
}
def artifactlocation(artifactinfo) {
return artifactinfo['Location']
}
def boolean isjoblocation(artifactinfo) {
return (artifactinfo['Location'] == 'Jenkins job artifact' ||
artifactinfo['Location'] == 'Jenkins job artefact')
}
def boolean isreleaserepolocation(artifactinfo) {
return artifactinfo['Location'] == 'Release repository'
}
def artifactjob(artifactinfo) {
return [
"name": artifactinfo['Job'],
"selector": "<StatusBuildSelector plugin=\"copyartifact@1.46.2\">${artifactinfo['Job selector']}</StatusBuildSelector>"
]
}
def releaserepo(artifactinfo) {
return [
"repo": artifactinfo['Release repo'],
"revision": artifactinfo['Release repo revision']
]
}
return this