Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #246 from daspilker/JENKINS-31214
[JENKINS-31214] added Job DSL for GhprbPullRequestMerge and docs
- Loading branch information
Showing
3 changed files
with
148 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
src/main/java/org/jenkinsci/plugins/ghprb/jobdsl/GhprbPullRequestMergeContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package org.jenkinsci.plugins.ghprb.jobdsl; | ||
|
||
import javaposse.jobdsl.dsl.Context; | ||
|
||
public class GhprbPullRequestMergeContext implements Context { | ||
String mergeComment; | ||
boolean onlyAdminsMerge; | ||
boolean disallowOwnCode; | ||
boolean failOnNonMerge; | ||
boolean deleteOnMerge; | ||
|
||
/** | ||
* Sets a comment that should show up when the merge command is sent to GitHub. | ||
*/ | ||
public void mergeComment(String mergeComment) { | ||
this.mergeComment = mergeComment; | ||
} | ||
|
||
/** | ||
* Allows only admin users to trigger a pull request merge. Defaults to {@code false}. | ||
*/ | ||
public void onlyAdminsMerge(boolean onlyAdminsMerge) { | ||
this.onlyAdminsMerge = onlyAdminsMerge; | ||
} | ||
|
||
/** | ||
* Allows only admin users to trigger a pull request merge. Defaults to {@code false}. | ||
*/ | ||
public void onlyAdminsMerge() { | ||
onlyAdminsMerge(true); | ||
} | ||
|
||
/** | ||
* Disallows a user to merge their own code. Defaults to {@code false}. | ||
*/ | ||
public void disallowOwnCode(boolean disallowOwnCode) { | ||
this.disallowOwnCode = disallowOwnCode; | ||
} | ||
|
||
/** | ||
* Disallows a user to merge their own code. Defaults to {@code false}. | ||
*/ | ||
public void disallowOwnCode() { | ||
disallowOwnCode(true); | ||
} | ||
|
||
/** | ||
* Fails the build if the pull request can't be merged. Defaults to {@code false}. | ||
*/ | ||
public void failOnNonMerge(boolean failOnNonMerge) { | ||
this.failOnNonMerge = failOnNonMerge; | ||
} | ||
|
||
/** | ||
* Fails the build if the pull request can't be merged. Defaults to {@code false}. | ||
*/ | ||
public void failOnNonMerge() { | ||
failOnNonMerge(true); | ||
} | ||
|
||
/** | ||
* Deletes the branch after a successful merge. Defaults to {@code false}. | ||
*/ | ||
public void deleteOnMerge(boolean deleteOnMerge) { | ||
this.deleteOnMerge = deleteOnMerge; | ||
} | ||
|
||
/** | ||
* Deletes the branch after a successful merge. Defaults to {@code false}. | ||
*/ | ||
public void deleteOnMerge() { | ||
deleteOnMerge(true); | ||
} | ||
} |