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

Gracefully handle missing Jenkins root URL

XMLWordPrintable

      When testing out the new multibranch pipeline support in version 1.1.0 of the plugin, I discovered that creation of a multibranch pipeline job via Job DSL fails when the Jenkins root URL is not set. It seems that the plugin tries to register the webhook but does not catch the exception thrown when the Jenkins root URL is unset. Full stack trace: stack-trace.txt

      Here is the Job DSL for the multibranch pipeline:

      multibranchPipelineJob('test') {
          branchSources {
              branchSource {
                  source {
                      BbS {
                          credentialsId('Build-User')
                          id('test')
                          mirrorName(null)
                          projectName('TEST')
                          repositoryName('test')
                          serverId('Bitbucket')
                          traits {
                              cleanBeforeCheckoutTrait {
                                  extension {
                                      deleteUntrackedNestedRepositories(true)
                                  }
                              }
                              gitBranchDiscovery()
                              localBranchTrait()
                              pruneStaleBranchTrait()
                          }
                      }
                  }
              }
          }
      }
      

      The equivalent multibranch pipeline definition for the CloudBees Bitbucket Branch Source plugin gracefully handles the exception and skips webhook registration when the Jenkins root URL is unset. Example:

      multibranchPipelineJob('test') {
          branchSources {
              branchSource {
                  source {
                      bitbucket {
                          credentialsId('Build-User')
                          id('test')
                          repoOwner('TEST')
                          repository('test')
                          serverUrl('https://redacted.com/scm')
                          traits {
                              bitbucketBranchDiscovery {
                                  strategyId(1)
                              }
                              bitbucketPullRequestDiscovery {
                                  strategyId(1)
                              }
                              cleanBeforeCheckoutTrait {
                                  extension {
                                      deleteUntrackedNestedRepositories(true)
                                  }
                              }
                              localBranchTrait()
                              pruneStaleBranchTrait()
                          }
                      }
                  }
              }
          }
      }
      

            Unassigned Unassigned
            bryanburke Bryan Burke
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: