mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-16 05:22:22 +00:00
DRY Failure/UnstableBuilder.
This commit is contained in:
1 parent
9ae0ba0681
commit
7fead6ff7f
2 files changed
+6
-22
No files matched your search
@@ -23,29 +23,21 @@
|
||||
*/
|
||||
package org.jvnet.hudson.test;
|
||||
|
||||
import hudson.Launcher;
|
||||
import hudson.Extension;
|
||||
import hudson.model.AbstractBuild;
|
||||
import hudson.model.BuildListener;
|
||||
import hudson.model.Descriptor;
|
||||
import hudson.model.Result;
|
||||
import hudson.tasks.Builder;
|
||||
import net.sf.json.JSONObject;
|
||||
import org.kohsuke.stapler.StaplerRequest;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Mock {@link Builder} that always cause a build to fail.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
public class FailureBuilder extends Builder {
|
||||
|
||||
public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
|
||||
listener.getLogger().println("Simulating a failure");
|
||||
build.setResult(Result.FAILURE);
|
||||
return false;
|
||||
public class FailureBuilder extends MockBuilder {
|
||||
public FailureBuilder() {
|
||||
super(Result.FAILURE);
|
||||
}
|
||||
|
||||
@Extension
|
||||
|
||||
@@ -23,29 +23,21 @@
|
||||
*/
|
||||
package org.jvnet.hudson.test;
|
||||
|
||||
import hudson.Launcher;
|
||||
import hudson.Extension;
|
||||
import hudson.model.AbstractBuild;
|
||||
import hudson.model.BuildListener;
|
||||
import hudson.model.Descriptor;
|
||||
import hudson.model.Result;
|
||||
import hudson.tasks.Builder;
|
||||
import net.sf.json.JSONObject;
|
||||
import org.kohsuke.stapler.StaplerRequest;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Mock {@link Builder} that always cause a build to fail.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
public class UnstableBuilder extends Builder {
|
||||
|
||||
public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
|
||||
listener.getLogger().println("Simulating an unstable build");
|
||||
build.setResult(Result.UNSTABLE);
|
||||
return true;
|
||||
public class UnstableBuilder extends MockBuilder {
|
||||
public UnstableBuilder() {
|
||||
super(Result.UNSTABLE);
|
||||
}
|
||||
|
||||
@Extension
|
||||
|
||||
Reference in new issue
Block a user