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

Allow Bitbucket build status text to be overridden

      Currently the text sent to Bitbucket as build status for a commit is hardcoded with messages that could be misleading (such as "This commit has test failures") if the job uses build statuses differently (i.e. UNSTABLE happens to mean something else).  At the very least the text should say "The commit is unstable".

      https://github.com/jenkinsci/bitbucket-branch-source-plugin/blob/master/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketBuildStatusNotifications.java#L73

       

      if (Result.SUCCESS.equals(result)) {
      status = new BitbucketBuildStatus(hash, "This commit looks good", "SUCCESSFUL", url, key, name);
      } else if (Result.UNSTABLE.equals(result)) {
      status = new BitbucketBuildStatus(hash, "This commit has test failures", "FAILED", url, key, name);
      } else if (Result.FAILURE.equals(result)) {
      status = new BitbucketBuildStatus(hash, "There was a failure building this commit", "FAILED", url, key,
      name);
      } else if (result != null) { // ABORTED etc.
      status = new BitbucketBuildStatus(hash, "Something is wrong with the build of this commit", "FAILED", url,
      key, name);
      } else {
      status = new BitbucketBuildStatus(hash, "The tests have started...", "INPROGRESS", url, key, name);
      }
      

        

          [JENKINS-46250] Allow Bitbucket build status text to be overridden

          pixman20 created issue -
          pixman20 made changes -
          Summary Original: Allow Bitbucket build status text to be overridden New: Allow Bitbucket build status text to be disabled/overridden
          James Dumay made changes -
          Link New: This issue relates to JENKINS-35453 [ JENKINS-35453 ]

          Bitbucket Branch Source Plugin 2.2.4 makes Bitbucket display the job/branch name in addition to the build number.
          The other two parts of this issue have not been implemented, AFAICT.

          Kalle Niemitalo added a comment - Bitbucket Branch Source Plugin 2.2.4 makes Bitbucket display the job/branch name in addition to the build number. The other two parts of this issue have not been implemented, AFAICT.

          Nuno Costa added a comment -

          I was also interested in the feature of disabling the build status to be sent to Bitbucket.

          My use case is that I have a Jenkins local instance on my laptop, for testing purpuses and I want to avoid to send my build status to the projects.

          This way, BB would only display build status from the PROD Jenkins instance.

          Nuno Costa added a comment - I was also interested in the feature of disabling the build status to be sent to Bitbucket. My use case is that I have a Jenkins local instance on my laptop, for testing purpuses and I want to avoid to send my build status to the projects. This way, BB would only display build status from the PROD Jenkins instance.

          I likewise have separate Jenkins instances for production and testing. When both instances had projects with identical names, the testing instance (that had an agent in a slower machine) usually sent its notification later and overwrote the build status of the production instance in Bitbucket Server. I ended up selecting "Restrict project naming" in the testing instance and enforcing a prefix. Still, disabling the notifications would be a useful feature, so that problems in the testing instance don't show up as errors in the commit history in Bitbucket Server.

          I wonder if this issue should be split, though.

          • overriding the status text
          • adding the project/branch names to the link text (already done)
          • disabling build status notifications altogether (at Jenkins instance level or at project level?)
          • adding a Jenkins instance identifier to the notification key (low priority; workaround: change the project name)
          • adding a Jenkins instance identifier to the link text (low priority; workaround: change the project name)

          Kalle Niemitalo added a comment - I likewise have separate Jenkins instances for production and testing. When both instances had projects with identical names, the testing instance (that had an agent in a slower machine) usually sent its notification later and overwrote the build status of the production instance in Bitbucket Server. I ended up selecting "Restrict project naming" in the testing instance and enforcing a prefix. Still, disabling the notifications would be a useful feature, so that problems in the testing instance don't show up as errors in the commit history in Bitbucket Server. I wonder if this issue should be split, though. overriding the status text adding the project/branch names to the link text (already done) disabling build status notifications altogether (at Jenkins instance level or at project level?) adding a Jenkins instance identifier to the notification key (low priority; workaround: change the project name) adding a Jenkins instance identifier to the link text (low priority; workaround: change the project name)

          pixman20 added a comment -

          Agreed, I'm shrinking the scope of this issue to be only:

          • Overriding the status text

          This is currently the only issue within the scope of this plugin without any workaround as previously mentioned.  The not-so-proper workaround that I've had to do is to duplicate the java plugin code in groovy and use it as a shared library function in my pipeline code and call that whenever I want to update Bitbucket notifications.  This requires disabling the current notifications.

           

          Regarding that, I realize now disabling the build status notifications is outside the scope of this plugin and would need to be a separate plugin (I actually created one that I'm currently using, just need to publish it)

          pixman20 added a comment - Agreed, I'm shrinking the scope of this issue to be only: Overriding the status text This is currently the only issue within the scope of this plugin without any workaround as previously mentioned.  The not-so-proper workaround that I've had to do is to duplicate the java plugin code in groovy and use it as a shared library function in my pipeline code and call that whenever I want to update Bitbucket notifications.  This requires disabling the current notifications.   Regarding that, I realize now disabling the build status notifications is outside the scope of this plugin and would need to be a separate plugin (I actually created one that I'm currently using, just need to publish it)
          pixman20 made changes -
          Summary Original: Allow Bitbucket build status text to be disabled/overridden New: Allow Bitbucket build status text overridden
          pixman20 made changes -
          Summary Original: Allow Bitbucket build status text overridden New: Allow Bitbucket build status text to be overridden
          pixman20 made changes -
          Description Original: Currently the text sent to Bitbucket as build status for a commit is hardcoded with messages that could be misleading (such as "This commit has test failures") if the job uses build statuses differently (i.e. UNSTABLE happens to mean something else).  At the very least the text should say "The commit is unstable".

          [https://github.com/jenkinsci/bitbucket-branch-source-plugin/blob/master/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketBuildStatusNotifications.java#L73]

           
          {code:java}
          if (Result.SUCCESS.equals(result)) {
          status = new BitbucketBuildStatus(hash, "This commit looks good", "SUCCESSFUL", url, key, name);
          } else if (Result.UNSTABLE.equals(result)) {
          status = new BitbucketBuildStatus(hash, "This commit has test failures", "FAILED", url, key, name);
          } else if (Result.FAILURE.equals(result)) {
          status = new BitbucketBuildStatus(hash, "There was a failure building this commit", "FAILED", url, key,
          name);
          } else if (result != null) { // ABORTED etc.
          status = new BitbucketBuildStatus(hash, "Something is wrong with the build of this commit", "FAILED", url,
          key, name);
          } else {
          status = new BitbucketBuildStatus(hash, "The tests have started...", "INPROGRESS", url, key, name);
          }
          {code}
           

          Also, the URL display text in Bitbucket should be able to be overridden so that the build number is only the default.  This is especially important when marking the build status of a Pull Request, since it's commit hash might have 2 build status updates: 1 for the corresponding PR build and 1 for the corresponding branch build of the branch being PR'ed. 

          Currently when this happens, there are 2 links on the build status icon, but both are only a number.  The only way to tell which one is the PR build and which one is the branch build is by hovering over the URL to see where it goes.  Being able to override the link's text would help a user to know which link goes where.

          [https://github.com/jenkinsci/bitbucket-branch-source-plugin/blob/master/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketBuildStatusNotifications.java#L69]

           
          {code:java}
          String name = build.getDisplayName(); // use the build number as the display name of the status
          {code}
           

          Additionally, the notifications should also be able to be disabled.

           
          New: Currently the text sent to Bitbucket as build status for a commit is hardcoded with messages that could be misleading (such as "This commit has test failures") if the job uses build statuses differently (i.e. UNSTABLE happens to mean something else).  At the very least the text should say "The commit is unstable".

          [https://github.com/jenkinsci/bitbucket-branch-source-plugin/blob/master/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketBuildStatusNotifications.java#L73]

           
          {code:java}
          if (Result.SUCCESS.equals(result)) {
          status = new BitbucketBuildStatus(hash, "This commit looks good", "SUCCESSFUL", url, key, name);
          } else if (Result.UNSTABLE.equals(result)) {
          status = new BitbucketBuildStatus(hash, "This commit has test failures", "FAILED", url, key, name);
          } else if (Result.FAILURE.equals(result)) {
          status = new BitbucketBuildStatus(hash, "There was a failure building this commit", "FAILED", url, key,
          name);
          } else if (result != null) { // ABORTED etc.
          status = new BitbucketBuildStatus(hash, "Something is wrong with the build of this commit", "FAILED", url,
          key, name);
          } else {
          status = new BitbucketBuildStatus(hash, "The tests have started...", "INPROGRESS", url, key, name);
          }
          {code}
            

            Unassigned Unassigned
            pixman20 pixman20
            Votes:
            5 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated: