jenkinsci / ghprb-plugin

github pull requests builder plugin for Jenkins
https://plugins.jenkins.io/ghprb/
MIT License
506 stars 612 forks source link

How to configure "Use comments to report results when updating commit status fails" using Groovy #736

Open mediumstack opened 5 years ago

mediumstack commented 5 years ago

How do I enable the feature "Use comments to report results when updating commit status fails" ("private Boolean useComments = true;" inside src/main/java/org/jenkinsci/plugins/ghprb/GhprbTrigger.java) using Groovy? The example below from the README is not adequate.

Thanks.

import jenkins.model.*
import org.jenkinsci.plugins.ghprb.*

GhprbTrigger.DescriptorImpl descriptor = Jenkins.instance.getDescriptorByType(org.jenkinsci.plugins.ghprb.GhprbTrigger.DescriptorImpl.class)

List<GhprbGitHubAuth> githubAuths = descriptor.getGithubAuth()

String serverAPIUrl = 'https://api.github.com'
String jenkinsUrl = 'https://your.jenkins.url/'
String credentialsId = 'credentials-id'
String description = 'Anonymous connection'
String id = 'github-auth-id'
String secret = null
githubAuths.add(new GhprbGitHubAuth(serverAPIUrl, jenkinsUrl, credentialsId, description, id, secret))

descriptor.save()