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

Build status notification fails with "Enter a valid URL"

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      I've setup my environment as described in this video: https://www.youtube.com/watch?v=uu5XcU4EPzQ

      However, when build starts and finishes, I don't see the status on BitBucket commits. In Jenkins log I can see following messages:

      May 13 10:57:18 rambo jenkins[743]: INFO: Bitbucket notify on start
      May 13 10:57:19 rambo jenkins[743]: May 13, 2016 10:57:19 AM org.jenkinsci.plugins.bitbucket.BitbucketBuildStatusNotifier notifyBuildStatus
      May 13 10:57:19 rambo jenkins[743]: INFO: This response was received:{"error": {"fields":

      {"url": ["Enter a valid URL."]}

      , "message": "Bad request"}}
      May 13 10:57:19 rambo jenkins[743]: May 13, 2016 10:57:19 AM org.jenkinsci.plugins.bitbucket.BitbucketBuildStatusNotifier prebuild
      May 13 10:57:19 rambo jenkins[743]: INFO: Bitbucket notify on start succeeded

      Any idea what has been configured wrong?

      Note: our Jenkins server is inside our local network and generally it is not available from public web. The exception is hole opened exclusively for BitBucket's IP ranges so that push notifications can be sent to Jenkins from BitBucket's webhooks.

        Attachments

          Activity

          Hide
          neil_whitworth Neil Whitworth added a comment -

          I have been looking into a similar issues, where I was getting 'BAD REQUEST' responses from BitBucket.

          In my case I was using the 'Multi-Branch Project' Plugin, which creates a folder, with a job per branch.

          I traced the BAD REQUEST response back to the value of the "name" field in the build update request. This includes a '»' character from the call to getFullDisplayName in function createBitbucketBuildStatusFromBuild

                  String buildName = build.getProject().getFullDisplayName() + " #" + build.getNumber();
          

          failing log:-

          May 27, 2016 2:30:48 PM INFO org.jenkinsci.plugins.bitbucket.BitbucketBuildStatusNotifier notifyBuildStatus

          This request was sent:

          Unknown macro: { "state"}

          May 27, 2016 2:30:48 PM INFO org.jenkinsci.plugins.bitbucket.BitbucketBuildStatusNotifier notifyBuildStatus

          This response was received: Bad Request

          changing to use getFullName (which uses a '/' char) fixed my issues.

                  String buildName = build.getProject().getFullName() + " #" + build.getNumber();
          

          May 27, 2016 2:32:46 PM INFO org.jenkinsci.plugins.bitbucket.BitbucketBuildStatusNotifier notifyBuildStatus

          This request was sent:

          Unknown macro: { "state"}

          This response was received: {"name": "Jenkins Test/master #21", "links": {"commit":

          Unknown macro: {"href"}

          , "self": {"href": "https://api.bitbucket.org/2.0/repositories/rivdevteam/jenkinstest/commit/7fce0b1f41e4f10cdd4faa7a62dd68a38e575e89/statuses/build/b7fa1a78ad87d07cfe5413bbc34e0d84"}}, "url": "http://localhost:8080/job/Jenkins%20Test/branch/master/21/", "created_on": "2016-05-27T13:32:41.883282+00:00", "repository": {"links": {"self":

          Unknown macro: {"href"}

          , "html":

          Unknown macro: {"href"}

          , "avatar": {"href": "https://bitbucket.org/rivdevteam/jenkinstest/avatar/32/"}}, "type": "repository", "name": "JenkinsTest", "full_name": "rivdevteam/jenkinstest", "uuid": "

          Unknown macro: {faa4fbc3-155b-4de0-bedf-8a7338292d9d}

          "}, "state": "INPROGRESS", "key": "b7fa1a78ad87d07cfe5413bbc34e0d84", "updated_on": "2016-05-27T13:32:41.883319+00:00", "type": "build", "description": ""}

          Show
          neil_whitworth Neil Whitworth added a comment - I have been looking into a similar issues, where I was getting 'BAD REQUEST' responses from BitBucket. In my case I was using the 'Multi-Branch Project' Plugin, which creates a folder, with a job per branch. I traced the BAD REQUEST response back to the value of the "name" field in the build update request. This includes a '»' character from the call to getFullDisplayName in function createBitbucketBuildStatusFromBuild String buildName = build.getProject().getFullDisplayName() + " #" + build.getNumber(); failing log:- May 27, 2016 2:30:48 PM INFO org.jenkinsci.plugins.bitbucket.BitbucketBuildStatusNotifier notifyBuildStatus This request was sent: Unknown macro: { "state"} May 27, 2016 2:30:48 PM INFO org.jenkinsci.plugins.bitbucket.BitbucketBuildStatusNotifier notifyBuildStatus This response was received: Bad Request changing to use getFullName (which uses a '/' char) fixed my issues. String buildName = build.getProject().getFullName() + " #" + build.getNumber(); May 27, 2016 2:32:46 PM INFO org.jenkinsci.plugins.bitbucket.BitbucketBuildStatusNotifier notifyBuildStatus This request was sent: Unknown macro: { "state"} This response was received: {"name": "Jenkins Test/master #21", "links": {"commit": Unknown macro: {"href"} , "self": {"href": "https://api.bitbucket.org/2.0/repositories/rivdevteam/jenkinstest/commit/7fce0b1f41e4f10cdd4faa7a62dd68a38e575e89/statuses/build/b7fa1a78ad87d07cfe5413bbc34e0d84"}}, "url": "http://localhost:8080/job/Jenkins%20Test/branch/master/21/", "created_on": "2016-05-27T13:32:41.883282+00:00", "repository": {"links": {"self": Unknown macro: {"href"} , "html": Unknown macro: {"href"} , "avatar": {"href": "https://bitbucket.org/rivdevteam/jenkinstest/avatar/32/"}}, "type": "repository", "name": "JenkinsTest", "full_name": "rivdevteam/jenkinstest", "uuid": " Unknown macro: {faa4fbc3-155b-4de0-bedf-8a7338292d9d} "}, "state": "INPROGRESS", "key": "b7fa1a78ad87d07cfe5413bbc34e0d84", "updated_on": "2016-05-27T13:32:41.883319+00:00", "type": "build", "description": ""}
          Hide
          dodoent Nenad Miksa added a comment -

          Hi Antonio Mansilla,

          I've finally received the update with logging enabled. Here are the logs of request and response:

          Jun 06 09:29:38 rambo jenkins[747]: Jun 06, 2016 9:29:38 AM org.jenkinsci.plugins.bitbucket.BitbucketBuildStatusNotifier notifyBuildStatus
          Jun 06 09:29:38 rambo jenkins[747]: INFO: This request was sent:

          { Jun 06 09:29:38 rambo jenkins[747]: "state": "INPROGRESS", Jun 06 09:29:38 rambo jenkins[747]: "key": "2a8f71244f064b1edc24a179661da25f", Jun 06 09:29:38 rambo jenkins[747]: "url": "http://rambo/jenkins/job/AndroidCore/687/", Jun 06 09:29:38 rambo jenkins[747]: "name": "AndroidCore #687" Jun 06 09:29:38 rambo jenkins[747]: }

          Jun 06 09:29:38 rambo jenkins[747]: Jun 06, 2016 9:29:38 AM org.jenkinsci.plugins.bitbucket.BitbucketBuildStatusNotifier notifyBuildStatus
          Jun 06 09:29:38 rambo jenkins[747]: INFO: This response was received: {"error": {"fields":

          {"url": ["Enter a valid URL."]}

          , "message": "Bad request"}}

          After cancelling the build:

          Jun 06 09:30:02 rambo jenkins[747]: INFO: Bitbucket notify on finish
          Jun 06 09:30:03 rambo jenkins[747]: Jun 06, 2016 9:30:03 AM org.jenkinsci.plugins.bitbucket.BitbucketBuildStatusNotifier notifyBuildStatus
          Jun 06 09:30:03 rambo jenkins[747]: INFO: This request was sent:

          { Jun 06 09:30:03 rambo jenkins[747]: "state": "FAILED", Jun 06 09:30:03 rambo jenkins[747]: "key": "2a8f71244f064b1edc24a179661da25f", Jun 06 09:30:03 rambo jenkins[747]: "url": "http://rambo/jenkins/job/AndroidCore/687/", Jun 06 09:30:03 rambo jenkins[747]: "name": "AndroidCore #687" Jun 06 09:30:03 rambo jenkins[747]: }

          Jun 06 09:30:03 rambo jenkins[747]: Jun 06, 2016 9:30:03 AM org.jenkinsci.plugins.bitbucket.BitbucketBuildStatusNotifier notifyBuildStatus
          Jun 06 09:30:03 rambo jenkins[747]: INFO: This response was received: {"error": {"fields":

          {"url": ["Enter a valid URL."]}

          , "message": "Bad request"}}
          Jun 06 09:30:03 rambo jenkins[747]: Jun 06, 2016 9:30:03 AM org.jenkinsci.plugins.bitbucket.BitbucketBuildStatusNotifier perform
          Jun 06 09:30:03 rambo jenkins[747]: INFO: Bitbucket notify on finish succeeded

          Hopefully this can help debugging the issue.

          Show
          dodoent Nenad Miksa added a comment - Hi Antonio Mansilla , I've finally received the update with logging enabled. Here are the logs of request and response: Jun 06 09:29:38 rambo jenkins [747] : Jun 06, 2016 9:29:38 AM org.jenkinsci.plugins.bitbucket.BitbucketBuildStatusNotifier notifyBuildStatus Jun 06 09:29:38 rambo jenkins [747] : INFO: This request was sent: { Jun 06 09:29:38 rambo jenkins[747]: "state": "INPROGRESS", Jun 06 09:29:38 rambo jenkins[747]: "key": "2a8f71244f064b1edc24a179661da25f", Jun 06 09:29:38 rambo jenkins[747]: "url": "http://rambo/jenkins/job/AndroidCore/687/", Jun 06 09:29:38 rambo jenkins[747]: "name": "AndroidCore #687" Jun 06 09:29:38 rambo jenkins[747]: } Jun 06 09:29:38 rambo jenkins [747] : Jun 06, 2016 9:29:38 AM org.jenkinsci.plugins.bitbucket.BitbucketBuildStatusNotifier notifyBuildStatus Jun 06 09:29:38 rambo jenkins [747] : INFO: This response was received: {"error": {"fields": {"url": ["Enter a valid URL."]} , "message": "Bad request"}} After cancelling the build: Jun 06 09:30:02 rambo jenkins [747] : INFO: Bitbucket notify on finish Jun 06 09:30:03 rambo jenkins [747] : Jun 06, 2016 9:30:03 AM org.jenkinsci.plugins.bitbucket.BitbucketBuildStatusNotifier notifyBuildStatus Jun 06 09:30:03 rambo jenkins [747] : INFO: This request was sent: { Jun 06 09:30:03 rambo jenkins[747]: "state": "FAILED", Jun 06 09:30:03 rambo jenkins[747]: "key": "2a8f71244f064b1edc24a179661da25f", Jun 06 09:30:03 rambo jenkins[747]: "url": "http://rambo/jenkins/job/AndroidCore/687/", Jun 06 09:30:03 rambo jenkins[747]: "name": "AndroidCore #687" Jun 06 09:30:03 rambo jenkins[747]: } Jun 06 09:30:03 rambo jenkins [747] : Jun 06, 2016 9:30:03 AM org.jenkinsci.plugins.bitbucket.BitbucketBuildStatusNotifier notifyBuildStatus Jun 06 09:30:03 rambo jenkins [747] : INFO: This response was received: {"error": {"fields": {"url": ["Enter a valid URL."]} , "message": "Bad request"}} Jun 06 09:30:03 rambo jenkins [747] : Jun 06, 2016 9:30:03 AM org.jenkinsci.plugins.bitbucket.BitbucketBuildStatusNotifier perform Jun 06 09:30:03 rambo jenkins [747] : INFO: Bitbucket notify on finish succeeded Hopefully this can help debugging the issue.
          Hide
          dodoent Nenad Miksa added a comment -

          Thank you for enabling the logging - I figured out the problem. The BitBucket API does not allow server names without dot. So while http://rambo/jenkins/job/AndroidCore/687/ was deemed as invalid URL, http://rambo.local/jenkins/job/AndroidCore/687/ was a valid URL.

          After all it was not bug in plugin - it was a bug in configuration on my server.

          Just a hint for future - if possible, please write somewhere (in documentation or setup guide) that server name should be a fully qualified name.

          Show
          dodoent Nenad Miksa added a comment - Thank you for enabling the logging - I figured out the problem. The BitBucket API does not allow server names without dot. So while http://rambo/jenkins/job/AndroidCore/687/ was deemed as invalid URL, http://rambo.local/jenkins/job/AndroidCore/687/ was a valid URL. After all it was not bug in plugin - it was a bug in configuration on my server. Just a hint for future - if possible, please write somewhere (in documentation or setup guide) that server name should be a fully qualified name.
          Hide
          flagbit Antonio Mansilla added a comment -

          Hi Nenad Miksa, I've updated the plugin for validating the Jenkins Job URL before the build status is sent to Bitbucket API, that way we are be able to avoid bad requests and show a more suitable error message to the user.

          Show
          flagbit Antonio Mansilla added a comment - Hi Nenad Miksa , I've updated the plugin for validating the Jenkins Job URL before the build status is sent to Bitbucket API, that way we are be able to avoid bad requests and show a more suitable error message to the user.
          Hide
          dodoent Nenad Miksa added a comment -

          Thanks!

          Show
          dodoent Nenad Miksa added a comment - Thanks!

            People

            • Assignee:
              flagbit Antonio Mansilla
              Reporter:
              dodoent Nenad Miksa
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: