Skip to content
Permalink
Browse files

[JENKINS-27206] - Move claim-plugin to use SimpleBuildStep

  • Loading branch information
abayer committed Jan 12, 2016
1 parent 109ee7f commit c863b59aa8fb1b8c2b679f18c14e75df4a6c1ba2
Showing with 17 additions and 7 deletions.
  1. +1 −1 pom.xml
  2. +16 −6 src/main/java/hudson/plugins/claim/ClaimPublisher.java
@@ -4,7 +4,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>1.577</version>
<version>1.580.1</version>
</parent>

<artifactId>claim</artifactId>
@@ -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;
}

}

0 comments on commit c863b59

Please sign in to comment.