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

Jobdsl is creating two organization when ForkPullRequestDiscoveryTrait is invoked

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • job-dsl-plugin
    • Jenkins version: 2.277.4 jdk 11
      JCasC plugin version: 1.50
      JobDsl plugin version: 1.77
      GitHub Branch Source: 2.10.2

      I am trying to use jcasc plugin to configure Github Organization folder. Everything works well excepting ForkPullRequestDiscoveryTrait.

      I try like this: 

      organizationFolder('MyOrgFolder') {
          description("My github organization folder")
          displayName('My Projects')
          organizations {
              github {           
                  repoOwner("github_owner")
                  apiUri("https://api.github.com")
                  credentialsId("GITHUB_USERNAME")
                  traits {
                      submoduleOptionTrait {
                          extension {
                              disableSubmodules(false)
                              recursiveSubmodules(true)
                              trackingSubmodules(true)
                              reference(null)
                              threads(3)
                              timeout(15)
                              parentCredentials(true)
                          }
                      }
                      gitHubBranchDiscovery {
                          strategyId(1)
                      }
                      gitHubPullRequestDiscovery {
                          strategyId(1)
                      }
                      sourceRegexFilter {
                          // A Java regular expression to restrict the project names.
                          regex("test*")
                      }
                      wipeWorkspaceTrait()
                  }
              }
          }
          // "Project Recognizers"
          projectFactories {
              workflowMultiBranchProjectFactory {
                  scriptPath 'Jenkinsfile'
              }
          }
          // "Orphaned Item Strategy"
          orphanedItemStrategy {
              discardOldItems {
                  daysToKeep(30)
                  numToKeep(-1)
              }
          }
          configure { node ->
              node / triggers / 'com.cloudbees.hudson.plugins.folder.computed.PeriodicFolderTrigger' {
                  spec('H H * * *')
                  interval(86400000)
              }
      
              def traits = node / navigators / 'org.jenkinsci.plugins.github__branch__source.GitHubSCMNavigator' / traits
              traits << 'org.jenkinsci.plugins.github__branch__source.ForkPullRequestDiscoveryTrait' {
                strategyId(3)
                trust(class: 'org.jenkinsci.plugins.github__branch__source.ForkPullRequestDiscoveryTrait$TrustPermission')
              }
          }
      }
      

      The problem is that when the job is running are created two github organizations as follow: The first one is created according with the job dsl description excepting the ForkPullRequestDiscoveryTrait. This trait is not added.

      The second github organization is added and all fields are empty and the behaviour for is added and set as in the job dsl.

      Please check the foto.

            jamietanna Jamie Tanna
            qalinn Alin Pana
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: