-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from sophistifunk/feature/JENKINS-38339-link-d…
…ownstream-builds-to-trigger-node Mark downstream runs with pointer to upstream FlowNode
- Loading branch information
Showing
4 changed files
with
100 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
|
@@ -3,3 +3,5 @@ work | ||
.project | .project | ||
.classpath | .classpath | ||
.settings | .settings | ||
.idea/ | |||
*.iml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
...main/java/org/jenkinsci/plugins/workflow/support/steps/build/BuildUpstreamNodeAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,53 @@ | |||
package org.jenkinsci.plugins.workflow.support.steps.build; | |||
|
|||
import hudson.model.InvisibleAction; | |||
import hudson.model.Run; | |||
import org.jenkinsci.plugins.workflow.graph.FlowNode; | |||
|
|||
import java.util.Objects; | |||
|
|||
/** | |||
* Attached to newly-created builds in order to point back to the triggering FlowNode. | |||
* | |||
* We annotate the downstream build instead of upstream in order to support no-wait builds, | |||
* because the downstream run id is not available when they're still queued. | |||
* | |||
* Needed for Blue Ocean to annotate the correct step. | |||
* See <a href="https://issues.jenkins-ci.org/browse/JENKINS-38339">#JENKINS-38339</a> | |||
*/ | |||
public class BuildUpstreamNodeAction extends InvisibleAction { | |||
|
|||
private final String upstreamNodeId; | |||
private final String upstreamRunId; | |||
|
|||
public BuildUpstreamNodeAction(FlowNode node, Run<?, ?> invokingRun) { | |||
this.upstreamNodeId = node.getId(); | |||
this.upstreamRunId = invokingRun.getExternalizableId(); | |||
} | |||
|
|||
public String getUpstreamNodeId() { | |||
return upstreamNodeId; | |||
} | |||
|
|||
public String getUpstreamRunId() { | |||
return upstreamRunId; | |||
} | |||
|
|||
@Override | |||
public boolean equals(Object o) { | |||
if (this == o) { | |||
return true; | |||
} | |||
if (o == null || getClass() != o.getClass()) { | |||
return false; | |||
} | |||
BuildUpstreamNodeAction that = (BuildUpstreamNodeAction) o; | |||
return Objects.equals(upstreamNodeId, that.upstreamNodeId) && | |||
Objects.equals(upstreamRunId, that.upstreamRunId); | |||
} | |||
|
|||
@Override | |||
public int hashCode() { | |||
return Objects.hash(upstreamNodeId, upstreamRunId); | |||
} | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters