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

First time builds are not reporting to Bitbucket

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      I'm using this plugin with a Multibranch Pipeline for reporting the status of a build to Bitbucket. The issue I'm seeing is that the first time a branch is built, the status is not being sent. I can see in the log that it does call the plugin, but the log that says that posting the status succeeded does not show up. Each time a build is run after the first run works as expected.

        Attachments

          Activity

          Hide
          cschwarz Christoph Schwarz added a comment -

          We too suffer from this annoying problem. Just like Antonio mentioned in August, the problem is the call to WorkflowJob.getSCMs() of workflow-job-2.15.jar. This method gets the SCMs from the last successful build or the last completed build. Obviously, for the first build on a branch there isn't either. So it does not return any SCM information, hence Bitbucket status notifier does not notify any SCM. So this might be a problem of the workflow-job plugin after all.

              @Override public Collection<? extends SCM> getSCMs() {
                  WorkflowRun b = getLastSuccessfulBuild();
                  if (b == null) {
                      b = getLastCompletedBuild();
                  }
                  if (b == null) {
                      return Collections.emptySet();
                  }
                  Map<String,SCM> scms = new LinkedHashMap<>();
                  for (WorkflowRun.SCMCheckout co : b.checkouts(null)) {
                      scms.put(co.scm.getKey(), co.scm);
                  }
                  return scms.values();
              }
          

          As for the proposal to use the SCMRevisionAction.getRevision() method : it does not seem to yield enough information. The plugin needs userName and repoName of the repository in addition to the commit hash.

          Show
          cschwarz Christoph Schwarz added a comment - We too suffer from this annoying problem. Just like Antonio mentioned in August, the problem is the call to WorkflowJob.getSCMs() of workflow-job-2.15.jar. This method gets the SCMs from the last successful build or the last completed build. Obviously, for the first build on a branch there isn't either. So it does not return any SCM information, hence Bitbucket status notifier does not notify any SCM. So this might be a problem of the workflow-job plugin after all. @Override public Collection<? extends SCM> getSCMs() { WorkflowRun b = getLastSuccessfulBuild(); if (b == null ) { b = getLastCompletedBuild(); } if (b == null ) { return Collections.emptySet(); } Map< String ,SCM> scms = new LinkedHashMap<>(); for (WorkflowRun.SCMCheckout co : b.checkouts( null )) { scms.put(co.scm.getKey(), co.scm); } return scms.values(); } As for the proposal to use the SCMRevisionAction.getRevision() method : it does not seem to yield enough information. The plugin needs userName and repoName of the repository in addition to the commit hash.
          Hide
          gaieges Evin Callahan added a comment -

          Christoph Schwarz if it helps at all, we moved over to the Bitbucket source branch plugin, and it does the start / finish / failure notifications without even having to think about it (including solving this issue).

          https://wiki.jenkins.io/display/JENKINS/Bitbucket+Branch+Source+Plugin

          Show
          gaieges Evin Callahan added a comment - Christoph Schwarz if it helps at all, we moved over to the Bitbucket source branch plugin, and it does the start / finish / failure notifications without even having to think about it (including solving this issue). https://wiki.jenkins.io/display/JENKINS/Bitbucket+Branch+Source+Plugin
          Hide
          030 030 030 added a comment -

          Any update on this issue? Is there anything I can do in order to help?

          Show
          030 030 030 added a comment - Any update on this issue? Is there anything I can do in order to help?
          Hide
          030 030 030 added a comment -
          Show
          030 030 030 added a comment - I created another plugin, see https://github.com/030/golang-bitbucket-cloud-build-status-notifier
          Hide
          joesolly Joseph Solomon added a comment -

          Why do we need to fetch previous build scm values here https://github.com/jenkinsci/bitbucket-build-status-notifier-plugin/blob/df373d0ae3ac32a5337c1c002505dee0c85ff5b0/src/main/java/org/jenkinsci/plugins/bitbucket/BitbucketBuildStatusHelper.java#L142?

          Couldn't we replace this line with 

          Map<String,SCM> scm_map = new LinkedHashMap<>();
          for (WorkflowRun.SCMCheckout co : build.checkouts(null)) {
              scm_map.put(co.scm.getKey(), co.scm);
          }
          Collection<? extends SCM> scms = scm_map.values()
          
          Show
          joesolly Joseph Solomon added a comment - Why do we need to fetch previous build scm values here https://github.com/jenkinsci/bitbucket-build-status-notifier-plugin/blob/df373d0ae3ac32a5337c1c002505dee0c85ff5b0/src/main/java/org/jenkinsci/plugins/bitbucket/BitbucketBuildStatusHelper.java#L142 ? Couldn't we replace this line with  Map< String ,SCM> scm_map = new LinkedHashMap<>(); for (WorkflowRun.SCMCheckout co : build.checkouts( null )) { scm_map.put(co.scm.getKey(), co.scm); } Collection<? extends SCM> scms = scm_map.values()

            People

            Assignee:
            flagbit Antonio Mansilla
            Reporter:
            ethanfrogers Ethan Rogers
            Votes:
            7 Vote for this issue
            Watchers:
            19 Start watching this issue

              Dates

              Created:
              Updated: