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

bitbucket source plugin fails with bad URL

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      The new status notifier code cause the BBSP plugin to fail with an unclear error message when the RootURL has not been specifically configured.

      This job worked with the 1.5 plugin from before the status notifier code was added, and fails in 1.8.

      First time build. Skipping changelog.
      [Bitbucket] Notifying commit build result
      [Bitbucket] Notifying commit build result
      com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketRequestException: HTTP request error. Status: 400: BAD REQUEST.
      {"error": {"fields": {"url": ["Enter a valid URL."]}, "message": "Bad request"}}
      	at com.cloudbees.jenkins.plugins.bitbucket.client.BitbucketCloudApiClient.postRequest(BitbucketCloudApiClient.java:496)
      	at com.cloudbees.jenkins.plugins.bitbucket.client.BitbucketCloudApiClient.postRequest(BitbucketCloudApiClient.java:523)
      	at com.cloudbees.jenkins.plugins.bitbucket.client.BitbucketCloudApiClient.postBuildStatus(BitbucketCloudApiClient.java:311)
      	at com.cloudbees.jenkins.plugins.bitbucket.BitbucketChangesetCommentNotifier.buildStatus(BitbucketChangesetCommentNotifier.java:49)
      	at com.cloudbees.jenkins.plugins.bitbucket.BitbucketBuildStatusNotifications.createBuildCommitStatus(BitbucketBuildStatusNotifications.java:87)
      	at com.cloudbees.jenkins.plugins.bitbucket.BitbucketBuildStatusNotifications.sendNotifications(BitbucketBuildStatusNotifications.java:173)
      	at com.cloudbees.jenkins.plugins.bitbucket.BitbucketBuildStatusNotifications.access$000(BitbucketBuildStatusNotifications.java:61)
      	at com.cloudbees.jenkins.plugins.bitbucket.BitbucketBuildStatusNotifications$JobCheckOutListener.onCheckout(BitbucketBuildStatusNotifications.java:192)
      	at org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:123)
      	at org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition.create(CpsScmFlowDefinition.java:108)
      	at org.jenkinsci.plugins.workflow.multibranch.SCMBinder.create(SCMBinder.java:85)
      	at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:214)
      	at hudson.model.ResourceController.execute(ResourceController.java:98)
      	at hudson.model.Executor.run(Executor.java:410)
      

      This is especially confusing given running the code in the plugin in the groovy console results in:

      def instance = Jenkins.getInstance()
      def bar_job = instance.getAllItems(WorkflowJob).find { it.getFullName() == "foo/bar/master"}
      def bar_last_build =  bar_job.getLastBuild()
      println DisplayURLProvider.get().getRunURL(bar_last_build)
      
      Result: https://my.fqdn.example.com/job/foo/job/bar/job/master/2/
      

      The confusion gets worse when navigating to the system configuration page appears to show the jenkins root url as configured (as autodetected) with the fqdn, whereas internally it's null.

      With changing nothing other than clicking save on the system configuration page (which then commits the autodetected fqdn as the actual rooturl) the job then completes successfully.

        Attachments

          Issue Links

            Activity

            Hide
            kenperkins Ken Perkins added a comment -

            For what it's worth, I'm getting the same behavior from the GitHub side of things. When I freshly restart jenkins, all build links on the GitHub side are http://unconfigured-jenkins-location/....

            When I go to manage jenkins, the URL is correct, and if I simply click "Apply" all builds there after will be correct.

            Show
            kenperkins Ken Perkins added a comment - For what it's worth, I'm getting the same behavior from the GitHub side of things. When I freshly restart jenkins, all build links on the GitHub side are http://unconfigured-jenkins-location/... . When I go to manage jenkins, the URL is correct, and if I simply click "Apply" all builds there after will be correct.
            Hide
            stephenconnolly Stephen Connolly added a comment -

            2.2.8

            Show
            stephenconnolly Stephen Connolly added a comment - 2.2.8
            Hide
            smorley Stephen Morley added a comment - - edited

            I'm still getting this issue even with the 2.2.8 version. 

            What changed with that version?

            Although now I look closely my stack trace is a little different

             
            com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketRequestException: HTTP request error. Status: 400: Bad Request.
            {"type": "error", "error": {"fields": {"url": ["Enter a valid URL."]}, "message": "Bad request"}}
            at com.cloudbees.jenkins.plugins.bitbucket.client.BitbucketCloudApiClient.doRequest(BitbucketCloudApiClient.java:637)
            at com.cloudbees.jenkins.plugins.bitbucket.client.BitbucketCloudApiClient.postRequest(BitbucketCloudApiClient.java:682)
            at com.cloudbees.jenkins.plugins.bitbucket.client.BitbucketCloudApiClient.postBuildStatus(BitbucketCloudApiClient.java:440)
            at com.cloudbees.jenkins.plugins.bitbucket.BitbucketChangesetCommentNotifier.buildStatus(BitbucketChangesetCommentNotifier.java:51)
            at com.cloudbees.jenkins.plugins.bitbucket.BitbucketBuildStatusNotifications.createStatus(BitbucketBuildStatusNotifications.java:93)
            at com.cloudbees.jenkins.plugins.bitbucket.BitbucketBuildStatusNotifications.sendNotifications(BitbucketBuildStatusNotifications.java:122)
            at com.cloudbees.jenkins.plugins.bitbucket.BitbucketBuildStatusNotifications.access$000(BitbucketBuildStatusNotifications.java:55)
            at com.cloudbees.jenkins.plugins.bitbucket.BitbucketBuildStatusNotifications$JobCheckOutListener.onCheckout(BitbucketBuildStatusNotifications.java:150)
            at org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:127)
            at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:85)
            at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:75)
            at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1$1.call(AbstractSynchronousNonBlockingStepExecution.java:47)
            at hudson.security.ACL.impersonate(ACL.java:260)
            at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:44)
            at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
            at java.util.concurrent.FutureTask.run(Unknown Source)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
            at java.lang.Thread.run(Unknown Source)

            Show
            smorley Stephen Morley added a comment - - edited I'm still getting this issue even with the 2.2.8 version.  What changed with that version? Although now I look closely my stack trace is a little different   com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketRequestException: HTTP request error. Status: 400: Bad Request. {"type": "error", "error": {"fields": {"url": ["Enter a valid URL."] }, "message": "Bad request"}} at com.cloudbees.jenkins.plugins.bitbucket.client.BitbucketCloudApiClient.doRequest(BitbucketCloudApiClient.java:637) at com.cloudbees.jenkins.plugins.bitbucket.client.BitbucketCloudApiClient.postRequest(BitbucketCloudApiClient.java:682) at com.cloudbees.jenkins.plugins.bitbucket.client.BitbucketCloudApiClient.postBuildStatus(BitbucketCloudApiClient.java:440) at com.cloudbees.jenkins.plugins.bitbucket.BitbucketChangesetCommentNotifier.buildStatus(BitbucketChangesetCommentNotifier.java:51) at com.cloudbees.jenkins.plugins.bitbucket.BitbucketBuildStatusNotifications.createStatus(BitbucketBuildStatusNotifications.java:93) at com.cloudbees.jenkins.plugins.bitbucket.BitbucketBuildStatusNotifications.sendNotifications(BitbucketBuildStatusNotifications.java:122) at com.cloudbees.jenkins.plugins.bitbucket.BitbucketBuildStatusNotifications.access$000(BitbucketBuildStatusNotifications.java:55) at com.cloudbees.jenkins.plugins.bitbucket.BitbucketBuildStatusNotifications$JobCheckOutListener.onCheckout(BitbucketBuildStatusNotifications.java:150) at org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:127) at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:85) at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:75) at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1$1.call(AbstractSynchronousNonBlockingStepExecution.java:47) at hudson.security.ACL.impersonate(ACL.java:260) at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:44) at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) at java.util.concurrent.FutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source)
            Hide
            meisert Mark isert added a comment - - edited

            I was getting this error as well.  After adding some logging in the plugin I discovered here:

                    if (cfg == null || cfg.getUrl() == null)

            {             LOGGER.fine(Level.INFO, "JenkinsLocationConfiguration empty");             throw new IllegalStateException("Could not determine Jenkins URL.");         }

            That the server URL required a "." in it.  In our case the Jenkins URL was a short name without a ".".  So I changed it to use a long URL alias we have as well.  This seems like a bug.  At the least there could be more logging added to the code.  I had to add more logging to figure this out for example and the original exception stack trace wasn't logged in this case.

            Show
            meisert Mark isert added a comment - - edited I was getting this error as well.  After adding some logging in the plugin I discovered here:         if (cfg == null || cfg.getUrl() == null) {             LOGGER.fine(Level.INFO, "JenkinsLocationConfiguration empty");             throw new IllegalStateException("Could not determine Jenkins URL.");         } That the server URL required a "." in it.  In our case the Jenkins URL was a short name without a ".".  So I changed it to use a long URL alias we have as well.  This seems like a bug.  At the least there could be more logging added to the code.  I had to add more logging to figure this out for example and the original exception stack trace wasn't logged in this case.
            Hide
            smorley Stephen Morley added a comment -

            Confirmed. After I changed the Jenkins URL to the IP address the problem went away. We're in a small shop so I don't have a domain name I can add to the normal URL.

            Show
            smorley Stephen Morley added a comment - Confirmed. After I changed the Jenkins URL to the IP address the problem went away. We're in a small shop so I don't have a domain name I can add to the normal URL.

              People

              • Assignee:
                stephenconnolly Stephen Connolly
                Reporter:
                hogarthj James Hogarth
              • Votes:
                7 Vote for this issue
                Watchers:
                11 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: