Skip to content

Commit b44b1b5

Browse files
authored
Create re-run-triggers.groovy
1 parent 2de15b0 commit b44b1b5

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

docs/re-run-triggers.groovy

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import static org.jenkinsci.plugins.github.pullrequest.utils.JobHelper.ghPRTriggerFromJob
2+
import static com.github.kostyasha.github.integration.branch.utils.JobHelper.ghBranchTriggerFromJob
3+
4+
import com.github.kostyasha.github.integration.branch.GitHubBranchTrigger
5+
import org.jenkinsci.plugins.github.pullrequest.GitHubPRTrigger
6+
7+
Jenkins.instance.getAllItems(Job.class).each{ job ->
8+
GitHubPRTrigger prTrigger = ghPRTriggerFromJob(job)
9+
if (prTrigger != null) {
10+
println "Running GH PR trigger for " + job.getFullName()
11+
try {
12+
prTrigger.run()
13+
} catch (Throwable error) {
14+
println "ERROR: failed to run branch trigger for " + job.getFullName()
15+
print error
16+
}
17+
}
18+
19+
GitHubBranchTrigger branchTrigger = ghBranchTriggerFromJob(job)
20+
if (branchTrigger != null) {
21+
println "Running GH Branch trigger for " + job.getFullName()
22+
try {
23+
branchTrigger.run()
24+
} catch (Throwable error) {
25+
println "ERROR: failed to run branch trigger for " + job.getFullName()
26+
print error
27+
28+
}
29+
}
30+
}
31+
println ""

0 commit comments

Comments
 (0)