-
Bug
-
Resolution: Not A Defect
-
Major
Given two basic Jenkins Pipelines:
//Pipeline 'a'
stage 'stage' node{ build 'b' step([$class: 'CopyArtifact', projectName: 'b', selector: [$class: 'DownstreamBuildSelector', upstreamBuildNumber: env.BUILD_NUMBER, upstreamProjectName: env.JOB_NAME]]) }
//Pipeline 'b'
stage 'stage' node{ writeFile file: 'target/b.txt', text: 'b' archive includes:'target/b.txt' }
Copy artifact cannot find the right build from the Pipeline, consistently returning:
ERROR: Unable to find a build for artifact copy from: b
Finished: FAILURE
It doesn't work when removing the env.XYZ variables and passing in hard-coded values either.
- depends on
-
JENKINS-29913 Generalize DependencyGraph to Job (or ParameterizedJobMixIn)
-
- Open
-
- is related to
-
JENKINS-31576 Sandboxed access to upstream build information
-
- Resolved
-
-
JENKINS-33578 Snippetizer broken for DownstreamBuildSelector with Jenkins Pipeline
-
- Closed
-
-
JENKINS-36152 Reference the upstream job by using CauseAction
-
- Resolved
-
- links to
Probably not a defect at all. Builds run with the build step are not considered “downstream”, and probably would not be even with JENKINS-29913, since the dependency graph is static. So DownstreamBuildSelector makes no sense in this context, and this is already logged.
I think you just want to use SpecificBuildSelector. And you need to save the return value of the build step so you can access its .number.