Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-60874

Cannot configure ForkPullRequestDiscoveryTrait by using Job DSL dynamic API

    Details

    • Similar Issues:
    • Released As:
      github-branch-source-2.4.5

      Description

      GitHub Branch Source plugin has introduced unique symbols (not released yet), so finally we are able to configure traits by using Job DSL dynamic API instead of configure block. Unfortunately, ForkPullRequestDiscoveryTrait (gitHubForkDiscovery) is unavailable. For now the only possible option is to still use configure block:

      branchSources {
          branchSource {
              source {
                  github {
                      apiUri(config.scm.apiUrl)
                      id(config.name)
                      repoOwner(config.scm.organisation)
                      repository(config.scm.repository)
                      repositoryUrl(config.scm.url)
                      configuredByUrl(false)
                      credentialsId(config.scm.credentialsId)
                      traits {
                          gitHubBranchDiscovery {
                              strategyId(3)
                          }
                          gitHubPullRequestDiscovery {
                              strategyId(1)
                          }
                      }
                  }
              }
              buildStrategies {
                  skipInitialBuildOnFirstBranchIndexing()
              }
          }
      }
      configure {
          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$TrustPermission')
          }
      }
      

      List of available traits in Job DSL Dynamic API Vievwer:

      • gitHubAgedRefsTrait
      • gitHubBranchDiscovery
      • gitHubPullRequestDiscovery
      • gitHubSshCheckout
      • gitHubTagDiscovery

      Missing:

      • gitHubForkDiscovery ← missing, but possible to execute

      I tried:
      1)

      gitHubForkDiscovery {
          strategyId(1)
          trust('trustPermission')
      } 
      
      ERROR: (unknown source) No signature of method: javaposse.jobdsl.plugin.structs.DescribableContext.trust() is applicable for argument types: (java.lang.String) values: [trustPermission]
      Possible solutions: getAt(java.lang.String), print(java.io.PrintWriter), use([Ljava.lang.Object;), print(java.lang.Object), wait(), dump()
      

      2)

      gitHubForkDiscovery {
          strategyId(1)
          trust(gitHubTrustPermissions)
      } 
      
      ERROR: (MultibranchJobFactory.groovy, line 89) No such property: gitHubTrustPermissions for class: javaposse.jobdsl.plugin.structs.DescribableContext
      

      3)

      gitHubForkDiscovery {
          strategyId(1)
          trust(gitHubTrustPermissions())
      } 
      
      ERROR: (unknown source) No signature of method: javaposse.jobdsl.plugin.structs.DescribableContext.gitHubTrustPermissions() is applicable for argument types: () values: []
      

      4)

      gitHubForkDiscovery {
          strategyId(1)
          trust {
              gitHubTrustPermissions()
          }
      } 
      
      ERROR: (unknown source) No signature of method: javaposse.jobdsl.plugin.structs.DescribableContext.gitHubTrustPermissions() is applicable for argument types: () values: []
      

      5)

      gitHubForkDiscovery {
          strategyId(1)
          trust(Class.forName('org.jenkinsci.plugins.github_branch_source.ForkPullRequestDiscoveryTrait$TrustPermission', true, Jenkins.get().pluginManager.uberClassLoader).getDeclaredConstructor().newInstance())
      } 
      
      ERROR: (unknown source) No signature of method: javaposse.jobdsl.plugin.structs.DescribableContext.trust() is applicable for argument types: (org.jenkinsci.plugins.github_branch_source.ForkPullRequestDiscoveryTrait$TrustPermission) values: [org.jenkinsci.plugins.github_branch_source.ForkPullRequestDiscoveryTrait$TrustPermission@3a41ed6e]
      Possible solutions: print(java.io.PrintWriter), use([Ljava.lang.Object;), print(java.lang.Object), wait(), dump(), grep()
      

        Attachments

          Issue Links

            Activity

            Hide
            robin_smith Robin Smith added a comment -

            Similar issue reported for the Bitbucket Branch source plugin: JENKINS-61119

            Show
            robin_smith Robin Smith added a comment - Similar issue reported for the Bitbucket Branch source plugin: JENKINS-61119
            Hide
            agabrys Adam Gabryś added a comment -

            Hi Liam Newman. Why did you close the ticket? I know symbols were added, but I used the latest version (2.8.3 now) and it doesn't work. This is a bug ticket.

            Show
            agabrys Adam Gabryś added a comment - Hi Liam Newman . Why did you close the ticket? I know symbols were added, but I used the latest version (2.8.3 now) and it doesn't work. This is a bug ticket.
            Hide
            agabrys Adam Gabryś added a comment -

            I see no answer and the feature doesn't work, so I'll reopen the issue to not confuse other people.

            Show
            agabrys Adam Gabryś added a comment - I see no answer and the feature doesn't work, so I'll reopen the issue to not confuse other people.

              People

              • Assignee:
                daspilker Daniel Spilker
                Reporter:
                agabrys Adam Gabryś
              • Votes:
                2 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated: