Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[JENKINS-31789] Added GitLab Plugin support
Added missing TestCases for GitLab Plugin: check values and use lowercase syntax Fixed values since rebuildOpenMergeRequest only accepts never, source, both Added a release notes for GitLab Plugin
- Loading branch information
Showing
5 changed files
with
244 additions
and
1 deletion.
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
26 changes: 26 additions & 0 deletions
26
...main/docs/examples/javaposse/jobdsl/dsl/helpers/triggers/TriggerContext/gitlabPush.groovy
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,26 @@ | ||
job('example') { | ||
scm { | ||
git { | ||
remote { | ||
name('origin') | ||
url('git@serverA:account/repo1.git') | ||
} | ||
} | ||
} | ||
triggers { | ||
gitlabPush { | ||
buildOnMergeRequestEvents(false) | ||
buildOnPushEvents(false) | ||
enableCiSkip(false) | ||
setBuildDescription(false) | ||
addNoteOnMergeRequest(false) | ||
rebuildOpenMergeRequest('never') | ||
addVoteOnMergeRequest(false) | ||
useCiFeatures(false) | ||
acceptMergeRequestOnSuccess() | ||
allowAllBranches(false) | ||
includeBranches('include1,include2') | ||
excludeBranches('exclude1,exclude2') | ||
} | ||
} | ||
} |
112 changes: 112 additions & 0 deletions
112
...sl-core/src/main/groovy/javaposse/jobdsl/dsl/helpers/triggers/GitlabTriggerContext.groovy
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,112 @@ | ||
package javaposse.jobdsl.dsl.helpers.triggers | ||
|
||
import javaposse.jobdsl.dsl.Context | ||
|
||
import static javaposse.jobdsl.dsl.Preconditions.checkArgument | ||
|
||
class GitlabTriggerContext implements Context { | ||
private static final Set<String> VALID_EXECUTION_STATUSES = ['never', 'source', 'both'] | ||
String includeBranches = '' | ||
String excludeBranches = '' | ||
String rebuildOpenMergeRequest = 'never' | ||
boolean buildOnMergeRequestEvents = true | ||
boolean buildOnPushEvents = true | ||
boolean enableCiSkip = true | ||
boolean setBuildDescription = true | ||
boolean addNoteOnMergeRequest = true | ||
boolean addVoteOnMergeRequest = true | ||
boolean useCiFeatures = false | ||
boolean acceptMergeRequestOnSuccess = false | ||
boolean allowAllBranches = false | ||
|
||
/** | ||
* Comma-separated list of source branches allowed to trigger a build from a Push event | ||
*/ | ||
void includeBranches(String includeBranches) { | ||
this.includeBranches = includeBranches | ||
} | ||
|
||
/** | ||
* Comma-separated list of source branches disabled to trigger a build from a Push event | ||
*/ | ||
void excludeBranches(String excludeBranches) { | ||
this.excludeBranches = excludeBranches | ||
} | ||
|
||
/** | ||
* If set, builds on merge request events. Defaults to {@code true}. | ||
*/ | ||
void buildOnMergeRequestEvents(boolean buildOnMergeRequestEvents = true) { | ||
this.buildOnMergeRequestEvents = buildOnMergeRequestEvents | ||
} | ||
|
||
/** | ||
* If set, builds on push events request events. Defaults to {@code true}. | ||
*/ | ||
void buildOnPushEvents(boolean buildOnPushEvents = true) { | ||
this.buildOnPushEvents = buildOnPushEvents | ||
} | ||
|
||
/** | ||
* If set, enables [ci-skip]. Defaults to {@code true}. | ||
*/ | ||
void enableCiSkip(boolean enableCiSkip = true) { | ||
this.enableCiSkip = enableCiSkip | ||
} | ||
|
||
/** | ||
* If set, sets build description to build cause (eg. Merge request or Git Push) . Defaults to {@code true}. | ||
*/ | ||
void setBuildDescription(boolean setBuildDescription = true) { | ||
this.setBuildDescription = setBuildDescription | ||
} | ||
|
||
/** | ||
* If set, adds note with build status on merge requests. Defaults to {@code true}. | ||
*/ | ||
void addNoteOnMergeRequest(boolean addNoteOnMergeRequest = true) { | ||
this.addNoteOnMergeRequest = addNoteOnMergeRequest | ||
} | ||
|
||
/** | ||
* If set, vote added to note with build status on merge requests. Defaults to {@code true}. | ||
*/ | ||
void addVoteOnMergeRequest(boolean addVoteOnMergeRequest = true) { | ||
this.addVoteOnMergeRequest = addVoteOnMergeRequest | ||
} | ||
|
||
/** | ||
* If set, enables GitLab 8.1 Continuous Integration feature. Defaults to {@code false}. | ||
*/ | ||
void useCiFeatures(boolean useCiFeatures = true) { | ||
this.useCiFeatures = useCiFeatures | ||
} | ||
|
||
/** | ||
* If set, accepts merge request on success. Defaults to {@code false}. | ||
*/ | ||
void acceptMergeRequestOnSuccess(boolean acceptMergeRequestOnSuccess = true) { | ||
this.acceptMergeRequestOnSuccess = acceptMergeRequestOnSuccess | ||
} | ||
|
||
/** | ||
* If set, allows all branches (Ignoring Filtered Branches). Defaults to {@code false}. | ||
*/ | ||
void allowAllBranches(boolean allowAllBranches = false) { | ||
this.allowAllBranches = allowAllBranches | ||
} | ||
|
||
/** | ||
* Only rebuild open Merge Requests. | ||
* | ||
* Possible values for are {@code 'never'}, {@code 'source'} and {@code 'both'}. | ||
*/ | ||
void rebuildOpenMergeRequest(String rebuildOpenMergeRequest) { | ||
checkArgument( | ||
VALID_EXECUTION_STATUSES.contains(rebuildOpenMergeRequest), | ||
"rebuildOpenMergeRequest must be one of ${VALID_EXECUTION_STATUSES.join(', ')}" | ||
) | ||
this.rebuildOpenMergeRequest = rebuildOpenMergeRequest | ||
|
||
} | ||
} |
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