Skip to content

Commit

Permalink
Merge pull request #28 from Vinnie555/master
Browse files Browse the repository at this point in the history
[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 1e481ce
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
6 changes: 6 additions & 0 deletions pom.xml
Expand Up @@ -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>
Expand Down
8 changes: 7 additions & 1 deletion src/main/java/jenkins/plugins/svnmerge/RebaseBuilder.java
Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -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;
}

Expand Down
8 changes: 7 additions & 1 deletion src/main/java/jenkins/plugins/svnmerge/Utility.java
@@ -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;
Expand All @@ -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;
}
Expand Down
Expand Up @@ -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.