Skip to content

Commit 576fa78

Browse files
committed
move commentFilePath to an extension point
1 parent be8ba4b commit 576fa78

File tree

5 files changed

+30
-23
lines changed

5 files changed

+30
-23
lines changed

src/main/java/org/jenkinsci/plugins/ghprb/GhprbTrigger.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
import org.jenkinsci.plugins.ghprb.extensions.comments.GhprbBuildLog;
3636
import org.jenkinsci.plugins.ghprb.extensions.comments.GhprbBuildResultMessage;
3737
import org.jenkinsci.plugins.ghprb.extensions.comments.GhprbBuildStatus;
38-
import org.jenkinsci.plugins.ghprb.extensions.comments.GhprbCommentFile;
3938
import org.jenkinsci.plugins.ghprb.extensions.comments.GhprbPublishJenkinsUrl;
4039
import org.jenkinsci.plugins.ghprb.extensions.status.GhprbSimpleStatus;
4140
import org.kohsuke.github.GHCommitState;
@@ -212,11 +211,6 @@ public GhprbTrigger(String adminlist,
212211
this.permitAll = permitAll;
213212
this.autoCloseFailedPullRequests = autoCloseFailedPullRequests;
214213
this.displayBuildErrorsOnDownstreamBuilds = displayBuildErrorsOnDownstreamBuilds;
215-
216-
if (commentFilePath != null) {
217-
extensions.add(new GhprbCommentFile(commentFilePath));
218-
}
219-
220214
this.skipBuildPhrase = skipBuildPhrase;
221215
this.blackListCommitAuthor = blackListCommitAuthor;
222216
this.whiteListTargetBranches = whiteListTargetBranches;
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 GhprbCommentFilePathContext implements Context {
6+
private String commentFilePath;
7+
8+
public String getCommentFilePath() {
9+
return commentFilePath;
10+
}
11+
12+
/**
13+
* sets the path to the comment file
14+
*/
15+
public void commentFilePath(String commentFilePath) {
16+
this.commentFilePath = commentFilePath;
17+
}
18+
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public Object githubPullRequest(Runnable closure) throws ANTLRException {
3030
context.permitAll,
3131
context.autoCloseFailedPullRequests,
3232
context.displayBuildErrorsOnDownstreamBuilds,
33-
context.commentFilePath,
33+
null,
3434
context.skipBuildPhrase,
3535
context.blackListCommitAuthor,
3636
context.whiteListTargetBranches,

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

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

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

44+
/**
45+
* Adds comment file path handling
46+
*/
47+
void commentFilePath(Runnable closure) {
48+
GhprbCommentFilePathContext context = new GhprbCommentFilePathContext();
49+
ContextExtensionPoint.executeInContext(closure, context);
50+
51+
extensions.add(new GhprbCommentFile(context.getCommentFilePath()));
52+
}
53+
4354
public List<GhprbExtension> getExtensions() {
4455
return extensions;
4556
}

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

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ class GhprbTriggerContext implements Context {
4242

4343
boolean displayBuildErrorsOnDownstreamBuilds;
4444

45-
String commentFilePath;
46-
4745
String buildDescriptionTemplate;
4846

4947
String includedRegions;
@@ -279,20 +277,6 @@ public void displayBuildErrorsOnDownstreamBuilds() {
279277
displayBuildErrorsOnDownstreamBuilds(true);
280278
}
281279

282-
/**
283-
* Pubilsh this comment file to the github PR
284-
*/
285-
public void commentFilePath(String commentFilePath) {
286-
this.commentFilePath = commentFilePath;
287-
}
288-
289-
/**
290-
* Pubilsh this comment file to the github PR
291-
*/
292-
public void commentFilePath() {
293-
commentFilePath("");
294-
}
295-
296280
/**
297281
* When filled, changes the default build description template
298282
*/

0 commit comments

Comments
 (0)