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

Cannot configure ForkPullRequestDiscoveryTrait by using Job DSL dynamic API

    XMLWordPrintable

Details

    • 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

            cringdahl Cory Ringdahl added a comment -

            The workaround doesn't work if you're using sandboxes, because the configure block writes XML directly to the file. We're working on automating internal deployments and configuration of multiple Jenkins clusters to various internal dev teams, so security is paramount. With this bug left unfixed, we're asking for more one-off configurations that will be overwritten by config management, or "yet another snowflake script" configuration workarounds that will plague those who have to support this.

            cringdahl Cory Ringdahl added a comment - The workaround doesn't work if you're using sandboxes, because the configure block writes XML directly to the file. We're working on automating internal deployments and configuration of multiple Jenkins clusters to various internal dev teams, so security is paramount. With this bug left unfixed, we're asking for more one-off configurations that will be overwritten by config management, or "yet another snowflake script" configuration workarounds that will plague those who have to support this.
            agabrys Adam Gabryś added a comment -

            The workaround is in the description (the configure block). The Job DSL and GitHub Branch Source plugins' maintainers cannot do anything with it because the issue is caused by JENKINS-26535 (created 2015-01-21).

            agabrys Adam Gabryś added a comment - The workaround is in the description (the configure block). The Job DSL and GitHub Branch Source plugins' maintainers cannot do anything with it because the issue is caused by JENKINS-26535 (created 2015-01-21).
            donatello0o Donatien added a comment - - edited

            Please, the description of the issue is very clear, so what can be done now ?

            The issue is marked as resolved, but it still can be reproduced on current Jenkins LTS version + latest github-branch-source-plugin, and job-dsl-plugin.

            Any workaround, or syntax to suggest ?

            donatello0o Donatien added a comment - - edited Please, the description of the issue is very clear, so what can be done now ? The issue is marked as resolved, but it still can be reproduced on current Jenkins LTS version + latest github-branch-source-plugin , and job-dsl-plugin . Any workaround, or syntax to suggest ?
            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.

            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.
            agabrys Adam Gabryś added a comment -

            Hi bitwiseman. 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.

            agabrys Adam Gabryś added a comment - Hi bitwiseman . 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.
            robin_smith Robin Smith added a comment -

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

            robin_smith Robin Smith added a comment - Similar issue reported for the Bitbucket Branch source plugin: JENKINS-61119

            People

              jamietanna Jamie Tanna
              agabrys Adam Gabryś
              Votes:
              9 Vote for this issue
              Watchers:
              12 Start watching this issue

              Dates

                Created:
                Updated: