Skip to content

Commit

Permalink
Change how resolve works so the project that is built is retained.
Browse files Browse the repository at this point in the history
  • Loading branch information
David Tanner committed Oct 27, 2014
1 parent 1f6693f commit c73300f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public Promotion(PromotionProcess project, File buildDir) throws IOException {
@Exported
public AbstractBuild<?,?> getTarget() {
PromotionTargetAction pta = getAction(PromotionTargetAction.class);
return pta.resolve(this);
return pta.resolve();
}

@Override public AbstractBuild<?,?> getRootBuild() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ public Future<Promotion> scheduleBuild2(AbstractBuild<?,?> build, Cause cause) {

public boolean isInQueue(AbstractBuild<?,?> build) {
for (Item item : Hudson.getInstance().getQueue().getItems(this))
if (item.getAction(PromotionTargetAction.class).resolve(this)==build)
if (item.getAction(PromotionTargetAction.class).resolve()==build)
return true;
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import hudson.model.AbstractBuild;
import hudson.model.AbstractProject;
import hudson.model.Hudson;
import hudson.model.InvisibleAction;


/**
* Remembers what build it's promoting. Attached to {@link Promotion}.
*
Expand All @@ -13,25 +13,17 @@
public class PromotionTargetAction extends InvisibleAction {
private final String jobName;
private final int number;
private final AbstractProject<?, ?> project;

public PromotionTargetAction(AbstractBuild<?,?> build) {
jobName = build.getParent().getFullName();
number = build.getNumber();
project = build.getProject();
}

public AbstractBuild<?,?> resolve() {
AbstractProject<?,?> j = Hudson.getInstance().getItemByFullName(jobName, AbstractProject.class);
if (j==null) return null;
return j.getBuildByNumber(number);
return project.getBuildByNumber(number);
}

public AbstractBuild<?,?> resolve(PromotionProcess parent) {
AbstractProject<?,?> j = parent.getOwner();
if (j==null) return null;
return j.getBuildByNumber(number);
}

public AbstractBuild<?,?> resolve(Promotion parent) {
return resolve(parent.getParent());
}
}

0 comments on commit c73300f

Please sign in to comment.