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

Build status is not being set for parameterized repositories

      The plugin doesn't set the status:

      According to the job log - everything is fine:

      Sending build status INPROGRESS for commit 915809121478ace3d92e52bbb2769f03f26cbfa9 to BitBucket is done!
      Sending build status SUCCESSFUL for commit 915809121478ace3d92e52bbb2769f03f26cbfa9 to BitBucket is done!
      

      Plugin log:

      Mar 02, 2016 6:23:46 PM INFO org.jenkinsci.plugins.bitbucket.BitbucketBuildStatusNotifier prebuild
      Bitbucket notify on start
      Mar 02, 2016 6:23:46 PM INFO org.jenkinsci.plugins.bitbucket.BitbucketBuildStatusNotifier notifyBuildStatus
      This response was received:
      Mar 02, 2016 6:23:47 PM INFO org.jenkinsci.plugins.bitbucket.BitbucketBuildStatusNotifier prebuild
      Bitbucket notify on start succeeded
      Mar 02, 2016 6:23:47 PM INFO org.jenkinsci.plugins.bitbucket.BitbucketBuildStatusNotifier perform
      Bitbucket notify on finish
      Mar 02, 2016 6:23:47 PM INFO org.jenkinsci.plugins.bitbucket.BitbucketBuildStatusNotifier notifyBuildStatus
      This response was received:
      Mar 02, 2016 6:23:48 PM INFO org.jenkinsci.plugins.bitbucket.BitbucketBuildStatusNotifier perform
      Bitbucket notify on finish succeeded
      

      Using CURL requests to api with the same credentials I'm able to set the status:
      REQUEST:

      curl -X POST https://api.bitbucket.org/2.0/repositories/myteam/myrepo.git/commit/9186237941862379481679236178237/statuses/build -H "Authorization: Bearer HkG8WeMRte2C2vx3CL8SwE7gO8_086612391486231486723617991_g==" -d state=SUCCESSFUL -d key=JENKINS-BUILD-50 -d url=https://cicd.myrepo.ru/job/myrepo/
      

      RESPONSE:

      {"name": "", "links": {"commit": {"href": "https://api.bitbucket.org/2.0/repositories/myteam/myrepo/commit/9186237941862379481679236178237"}, "self": {"href": "https://api.bitbucket.org/2.0/repositories/myteam/myrepo/commit/9186237941862379481679236178237/statuses/build/JENKINS-BUILD-50"}}, "url": "https://cicd.myrepo.ru/job/myrepo/", "state": "SUCCESSFUL", "created_on": "2016-03-02T14:46:06.740794+00:00", "key": "JENKINS-BUILD-50", "updated_on": "2016-03-02T14:48:41.267025+00:00", "type": "build", "description": ""}
      

          [JENKINS-33276] Build status is not being set for parameterized repositories

          Key and Secret credentials are accepted without error in job configuration page

          Lior Goikhburg added a comment - Key and Secret credentials are accepted without error in job configuration page

          Hi zerthimon, first thank you for reporting the issue. Currently I don't have too much time to take a look to this, so maybe you could clone the repository, deep into the code and try identify what is exactly the problem, that'd be fine at first.

          Antonio Mansilla added a comment - Hi zerthimon , first thank you for reporting the issue. Currently I don't have too much time to take a look to this, so maybe you could clone the repository, deep into the code and try identify what is exactly the problem, that'd be fine at first.

          Hi zerthimon I just remembered some guy had a similar issue because long job names. Can you please report the job name you are having this issue with? Thx

          Antonio Mansilla added a comment - Hi zerthimon I just remembered some guy had a similar issue because long job names. Can you please report the job name you are having this issue with? Thx

          The job name is "test".
          Regarding fixing the code myself, well, that has a very low chance of success considering me not knowing Java

          Lior Goikhburg added a comment - The job name is "test". Regarding fixing the code myself, well, that has a very low chance of success considering me not knowing Java

          Lior Goikhburg added a comment - - edited

          Hey amansilla I figured out what's causing this.
          I have a global variable (that I inject before SCM) configured in the repo url such as:

          Repository URL: git@bitbucket.org:my_team/${PROJECT}.git

          I guess that the plugin cannot expand that variable and proceeds to notify the repo by

          my_team/${PROJECT}

          name.
          When I change the variable to a real repo name - the plugin works like a charm.

          Lior Goikhburg added a comment - - edited Hey amansilla I figured out what's causing this. I have a global variable (that I inject before SCM) configured in the repo url such as: Repository URL: git@bitbucket.org:my_team/${PROJECT}.git I guess that the plugin cannot expand that variable and proceeds to notify the repo by my_team/${PROJECT} name. When I change the variable to a real repo name - the plugin works like a charm.

          Nice catch zerthimon. In that case, can you please provide a list of the plugins involved in your deployment and some tips for the job configuration in order to I can properly reproduce your problem?

          Antonio Mansilla added a comment - Nice catch zerthimon . In that case, can you please provide a list of the plugins involved in your deployment and some tips for the job configuration in order to I can properly reproduce your problem?

          Lior Goikhburg added a comment - - edited

          Oh, I have a lot of plugins actually, the relevant for this problem is "Environment Injector Plugin".

          The job is configured as follows:

          1. Select "Prepare an environment for the run" checkbox (just before SCM)
          2. In "Properties Content" form write:
            PROJECT=REPO_NAME
          3. In SCM choose git and enter "Reository URL"
            git@bitbucket.org:USERNAME/${PROJECT}.git
          4. In Post-build actions configure "Bitbucket notify build status"

          That should trigger the problem.

          EDIT:
          You can also try without "Environment Injector Plugin":
          Set your job name as the name of your bitbucket repo, and then configure your repo URL to use a built-in variable $JOB_NAME:

          git@bitbucket.org:USERNAME/${JOB_NAME}.git

          And check if your repo is notified.

          Lior Goikhburg added a comment - - edited Oh, I have a lot of plugins actually, the relevant for this problem is "Environment Injector Plugin". The job is configured as follows: Select "Prepare an environment for the run" checkbox (just before SCM) In "Properties Content" form write: PROJECT=REPO_NAME In SCM choose git and enter "Reository URL" git@bitbucket.org:USERNAME/${PROJECT}.git In Post-build actions configure "Bitbucket notify build status" That should trigger the problem. EDIT: You can also try without "Environment Injector Plugin": Set your job name as the name of your bitbucket repo, and then configure your repo URL to use a built-in variable $JOB_NAME: git@bitbucket.org:USERNAME/${JOB_NAME}.git And check if your repo is notified.

          Hi Antonio, have you been able to duplicate the problem? Do you think this can be fixed? It'd be cool if I could use a variable in repo name and still be able to have bitbucket notifications.

          Lior Goikhburg added a comment - Hi Antonio, have you been able to duplicate the problem? Do you think this can be fixed? It'd be cool if I could use a variable in repo name and still be able to have bitbucket notifications.

          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/32e1ecb6616eb3d24878f1cc256c8976ac58fc02
          Log:
          JENKINS-33276 Expands env parameters on repo URL

          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/32e1ecb6616eb3d24878f1cc256c8976ac58fc02 Log: JENKINS-33276 Expands env parameters on repo URL

          Sorry for the delay zerthimon, I finally got your problem and fixed it and it'll be included in the plugin release.

          Thank you for all the information you provided, it was really helpful.

          Antonio Mansilla added a comment - Sorry for the delay zerthimon , I finally got your problem and fixed it and it'll be included in the plugin release. Thank you for all the information you provided, it was really helpful.

            flagbit Antonio Mansilla
            zerthimon Lior Goikhburg
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: