From ba2fa8cd05d006dac2314af53cf67eb64edffef5 Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Tue, 16 Nov 2021 23:09:30 +0000 Subject: [PATCH] Add a JSON object passing mechanism --- hardware/sominfo.groovy | 62 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) diff --git a/hardware/sominfo.groovy b/hardware/sominfo.groovy index 41f3656..fa745d1 100644 --- a/hardware/sominfo.groovy +++ b/hardware/sominfo.groovy @@ -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": "true", + "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": "true", + "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": "${artifactinfo['Job selector']}" + ] +} + +def releaserepo(artifactinfo) { + return [ + "repo": artifactinfo['Release repo'], + "revision": artifactinfo['Release repo revision'] + ] +} + return this \ No newline at end of file