Skip to content

Commit 556164a

Browse files
committed
Expose cancelBuildsOnUpdate to dsl
Closes #628
1 parent c86e68c commit 556164a

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package org.jenkinsci.plugins.ghprb.jobdsl;
2+
3+
import javaposse.jobdsl.dsl.Context;
4+
5+
class GhprbCancelBuildsOnUpdateContext implements Context {
6+
private Boolean overrideGlobal;
7+
8+
public Boolean getOverrideGlobal() {
9+
return overrideGlobal;
10+
}
11+
12+
/**
13+
* sets the overrideGlobal value
14+
*/
15+
public void overrideGlobal(Boolean overrideGlobal) {
16+
this.overrideGlobal = overrideGlobal;
17+
}
18+
}

src/main/java/org/jenkinsci/plugins/ghprb/jobdsl/GhprbExtensionContext.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import javaposse.jobdsl.dsl.Context;
44
import javaposse.jobdsl.plugin.ContextExtensionPoint;
55
import org.jenkinsci.plugins.ghprb.extensions.GhprbExtension;
6+
import org.jenkinsci.plugins.ghprb.extensions.build.GhprbCancelBuildsOnUpdate;
67
import org.jenkinsci.plugins.ghprb.extensions.comments.GhprbBuildStatus;
78
import org.jenkinsci.plugins.ghprb.extensions.status.GhprbSimpleStatus;
89

@@ -40,6 +41,16 @@ void buildStatus(Runnable closure) {
4041
extensions.add(new GhprbBuildStatus(context.getCompletedStatus()));
4142
}
4243

44+
/**
45+
* Overrides global settings for cancelling builds when a PR was updated
46+
*/
47+
void cancelBuildsOnUpdate(Runnable closure) {
48+
GhprbCancelBuildsOnUpdateContext context = new GhprbCancelBuildsOnUpdateContext();
49+
ContextExtensionPoint.executeInContext(closure, context);
50+
51+
extensions.add(new GhprbCancelBuildsOnUpdate(context.getOverrideGlobal()));
52+
}
53+
4354
public List<GhprbExtension> getExtensions() {
4455
return extensions;
4556
}

0 commit comments

Comments
 (0)