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 created issue -

          Hi dodoent, there is some configuration checks missing in the video. Because of that I removed the video right now from the wiki page. Could you ensure you have a valid URL for the field Jenkins Location? Take a look here in the wiki page.

          Antonio Mansilla added a comment - Hi dodoent , there is some configuration checks missing in the video. Because of that I removed the video right now from the wiki page. Could you ensure you have a valid URL for the field Jenkins Location? Take a look here in the wiki page .
          Antonio Mansilla made changes -
          Status Original: Open [ 1 ] New: In Progress [ 3 ]

          Nenad Miksa added a comment -

          Hi Antonio. What is a "valid URL"?

          I've tried setting following URLs as "Callback URL" of OAuth consumer, none of them worked:

          http://141.138.8.191:54321/jenkins
          http://141.138.8.191:54321
          http://bitbucket:keyForBitbucketUserOnJenkinsServer@141.138.8.191:54321/jenkins (this one is used for notifying Jenkins that there was a push into a repository)

          For security reason, 141.138.8.191:54321 is accessible only from these IP ranges: 131.103.20.160/27, 165.254.145.0/26 and 104.192.143.0/24 (as documented here: https://confluence.atlassian.com/bitbucket/manage-webhooks-735643732.html)

          In Manage Jenkins -> Jenkins Location -> Jenkins URL the set URL is: http://192.168.100.234/jenkins (this URL is accessible only from LAN - not from public Internet).

          Nenad Miksa added a comment - Hi Antonio. What is a "valid URL"? I've tried setting following URLs as "Callback URL" of OAuth consumer, none of them worked: http://141.138.8.191:54321/jenkins http://141.138.8.191:54321 http://bitbucket:keyForBitbucketUserOnJenkinsServer@141.138.8.191:54321/jenkins (this one is used for notifying Jenkins that there was a push into a repository) For security reason, 141.138.8.191:54321 is accessible only from these IP ranges: 131.103.20.160/27, 165.254.145.0/26 and 104.192.143.0/24 (as documented here: https://confluence.atlassian.com/bitbucket/manage-webhooks-735643732.html ) In Manage Jenkins -> Jenkins Location -> Jenkins URL the set URL is: http://192.168.100.234/jenkins (this URL is accessible only from LAN - not from public Internet).

          Hi dodoent, I was trying to reproduce your problem but I'm not able to reproduce it using the last plugin version. Which version of the plugin are you using actually the latest stable is 1.2.0? In case you are not using the latest stable one, could you please update the plugin and try again?

          Thanks and regards.

          Antonio Mansilla added a comment - Hi dodoent , I was trying to reproduce your problem but I'm not able to reproduce it using the last plugin version. Which version of the plugin are you using actually the latest stable is 1.2.0? In case you are not using the latest stable one, could you please update the plugin and try again? Thanks and regards.

          Nenad Miksa added a comment -

          Hi Antonio,

          Jenkins plugin manager tells me that v1.2.0 is being used. I am keeping all my plugins up to date with the exception of "Bitbucket Pullrequest Builder Plugin" which I keep on 1.4.7 since every version after it causes infinite rebuilds of my pull requests (I've already issued the ticket to the author, yet it is still not fixed in 1.4.18).

          Is there any debug log I can enable to help you find a problem? Can you add logging of the URL to which you are sending request? Currently only server response is logged. I would like to see the entire request and repeat it from commandline with curl - it may be possible that error is due to my firewall configuration.

          Regards,
          Nenad

          Nenad Miksa added a comment - Hi Antonio, Jenkins plugin manager tells me that v1.2.0 is being used. I am keeping all my plugins up to date with the exception of "Bitbucket Pullrequest Builder Plugin" which I keep on 1.4.7 since every version after it causes infinite rebuilds of my pull requests (I've already issued the ticket to the author, yet it is still not fixed in 1.4.18). Is there any debug log I can enable to help you find a problem? Can you add logging of the URL to which you are sending request? Currently only server response is logged. I would like to see the entire request and repeat it from commandline with curl - it may be possible that error is due to my firewall configuration. Regards, Nenad

          Hi Nenad,

          that's weird since it seems the communication with bitbucket is working, so the problem should not be caused by your firewall but in the plugin self. Try posting the build status manually from your terminal following this instructions:

          First get the ACCESS_TOKEN:

          curl -X POST https://bitbucket.org/site/oauth2/access_token -u "API_KEY:API_SECRET" -d grant_type=client_credentials
          

          The response will be something like this:

          {"access_token": "ACCESS_TOKEN", "scopes": "repository:write", "expires_in": 3600, "refresh_token": "sYf7Ka49Cc4kgFKFTV", "token_type": "bearer"}
          

          Use the ACCESS_TOKEN received in the next request:

          curl -X POST https://api.bitbucket.org/2.0/repositories/REPO_OWNER/REPO_NAME/commit/COMMIT_ID/statuses/build -H "Content-Type: application/json" -H "Authorization: Bearer ACCESS_TOKEN" -d '{
          "state": "SUCCESSFUL",
              "key": "BAMBOO-PROJECT-X-X",
              "name": "Build #34",
              "url": "https://example.com/path/to/build/info",
              "description": "Changes by John Doe"}'
          

          I got to reproduce your problem and it seems that the attribute "url" is being set with a invalid URL value, so I guess it's a plugin internal problem. Before I deep in the plugin code, could you please confirm you get the previous example working?

          Antonio Mansilla added a comment - Hi Nenad, that's weird since it seems the communication with bitbucket is working, so the problem should not be caused by your firewall but in the plugin self. Try posting the build status manually from your terminal following this instructions: First get the ACCESS_TOKEN: curl -X POST https: //bitbucket.org/site/oauth2/access_token -u "API_KEY:API_SECRET" -d grant_type=client_credentials The response will be something like this: { "access_token" : "ACCESS_TOKEN" , "scopes" : "repository:write" , "expires_in" : 3600, "refresh_token" : "sYf7Ka49Cc4kgFKFTV" , "token_type" : "bearer" } Use the ACCESS_TOKEN received in the next request: curl -X POST https: //api.bitbucket.org/2.0/repositories/REPO_OWNER/REPO_NAME/commit/COMMIT_ID/statuses/build -H "Content-Type: application/json" -H "Authorization: Bearer ACCESS_TOKEN" -d '{ "state" : "SUCCESSFUL" , "key" : "BAMBOO-PROJECT-X-X" , "name" : "Build #34" , "url" : "https: //example.com/path/to/build/info" , "description" : "Changes by John Doe" }' I got to reproduce your problem and it seems that the attribute "url" is being set with a invalid URL value, so I guess it's a plugin internal problem. Before I deep in the plugin code, could you please confirm you get the previous example working?

          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

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

              Created:
              Updated:
              Resolved: