One way you can do this is with Jenkins' built-in artifacts. I like to use JSON for this purpose since Pipeline has built-in readJSON
and writeJSON
methods.
For instance, here's what the configuration from the parent job might look like:
build job: "myproject", wait: true
step([
$class: 'CopyArtifact',
filter: 'mydata.json',
projectName: "myproject",
])
if (fileExists("mydata.json")) {
mydata = readJSON file: "mydata.json"
myvalue = mydata.mykey
}
And then your child job would need to write the mydata.json
file to the artifact store somewhere in its Pipeline job config, e.g.:
mydata = [mykey: 'myvalue']
writeJSON file: 'mydata.json', json: mydata
archiveArtifacts artifacts: 'mydata.json', onlyIfSuccessful: true