Home > Enterprise >  How to set ForkPullRequestDiscoveryTrait trustId to Collaborators - Jenkins
How to set ForkPullRequestDiscoveryTrait trustId to Collaborators - Jenkins

Time:10-13

newbie here.

In Jenkins, I need to set "Discover pull requests from forks" setting as a code with Trust set to Collaborators. What trustId I should use?

configure {
                                    def traits = it / sources / data / 'jenkins.branch.BranchSource' / source / traits
                                    traits << 'org.jenkinsci.plugins.github__branch__source.ForkPullRequestDiscoveryTrait' {
                                        strategyId(1)
                                    }

All I managed to find is this. But I can't see collaborators setting anywhere.

 trustID('1')
              // Values
              // 0 : Everyone
              // 1 : Forks in the same account
              // 2 : Nobody

Wanted option can be found and set using GUI.

Edit: I've found something like this. Running build like this throws: groovy.lang.MissingPropertyException: No such property: TrustContributors for class: groovy.lang.Binding

def traits = it / sources / data / 'jenkins.branch.BranchSource' / source / traits
                                    traits << 'org.jenkinsci.plugins.github__branch__source.ForkPullRequestDiscoveryTrait' {
                                        strategyId(1)
                                        trust(class: 'org.jenkinsci.plugins.github_branch_source.ForkPullRequestDiscoveryTrait$TrustContributors')
                                    }          ```

CodePudding user response:

I finally got it to work. Here's what it looks like.

configure {
                                    def traits = it / sources / data / 'jenkins.branch.BranchSource' / source / traits
                                    traits << 'org.jenkinsci.plugins.github__branch__source.ForkPullRequestDiscoveryTrait' {
                                        strategyId (1)
                                        extension(class: 'org.jenkinsci.plugins.github_branch_source.ForkPullRequestDiscoveryTrait') {
                                            trust(TrustContributors)
                                        }
                                    }                       
                                }
  • Related