Skip to content

Commit

Permalink
Retry getLastAction until build is complete
Browse files Browse the repository at this point in the history
A builds change actions will not be available until
after SCM checkout. In cases of executor starvation
this can result in infinite queuing. This
works around JENKINS-40722 to provide concurrent
builds with P4 polling/Perforce Triggered Builds
  • Loading branch information
Robby Pocase committed Nov 17, 2017
1 parent 52bc05a commit c0812f0
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/main/java/org/jenkinsci/plugins/p4/tagging/TagAction.java
Expand Up @@ -257,7 +257,14 @@ public Label getLabel(String tag) {
public static List<P4Ref> getLastChange(Run<?, ?> run, TaskListener listener, String syncID) {
List<P4Ref> changes = new ArrayList<>();

List<TagAction> actions = lastActions(run);
List<TagAction> actions;
// Check for actions until the build is complete
// Workaround for JENKINS-40722
do {
actions = lastActions(run);
} while(actions == null && run.isBuilding());


if (actions == null || syncID == null || syncID.isEmpty()) {
listener.getLogger().println("No previous build found...");
return changes;
Expand Down Expand Up @@ -305,6 +312,7 @@ private static List<TagAction> lastActions(Run<?, ?> run) {

// get last action, if no previous action then build now.
List<TagAction> actions = run.getActions(TagAction.class);

if (actions.isEmpty()) {
return null;
}
Expand Down

0 comments on commit c0812f0

Please sign in to comment.