I had a similar problem. I had to do this, having tasks J1, J2 create property files, and then acquire these files using the "Copy artifact" in the main P1 pipeline. Then convert the properties to Java properties (which may require the approval of the script in Jenkins). It would be nice if Jenkins Pipeline could return the parameters directly in the code (maybe this needs to be done, but I don't know that). The return from the build phase is RunWrapper , it seems that it has no way to return the result that I can see (if only we used some existing property, for example, the assembly description).
So I had something like this:
// Pipeline code in P1 // Build J1 and get result. def j1BuildResult = build job: 'J1', parameters: [string(name: 'J1_PROP', value: 'FOO')], propagate: true, wait: true // Get results of J1 step([$class : 'CopyArtifact', filter: 'j1-result.properties', fingerprintArtifacts: true, flatten : true, projectName : 'J1', selector : [$class : 'SpecificBuildSelector', buildNumber: buildResult.getNumber().toString()]]) // Load J1 properties (you may need to turn off sandbox or approve this in Jenkins) Properties j1Props = new Properties() j1Props.load(new StringReader(readFile('j1-result.properties'))) // Build J2 def j2BuildResult = build job: 'J2', parameters: [string(name: 'J2_PROP', value: j1Props.someProperty)], propagate: true, wait: true // Get results of J2 step([$class : 'CopyArtifact', filter: 'j2-result.properties', fingerprintArtifacts: true, flatten : true, projectName : 'J2', selector : [$class : 'SpecificBuildSelector', buildNumber: buildResult.getNumber().toString()]]) // Load J2 properties (you may need to turn off sandbox or approve this in Jenkins) Properties j2Props = new Properties() j1Props.load(new StringReader(readFile('j2-result.properties')))
macg33zr
source share