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

First time builds are not reporting to Bitbucket

    XMLWordPrintable

Details

    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

          030 030 030 added a comment -

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

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

          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()
          
          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()
          kevstev01 Kevin Stevens added a comment -

          I copied the workaround to fail on first build to get around this bug, but changed the status to NOT_BUILT and added a re-trigger of the build by adding the following stage

          stage('conditional abort first build') {
              when {
                  expression { "${env.BUILD_NUMBER}" == "1" }
              }
              steps {
                  echo "Aborting first build to workaround bitbucketStatusNotify issue"
                  /* re-trigger this build job */
                  build job: "${env.JOB_NAME}", wait: false
                  script {
                      currentBuild.result = 'NOT_BUILT'
                      return
                  }
              }
          }
              
          
          kevstev01 Kevin Stevens added a comment - I copied the workaround to fail on first build to get around this bug, but changed the status to NOT_BUILT and added a re-trigger of the build by adding the following stage stage( 'conditional abort first build' ) { when { expression { "${env.BUILD_NUMBER}" == "1" } } steps { echo "Aborting first build to workaround bitbucketStatusNotify issue" /* re-trigger this build job */ build job: "${env.JOB_NAME}" , wait: false script { currentBuild.result = 'NOT_BUILT' return } } }
          sc_rsc Stefan Cordes added a comment -

          In the first commit on a jenkins multibranch pipeline with Bitbucket Build Status Notifier Plugin Version 1.4.2 is not send to bitbucket:

           

          07:35:28  bitbucketStatusNotify:bitBucketBuildState=SUCCESSFUL bitBucketBuildRepoSlug=mule-cloudhub-* bitBucketBuildCommitId=c8690ed048aaa86493097ee844d8d44de9846fa3
          [Pipeline] bitbucketStatusNotify
          [Pipeline] echo
          07:35:28  cleanupStep:start 

          second (manual) build show it twice

          11:39:30  bitbucketStatusNotify:bitBucketBuildState=SUCCESSFUL bitBucketBuildRepoSlug=mule-cloudhub-* bitBucketBuildCommitId=c8690ed048aaa86493097ee844d8d44de9846fa3
          [Pipeline] bitbucketStatusNotify
          11:39:31  Sending build status SUCCESSFUL for commit c8690ed048aaa86493097ee844d8d44de9846fa3 to BitBucket is done!
          11:39:31  Sending build status SUCCESSFUL for commit c8690ed048aaa86493097ee844d8d44de9846fa3 to BitBucket is done!
          [Pipeline] echo
          11:39:31  cleanupStep:start 

           

           

          sc_rsc Stefan Cordes added a comment - In the first commit on a jenkins multibranch pipeline with Bitbucket Build Status Notifier Plugin Version 1.4.2 is not send to bitbucket:   07:35:28 bitbucketStatusNotify:bitBucketBuildState=SUCCESSFUL bitBucketBuildRepoSlug=mule-cloudhub-* bitBucketBuildCommitId=c8690ed048aaa86493097ee844d8d44de9846fa3 [Pipeline] bitbucketStatusNotify [Pipeline] echo 07:35:28 cleanupStep:start second (manual) build show it twice 11:39:30 bitbucketStatusNotify:bitBucketBuildState=SUCCESSFUL bitBucketBuildRepoSlug=mule-cloudhub-* bitBucketBuildCommitId=c8690ed048aaa86493097ee844d8d44de9846fa3 [Pipeline] bitbucketStatusNotify 11:39:31 Sending build status SUCCESSFUL for commit c8690ed048aaa86493097ee844d8d44de9846fa3 to BitBucket is done! 11:39:31 Sending build status SUCCESSFUL for commit c8690ed048aaa86493097ee844d8d44de9846fa3 to BitBucket is done! [Pipeline] echo 11:39:31 cleanupStep:start    

          People

            flagbit Antonio Mansilla
            ethanfrogers Ethan Rogers
            Votes:
            11 Vote for this issue
            Watchers:
            23 Start watching this issue

            Dates

              Created:
              Updated: