|
|
@@ -1,21 +1,25 @@ |
|
|
package hudson.plugins.claim; |
|
|
|
|
|
import hudson.Extension; |
|
|
import hudson.FilePath; |
|
|
import hudson.Launcher; |
|
|
import hudson.model.AbstractBuild; |
|
|
import hudson.model.AbstractProject; |
|
|
import hudson.model.BuildListener; |
|
|
import hudson.model.Result; |
|
|
import hudson.model.Run; |
|
|
import hudson.model.TaskListener; |
|
|
import hudson.tasks.BuildStepDescriptor; |
|
|
import hudson.tasks.BuildStepMonitor; |
|
|
import hudson.tasks.Notifier; |
|
|
import hudson.tasks.Publisher; |
|
|
|
|
|
import java.io.IOException; |
|
|
|
|
|
import jenkins.tasks.SimpleBuildStep; |
|
|
import org.kohsuke.stapler.DataBoundConstructor; |
|
|
|
|
|
public class ClaimPublisher extends Notifier { |
|
|
public class ClaimPublisher extends Notifier implements SimpleBuildStep { |
|
|
|
|
|
@DataBoundConstructor |
|
|
public ClaimPublisher() { |
|
@@ -33,7 +37,7 @@ public String getDisplayName() { |
|
|
return Messages.ClaimPublisher_DisplayName(); |
|
|
} |
|
|
|
|
|
public boolean isApplicable(Class<? extends AbstractProject> jobType) { |
|
|
public boolean isApplicable(Class jobType) { |
|
|
return true; |
|
|
} |
|
|
|
|
@@ -46,15 +50,22 @@ public DescriptorImpl getDescriptor() { |
|
|
|
|
|
@Override |
|
|
public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, |
|
|
BuildListener listener) throws InterruptedException, IOException { |
|
|
BuildListener listener) throws InterruptedException, IOException { |
|
|
perform(build, build.getWorkspace(), launcher, listener); |
|
|
return true; |
|
|
} |
|
|
|
|
|
@Override |
|
|
public void perform(Run<?, ?> build, FilePath workspace, Launcher launcher, |
|
|
TaskListener listener) throws InterruptedException, IOException { |
|
|
|
|
|
if (build.getResult().isWorseThan(Result.SUCCESS)) { |
|
|
ClaimBuildAction action = new ClaimBuildAction(build); |
|
|
build.addAction(action); |
|
|
build.save(); |
|
|
|
|
|
// check if previous build was claimed |
|
|
AbstractBuild<?,?> previousBuild = build.getPreviousBuild(); |
|
|
Run<?,?> previousBuild = build.getPreviousBuild(); |
|
|
if (previousBuild != null) { |
|
|
ClaimBuildAction c = previousBuild.getAction(ClaimBuildAction.class); |
|
|
if (c != null && c.isClaimed() && c.isSticky()) { |
|
@@ -63,11 +74,10 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, |
|
|
} |
|
|
} |
|
|
|
|
|
return true; |
|
|
} |
|
|
|
|
|
public BuildStepMonitor getRequiredMonitorService() { |
|
|
return BuildStepMonitor.STEP; |
|
|
return BuildStepMonitor.NONE; |
|
|
} |
|
|
|
|
|
} |