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

missing elements in job dsl 'organizationFolder'

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Minor Minor
    • job-dsl-plugin
    • None
    • Jenkins:2.138.2
      job-dsl:1.70
      cloudbees-bitbucket-branch-source:2.2.15
      basic-branch-build-strategies:1.1.1
    • job-dsl 1.75

      While configuring our bitbucket organization folder, I came across a couple of places where I needed to use the configure block because it did not work the way I expected:

      • 'organizationFolder' / 'triggers' / 'periodic' not working as expected, no matter what value I use, it always falls back to 1 minute
      • 'organizationFolder' / 'traits' does not support BranchDiscoveryTrait
      • 'organizationFolder' does not support 'buildStrategies'
      organizationFolder('org') {
          description('This contains branch source jobs for Bitbucket')
          displayName('org')
          // triggers {
          //     // not working, using configure block below
          //     periodic(28800000)
          // }
          organizations {
              bitbucket {
                repoOwner('myorg')
                credentialsId('BITBUCKET_CRED')
                traits {
                   // BranchDiscoveryTrait not available using configure block below
                }
              }
          }
          // buildStrategies not available using configure block below
      
          // discover Branches (workaround due to JENKINS-46202)
          configure { node ->
              // node represents <jenkins.branch.OrganizationFolder>     
      
              // Behaviours > 'Discover branches' > 'All branches'   
              def traits = node / 'navigators' / 'com.cloudbees.jenkins.plugins.bitbucket.BitbucketSCMNavigator' / 'traits'
              traits << 'com.cloudbees.jenkins.plugins.bitbucket.BranchDiscoveryTrait' {
                  strategyId(3) // detect all branches
              }
      
              // scan all repos at least once a day
              def triggers = node / 'triggers'
              triggers << 'com.cloudbees.hudson.plugins.folder.computed.PeriodicFolderTrigger' {
                  spec('H H * * *')
                  interval(86400000)
              }
      
              // make sure all branches get build
              def buildStrategies = node / 'buildStrategies' 
              buildStrategies << 'jenkins.branch.buildstrategies.basic.BranchBuildStrategyImpl' {}
          }    
      }
      

            daspilker Daniel Spilker
            imod Dominik Bartholdi
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: