diff --git a/README.md b/README.md index 4bbb8f056..f7b9dfd9f 100644 --- a/README.md +++ b/README.md @@ -150,6 +150,9 @@ job('upstreamJob') { blackListLabels(['baz']) allowMembersOfWhitelistedOrgsAsAdmin() extensions { + commentFilePath { + commentFilePath("relative/path/to/file") + } commitStatus { context('deploy to staging site') triggeredStatus('starting deployment to staging site...') diff --git a/src/main/java/org/jenkinsci/plugins/ghprb/jobdsl/GhprbCommentFilePathContext.java b/src/main/java/org/jenkinsci/plugins/ghprb/jobdsl/GhprbCommentFilePathContext.java new file mode 100644 index 000000000..293f71dca --- /dev/null +++ b/src/main/java/org/jenkinsci/plugins/ghprb/jobdsl/GhprbCommentFilePathContext.java @@ -0,0 +1,18 @@ +package org.jenkinsci.plugins.ghprb.jobdsl; + +import javaposse.jobdsl.dsl.Context; + +class GhprbCommentFilePathContext implements Context { + private String commentFilePath; + + public String getCommentFilePath() { + return commentFilePath; + } + + /** + * sets the path to the comment file + */ + public void commentFilePath(String commentFilePath) { + this.commentFilePath = commentFilePath; + } +} diff --git a/src/main/java/org/jenkinsci/plugins/ghprb/jobdsl/GhprbExtensionContext.java b/src/main/java/org/jenkinsci/plugins/ghprb/jobdsl/GhprbExtensionContext.java index da2cea703..28f3d4b2d 100644 --- a/src/main/java/org/jenkinsci/plugins/ghprb/jobdsl/GhprbExtensionContext.java +++ b/src/main/java/org/jenkinsci/plugins/ghprb/jobdsl/GhprbExtensionContext.java @@ -5,6 +5,7 @@ import org.jenkinsci.plugins.ghprb.extensions.GhprbExtension; import org.jenkinsci.plugins.ghprb.extensions.build.GhprbCancelBuildsOnUpdate; import org.jenkinsci.plugins.ghprb.extensions.comments.GhprbBuildStatus; +import org.jenkinsci.plugins.ghprb.extensions.comments.GhprbCommentFile; import org.jenkinsci.plugins.ghprb.extensions.status.GhprbSimpleStatus; import java.util.ArrayList; @@ -41,6 +42,16 @@ void buildStatus(Runnable closure) { extensions.add(new GhprbBuildStatus(context.getCompletedStatus())); } + /** + * Adds comment file path handling + */ + void commentFilePath(Runnable closure) { + GhprbCommentFilePathContext context = new GhprbCommentFilePathContext(); + ContextExtensionPoint.executeInContext(closure, context); + + extensions.add(new GhprbCommentFile(context.getCommentFilePath())); + } + /** * Overrides global settings for cancelling builds when a PR was updated */