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 #249 from Eriten/JENKINS-32375
JENKINS-32375: GHPRB - Add DSL Support for Downstream Commit Status and Whitelist Target Branches
- Loading branch information
Showing
4 changed files
with
128 additions
and
4 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
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
55 changes: 55 additions & 0 deletions
55
src/main/java/org/jenkinsci/plugins/ghprb/jobdsl/GhprbUpstreamStatusContext.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,55 @@ | ||
package org.jenkinsci.plugins.ghprb.jobdsl; | ||
|
||
import javaposse.jobdsl.dsl.Context; | ||
import org.jenkinsci.plugins.ghprb.extensions.comments.GhprbBuildResultMessage; | ||
import org.kohsuke.github.GHCommitState; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
class GhprbUpstreamStatusContext implements Context { | ||
String context; | ||
String triggeredStatus; | ||
String startedStatus; | ||
String statusUrl; | ||
List<GhprbBuildResultMessage> completedStatus = new ArrayList<GhprbBuildResultMessage>(); | ||
|
||
/** | ||
* A string label to differentiate this status from the status of other systems. | ||
*/ | ||
void context(String context) { | ||
this.context = context; | ||
} | ||
|
||
/** | ||
* Use a custom status for when a build is triggered. | ||
*/ | ||
void triggeredStatus(String triggeredStatus) { | ||
this.triggeredStatus = triggeredStatus; | ||
} | ||
|
||
/** | ||
* Use a custom status for when a build is started. | ||
*/ | ||
void startedStatus(String startedStatus) { | ||
this.startedStatus = startedStatus; | ||
} | ||
|
||
/** | ||
* Use a custom URL instead of the job default. | ||
*/ | ||
void statusUrl(String statusUrl) { | ||
this.statusUrl = statusUrl; | ||
} | ||
|
||
/** | ||
* Use a custom status for when a build is completed. Can be called multiple times to set messages for different | ||
* build results. Valid build results are {@code 'SUCCESS'}, {@code 'FAILURE'}, and {@code 'ERROR'}. | ||
*/ | ||
void completedStatus(String buildResult, String message) { | ||
completedStatus.add(new GhprbBuildResultMessage( | ||
GHCommitState.valueOf(buildResult), | ||
message | ||
)); | ||
} | ||
} |