Skip to content

Commit 3b74998

Browse files
author
Victor Cabello
committed
Add support for commentFile on PullRequestBuilder
1 parent 2257bcb commit 3b74998

File tree

4 files changed

+11
-0
lines changed

4 files changed

+11
-0
lines changed

docs/Job-reference.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1379,6 +1379,7 @@ pullRequest {
13791379
useGitHubHooks(boolean useGithubHooks = true) // defaults to false if not specified
13801380
permitAll(boolean permitAll = true) // defaults to false if not specified
13811381
autoCloseFailedPullRequests(boolean autoCloseFailedPullRequests = true) // defaults to false if not specified
1382+
commentFilePath(String commentFilePath) // post the content of the commentFile on the pull request as comment
13821383
}
13831384
```
13841385

job-dsl-core/src/main/groovy/javaposse/jobdsl/dsl/helpers/triggers/PullRequestBuilderContext.groovy

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class PullRequestBuilderContext implements Context {
1212
boolean useGitHubHooks = false
1313
boolean permitAll = false
1414
boolean autoCloseFailedPullRequests = false
15+
String commentFilePath = ''
1516

1617
void admin(String admin) {
1718
admins << admin
@@ -47,6 +48,10 @@ class PullRequestBuilderContext implements Context {
4748
this.cron = cron
4849
}
4950

51+
void commentFilePath(String commentFilePath) {
52+
this.commentFilePath = commentFilePath
53+
}
54+
5055
void triggerPhrase(String triggerPhrase) {
5156
this.triggerPhrase = triggerPhrase
5257
}

job-dsl-core/src/main/groovy/javaposse/jobdsl/dsl/helpers/triggers/TriggerContext.groovy

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ class TriggerContext implements Context {
135135
* <useGitHubHooks>true</useGitHubHooks>
136136
* <permitAll>true</permitAll>
137137
* <autoCloseFailedPullRequests>false</autoCloseFailedPullRequests>
138+
* <commentFilePath>$WORKSPACE/myCommentFile.log</commentFilePath>
138139
* </org.jenkinsci.plugins.ghprb.GhprbTrigger>
139140
*/
140141
void pullRequest(@DslContext(PullRequestBuilderContext) Closure contextClosure) {
@@ -152,6 +153,7 @@ class TriggerContext implements Context {
152153
useGitHubHooks pullRequestBuilderContext.useGitHubHooks
153154
permitAll pullRequestBuilderContext.permitAll
154155
autoCloseFailedPullRequests pullRequestBuilderContext.autoCloseFailedPullRequests
156+
commentFilePath pullRequestBuilderContext.commentFilePath
155157
}
156158
}
157159

job-dsl-core/src/test/groovy/javaposse/jobdsl/dsl/helpers/triggers/TriggerContextSpec.groovy

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@ class TriggerContextSpec extends Specification {
315315
adminlist[0].value() == ''
316316
whitelist[0].value() == ''
317317
orgslist[0].value() == ''
318+
commentFilePath[0].value() == ''
318319
}
319320

320321
}
@@ -348,6 +349,7 @@ class TriggerContextSpec extends Specification {
348349
useGitHubHooks(true)
349350
permitAll(true)
350351
autoCloseFailedPullRequests(true)
352+
commentFilePath('myCommentFile')
351353
}
352354

353355
then:
@@ -364,6 +366,7 @@ class TriggerContextSpec extends Specification {
364366
useGitHubHooks[0].value() == true
365367
permitAll[0].value() == true
366368
autoCloseFailedPullRequests[0].value() == true
369+
commentFilePath[0].value() == 'myCommentFile'
367370
}
368371
}
369372

0 commit comments

Comments
 (0)