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

Build status notification fails with "Enter a valid URL"

      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.

          [JENKINS-34788] Build status notification fails with "Enter a valid URL"

          Nenad Miksa added a comment -

          Hi Antonio!

          I can confirm that calling BitBucket with curl as you explained works correctly (I've tried issuing the request from both my laptop and server where Jenkins is installed).

          When I put some random string which is not in URL form in field "url", then I get the same error as observed in jenkins log. Is there a way for me to enable logging which will show me what is the value plugin puts in "url" field before issuing a request?

          Btw, one side question: how does plugin perform when I have option "merge before build" enabled in my Git plugin? I've tried issuing a curl request with merge commit created before build and Bitbucket responded with "Changeset not found.". Does in this case plugin send the commit ID of the original commit (before making a merge)?

          Nenad Miksa added a comment - Hi Antonio! I can confirm that calling BitBucket with curl as you explained works correctly (I've tried issuing the request from both my laptop and server where Jenkins is installed). When I put some random string which is not in URL form in field "url", then I get the same error as observed in jenkins log. Is there a way for me to enable logging which will show me what is the value plugin puts in "url" field before issuing a request? Btw, one side question: how does plugin perform when I have option "merge before build" enabled in my Git plugin? I've tried issuing a curl request with merge commit created before build and Bitbucket responded with "Changeset not found.". Does in this case plugin send the commit ID of the original commit (before making a merge)?

          Code changed in jenkins
          User: Antonio Mansilla
          Path:
          src/main/java/org/jenkinsci/plugins/bitbucket/BitbucketBuildStatusNotifier.java
          http://jenkins-ci.org/commit/bitbucket-build-status-notifier-plugin/35fb7cf5e7bf2638f38baadbd63a6885774b5a52
          Log:
          JENKINS-34788 Add more logging for easy debugging bitbucket request and response

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Antonio Mansilla Path: src/main/java/org/jenkinsci/plugins/bitbucket/BitbucketBuildStatusNotifier.java http://jenkins-ci.org/commit/bitbucket-build-status-notifier-plugin/35fb7cf5e7bf2638f38baadbd63a6885774b5a52 Log: JENKINS-34788 Add more logging for easy debugging bitbucket request and response

          Code changed in jenkins
          User: Antonio Mansilla
          Path:
          src/main/java/org/jenkinsci/plugins/bitbucket/BitbucketBuildStatusNotifier.java
          http://jenkins-ci.org/commit/bitbucket-build-status-notifier-plugin/acac5171f50f61ea098c49778868fdff12ec0ed8
          Log:
          Merge pull request #21 from Flagbit/issue-34651

          JENKINS-34788 Add more logging for easy debugging bitbucket request

          Compare: https://github.com/jenkinsci/bitbucket-build-status-notifier-plugin/compare/66a0a8926765...acac5171f50f

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Antonio Mansilla Path: src/main/java/org/jenkinsci/plugins/bitbucket/BitbucketBuildStatusNotifier.java http://jenkins-ci.org/commit/bitbucket-build-status-notifier-plugin/acac5171f50f61ea098c49778868fdff12ec0ed8 Log: Merge pull request #21 from Flagbit/issue-34651 JENKINS-34788 Add more logging for easy debugging bitbucket request Compare: https://github.com/jenkinsci/bitbucket-build-status-notifier-plugin/compare/66a0a8926765...acac5171f50f

          Hi dodoent, I've added right now the bitbucket request content to the log. It'll be released tomorrow or next friday, so wait until the new plugin version is available, update it and lets run the build to see what's going on.

          Antonio Mansilla added a comment - Hi dodoent , I've added right now the bitbucket request content to the log. It'll be released tomorrow or next friday, so wait until the new plugin version is available, update it and lets run the build to see what's going on.

          Nenad Miksa added a comment -

          Thank you a lot, amansilla. I am looking forward to being able to debug that issue.

          Nenad Miksa added a comment - Thank you a lot, amansilla . I am looking forward to being able to debug that issue.

          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: {
          "state": "INPROGRESS",
          "key": "d341c8de26d9cf205542b1e445ae0c53",
          "url": "http://localhost:8080/job/Jenkins%20Test/branch/master/20/",
          "name": "Jenkins Test » master #20"
          }

          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: {
          "state": "INPROGRESS",
          "key": "b7fa1a78ad87d07cfe5413bbc34e0d84",
          "url": "http://localhost:8080/job/Jenkins%20Test/branch/master/21/",
          "name": "Jenkins Test/master #21"
          }

          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": ""}

          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: { "state": "INPROGRESS", "key": "d341c8de26d9cf205542b1e445ae0c53", "url": "http://localhost:8080/job/Jenkins%20Test/branch/master/20/", "name": "Jenkins Test » master #20" } 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: { "state": "INPROGRESS", "key": "b7fa1a78ad87d07cfe5413bbc34e0d84", "url": "http://localhost:8080/job/Jenkins%20Test/branch/master/21/", "name": "Jenkins Test/master #21" } 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": ""}

          Nenad Miksa added a comment -

          Hi flagbit,

          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.

          Nenad Miksa added a comment - Hi flagbit , 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.

          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.

          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.

          Hi dodoent, 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.

          Antonio Mansilla added a comment - Hi dodoent , 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.

          Nenad Miksa added a comment -

          Thanks!

          Nenad Miksa added a comment - Thanks!

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

              Created:
              Updated:
              Resolved: