Skip to content
Permalink
Browse files
Merge pull request #28 from Vinnie555/master
[FIXED JENKINS-27609] Add Support for Matrix build
[FIXED JENKINS-27610] Mark build as unstable on failure
  • Loading branch information
hugueschabot committed Mar 26, 2015
2 parents 6293430 + 6948dfd commit 1e481ce60c006cc18a6170d026cd64dd5d81ed57
@@ -57,6 +57,12 @@
<version>2.15</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>matrix-project</artifactId>
<version>1.3</version>
<optional>true</optional>
</dependency>
</dependencies>

</project>
@@ -8,6 +8,7 @@
import hudson.model.AbstractProject;
import hudson.model.BuildListener;
import hudson.model.PermalinkProjectAction.Permalink;
import hudson.model.Result;
import hudson.tasks.BuildStepDescriptor;
import hudson.tasks.Builder;
import hudson.util.ListBoxModel;
@@ -28,11 +29,13 @@ public class RebaseBuilder extends Builder {
* Indicates whether to stop the build if the merge fails.
*/
public final boolean stopBuildIfMergeFails;
public final boolean setUnstableIfMergeFails;

@DataBoundConstructor
public RebaseBuilder(String permalink, boolean stopBuildIfMergeFails) {
public RebaseBuilder(String permalink, boolean stopBuildIfMergeFails, boolean setUnstableIfMergeFails) {
this.permalink = permalink;
this.stopBuildIfMergeFails = stopBuildIfMergeFails;
this.setUnstableIfMergeFails = setUnstableIfMergeFails;
}

@Override
@@ -48,6 +51,9 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListen

RebaseAction rebaseAction = new RebaseAction(project);
long result = rebaseAction.perform(listener,new RebaseSetting(permalink));
if(result<0){
build.setResult(Result.UNSTABLE);
}
return !stopBuildIfMergeFails || result >= 0;
}

@@ -1,6 +1,6 @@
package jenkins.plugins.svnmerge;

import hudson.EnvVars;
import hudson.EnvVars;
import hudson.model.AbstractBuild;
import hudson.model.Computer;
import hudson.model.Job;
@@ -19,13 +19,19 @@ class Utility {
/**
* Get either the provided build of the root build of the provided
* build if it is a promotion one.
* also use the root build of a matrix build
*/
static AbstractBuild<?,?> rootBuildOf(AbstractBuild build) {
if (Jenkins.getInstance().getPlugin("promoted-builds") != null) {
if (build instanceof hudson.plugins.promoted_builds.Promotion) {
return build.getRootBuild();
}
}
if (Jenkins.getInstance().getPlugin("matrix-project") != null) {
if (build instanceof hudson.matrix.MatrixBuild) {
return build.getRootBuild();
}
}

return build;
}
@@ -8,3 +8,6 @@ f.entry(title:_("Build to rebase to"), field:"permalink") {
f.entry(title:_("Stop the build if the merge fails"), field:"stopBuildIfMergeFails") {
f.checkbox()
}
f.entry(title:_("Make the build UNSTABLE if the merge fails"), field:"setUnstableIfMergeFails") {
f.checkbox()
}

0 comments on commit 1e481ce

Please sign in to comment.