Add option to 'Upstream build that triggered this job' to allow upstream dependencies #73
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The CopyArtifact plugin with 'Upstream build that triggered this job' works fine for us for a chain of jobs when the build started with the first job that triggers the next one, which triggers the next, and so on. The advantage of the Upstream-build strategy is that it works even with overlapping chains of builds. But there is a problem when we have overlapping chains and the build is started with an intermediate job.
Let's consider a simple scenario: each job triggers the next one
ModuleA --> ModuleB --> Publisher
where
ModuleB depends on artifacts of ModuleA (using the Upstream-build strategy),
Publisher copies artifacts from ModuleA and ModuleB (using the Upstream-build strategy),
ModuleB needs significantly more time to build than ModuleA, so ModuleA can build while a ModuleB build is running.
Example execution:
ModuleA#1 is triggered by SCM, builds successfully.
ModuleB#1 is triggered by ModuleA#1, copies its artifacts and builds successfully.
Publisher#1 is triggered by ModuleB#1, copies artifacts from ModuleA#1 and ModuleB#1.
ModuleB#2 is triggered by SCM, copies artifacts from ModuleA#1 (fallback to last successful), build started...
ModuleA#2 is triggered by SCM, builds successfully.
... ModuleB#2 finished.
Publisher#2 is triggered by ModuleB#2, copies artifacts from ModuleB#2 and ModuleA#2 (fallback) instead of ModuleA#1, which ModuleB#2 depends on.
ModuleB#3 and Publisher#3 works as expected.
This scenario happens more easily if the chain is longer and contains more than 3 jobs.
The problem here is the inconsistent builds (here the Publisher), or the violated isolation of build chains.
I hope what I've written so far is a reasonable issue.
What I found to this is that, the Upstream-build strategy in CopyArtifact plugin could include the upstream builds of the target build, not just the builds that triggered it. I have implemented this change introducing an additional checkbox for this, tried on a local Jenkins installation and seems working.