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

Cannot configure Bitbucket ForkPullRequestDiscoveryTrait by using Job DSL dynamic API

    XMLWordPrintable

Details

    Description

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

      branchSources {
          branchSource {
              source {
                  bitbucket {
                      bitbucketServerUrl('https://stash.server.org')
                      credentialsId('bitbucket-credentials')
                      repoOwner('TEST')
                      repository('test-repo')
                          traits {
                              bitbucketBranchDiscovery { strategyId(1) }
                              bitbucketPullRequestDiscovery { strategyId(2) }
                          }
                      }
                  }
              }
          }
      }
      configure {
          def traits = it / sources / data / 'jenkins.branch.BranchSource' / source / traits
          traits << 'com.cloudbees.jenkins.plugins.bitbucket.ForkPullRequestDiscoveryTrait' {
              strategyId(2)
          }
      }
      

      List of available traits in Job DSL Dynamic API Viewer:

      • bitbucketBranchDiscovery
      • bitbucketPublicRepoPullRequestFilter
      • bitbucketPullRequestDiscovery
      • bitbucketSshCheckout
      • bitbucketTagDiscovery
      • bitbucketWebhookConfiguration
      • bitbucketWebhookRegistration

      Missing:

      • bitbucketForkDiscovery ← missing, but possible to execute
      • bitbucketTrustNobody
      • bitbucketTrustTeam
      • bitbucketTrustProject
      • bitbucketTrustEveryone

      I tried:
      1)

      bitbucketForkDiscovery {
          strategyId(2)
          trust('bitbucketTrustTeam')
      } 
      
      groovy.lang.MissingMethodException: No signature of method: javaposse.jobdsl.plugin.structs.DescribableContext.trust() is applicable for argument types: (java.lang.String) values: [bitbucketTrustTeam]
      Possible solutions: print(java.lang.Object), use([Ljava.lang.Object;), getAt(java.lang.String), print(java.io.PrintWriter), wait(), dump()
      

      2)

      bitbucketForkDiscovery {
          strategyId(2)
          trust(bitbucketTrustTeam)
      } 
      
      groovy.lang.MissingPropertyException: No such property: bitbucketTrustTeam for class: javaposse.jobdsl.plugin.structs.DescribableContext
      

      3)

      bitbucketForkDiscovery {
          strategyId(2)
          trust(bitbucketTrustTeam())
      } 
      
      groovy.lang.MissingMethodException: No signature of method: javaposse.jobdsl.plugin.structs.DescribableContext.bitbucketTrustTeam() is applicable for argument types: () values: []
      

      4)

      bitbucketForkDiscovery {
          strategyId(2)
          trust {
              bitbucketTrustTeam()
          }
      } 
      
      groovy.lang.MissingMethodException: No signature of method: javaposse.jobdsl.plugin.structs.DescribableContext.trust() is applicable for argument types: (script$_run_closure1$_closure3$_closure8$_closure9$_closure10$_closure11$_closure14$_closure16) values: [script$_run_closure1$_closure3$_closure8$_closure9$_closure10$_closure11$_closure14$_closure16@6abb68ce]
      Possible solutions: print(java.lang.Object), use([Ljava.lang.Object;), print(java.io.PrintWriter), wait(), dump(), grep()
      

      5)

      bitbucketForkDiscovery {
          strategyId(2)
      } 
      
      javaposse.jobdsl.dsl.DslScriptException: (script, line 30) the following options are required and must be specified: trust
      

      Attachments

        Issue Links

          Activity

            People

              jamietanna Jamie Tanna
              robin_smith Robin Smith
              Votes:
              7 Vote for this issue
              Watchers:
              10 Start watching this issue

              Dates

                Created:
                Updated: