It would be great if Bitbucket Build Status Notifier would support pipeline builds. There don't seem to be any way to use the Bitbucket Build Status Notifier plugin with the pipeline build that was added in Jenkins 2.0.

          [JENKINS-33841] Support for pipeline builds

          Hello itaisanders

          I notice that you have a status notification message in the logs

          Sending build status INPROGRESS for commit 4e7eb185a08b8b5cb1775c31d26f3f05cbaa8bbc to BitBucket is done!
          Sending build status SUCCESSFUL for commit 4e7eb185a08b8b5cb1775c31d26f3f05cbaa8bbc to BitBucket is done!
          

          what looks really good, but my build doesn't issue even anything close to that, I have just:

          Proceeding
          [Pipeline] bitbucketStatusNotify
          [Pipeline] stage (Checkout)
          
          

          and even more strange - error in the end

          [Pipeline] bitbucketStatusNotify
          [Pipeline] }
          [Pipeline] // node
          [Pipeline] End of Pipeline
          java.lang.NullPointerException
          	at org.jenkinsci.plugins.bitbucket.BitbucketBuildStatusNotifierStep$Execution.run(BitbucketBuildStatusNotifierStep.java:191)
          	at org.jenkinsci.plugins.bitbucket.BitbucketBuildStatusNotifierStep$Execution.run(BitbucketBuildStatusNotifierStep.java:140)
          	at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1$1.call(AbstractSynchronousNonBlockingStepExecution.java:52)
          	at hudson.security.ACL.impersonate(ACL.java:213)
          	at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:49)
          	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
          	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
          	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
          	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
          	at java.lang.Thread.run(Thread.java:745)
          Finished: FAILURE
          

          Can you please suggest what I might be missing? The only difference I can see between my and sample config is that I'm fetching code with credentials:

              checkout([$class: 'GitSCM', branches: [[name: env.BRANCH_NAME]], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'c6bcc00a-8dea-4671-bdd3-8335a959d610', url: 'git@bitbucket.xxx/xxx.git']]])
          
          

          Yevhenii Kurtov added a comment - Hello itaisanders I notice that you have a status notification message in the logs Sending build status INPROGRESS for commit 4e7eb185a08b8b5cb1775c31d26f3f05cbaa8bbc to BitBucket is done! Sending build status SUCCESSFUL for commit 4e7eb185a08b8b5cb1775c31d26f3f05cbaa8bbc to BitBucket is done! what looks really good, but my build doesn't issue even anything close to that, I have just: Proceeding [Pipeline] bitbucketStatusNotify [Pipeline] stage (Checkout) and even more strange - error in the end [Pipeline] bitbucketStatusNotify [Pipeline] } [Pipeline] // node [Pipeline] End of Pipeline java.lang.NullPointerException at org.jenkinsci.plugins.bitbucket.BitbucketBuildStatusNotifierStep$Execution.run(BitbucketBuildStatusNotifierStep.java:191) at org.jenkinsci.plugins.bitbucket.BitbucketBuildStatusNotifierStep$Execution.run(BitbucketBuildStatusNotifierStep.java:140) at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1$1.call(AbstractSynchronousNonBlockingStepExecution.java:52) at hudson.security.ACL.impersonate(ACL.java:213) at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:49) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang. Thread .run( Thread .java:745) Finished: FAILURE Can you please suggest what I might be missing? The only difference I can see between my and sample config is that I'm fetching code with credentials: checkout([$class: 'GitSCM' , branches: [[name: env.BRANCH_NAME]], doGenerateSubmoduleConfigurations: false , extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'c6bcc00a-8dea-4671-bdd3-8335a959d610' , url: 'git@bitbucket.xxx/xxx.git' ]]])

          Itai Sanders added a comment -

          lessless: I need to see the pipeline code to be certain, but from the snippet you posted it seems like you activated the bitbucketnotifier before the checkout stage.

          Proceeding
          [Pipeline] bitbucketStatusNotify
          [Pipeline] stage (Checkout)
          

          the notifier is looking for the scm object instance, which in pipelines (unlike the freestyle jobs) is only initiated when you go through the scm checkout step, so basically you are calling for bitbucketnotifier with an uninitiated (null) scm object.
          it might be best if the plugin catches this and posts a more friendly exception message. maybe I'll look into it and post another pull request later if no one gets to it.

          let me know if placing the scm checkout before the bitbucketnotifier step worked or it's something else entirely.

          Itai Sanders added a comment - lessless : I need to see the pipeline code to be certain, but from the snippet you posted it seems like you activated the bitbucketnotifier before the checkout stage. Proceeding [Pipeline] bitbucketStatusNotify [Pipeline] stage (Checkout) the notifier is looking for the scm object instance, which in pipelines (unlike the freestyle jobs) is only initiated when you go through the scm checkout step, so basically you are calling for bitbucketnotifier with an uninitiated (null) scm object. it might be best if the plugin catches this and posts a more friendly exception message. maybe I'll look into it and post another pull request later if no one gets to it. let me know if placing the scm checkout before the bitbucketnotifier step worked or it's something else entirely.

          Yevhenii Kurtov added a comment - - edited

          Hi itaisanders

          thank you for the tip, this is my first experience with Jenkins, so pretty frustrated atm due to the setup complexity.
          I tried to `checkout scm` before setting status, but change.
          Here is the script itself:

          node {
              deleteDir()
              checkout scm
              bitbucketStatusNotify(buildState: 'INPROGRESS')
              sleep 10 
              bitbucketStatusNotify (buildState: 'SUCCESSFUL')
          }
          

          and console output

          Started by user lessless
          Replayed #2
          Setting origin to git@bitbucket.org:team/proj.git
          Fetching origin...
          [Pipeline] node
          Running on master in /var/lib/jenkins/workspace/proj/feature%2Fadd-jenkinsfile
          [Pipeline] {
          [Pipeline] deleteDir
          [Pipeline] checkout
          Cloning the remote Git repository
          Cloning repository git@bitbucket.org:team/proj.git
           > git init /var/lib/jenkins/workspace/proj/feature%2Fadd-jenkinsfile # timeout=10
          Fetching upstream changes from git@bitbucket.org:team/proj.git
           > git --version # timeout=10
          using GIT_SSH to set credentials 
           > git -c core.askpass=true fetch --tags --progress git@bitbucket.org:team/proj.git  +refs/heads/*:refs/remotes/origin/*
           > git config remote.origin.url git@bitbucket.org:team/proj.git # timeout=10
           > git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10
           > git config remote.origin.url git@bitbucket.org:team/proj.git # timeout=10
          Fetching upstream changes from git@bitbucket.org:team/proj.git
          using GIT_SSH to set credentials 
           > git -c core.askpass=true fetch --tags --progress git@bitbucket.org:team/proj.git +refs/heads/*:refs/remotes/origin/*
          Checking out Revision 7911cc863d326253d1333cc899a837883dced255 (feature/add-jenkinsfile)
           > git config core.sparsecheckout # timeout=10
           > git checkout -f 7911cc863d326253d1333cc899a837883dced255
           > git rev-list 7911cc863d326253d1333cc899a837883dced255 # timeout=10
          [Pipeline] bitbucketStatusNotify
          [Pipeline] }
          [Pipeline] // node
          [Pipeline] End of Pipeline
          java.lang.Exception: Credentials could not be found!
          	at org.jenkinsci.plugins.bitbucket.BitbucketBuildStatusHelper.sendBuildStatusNotification(BitbucketBuildStatusHelper.java:262)
          	at org.jenkinsci.plugins.bitbucket.BitbucketBuildStatusHelper.notifyBuildStatus(BitbucketBuildStatusHelper.java:252)
          	at org.jenkinsci.plugins.bitbucket.BitbucketBuildStatusNotifierStep$Execution.run(BitbucketBuildStatusNotifierStep.java:189)
          	at org.jenkinsci.plugins.bitbucket.BitbucketBuildStatusNotifierStep$Execution.run(BitbucketBuildStatusNotifierStep.java:140)
          	at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1$1.call(AbstractSynchronousNonBlockingStepExecution.java:52)
          	at hudson.security.ACL.impersonate(ACL.java:213)
          	at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:49)
          	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
          	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
          	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
          	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
          	at java.lang.Thread.run(Thread.java:745)
          Finished: FAILURE
          
          

          Yevhenii Kurtov added a comment - - edited Hi itaisanders thank you for the tip, this is my first experience with Jenkins, so pretty frustrated atm due to the setup complexity. I tried to `checkout scm` before setting status, but change. Here is the script itself: node { deleteDir() checkout scm bitbucketStatusNotify(buildState: 'INPROGRESS' ) sleep 10 bitbucketStatusNotify (buildState: 'SUCCESSFUL' ) } and console output Started by user lessless Replayed #2 Setting origin to git@bitbucket.org:team/proj.git Fetching origin... [Pipeline] node Running on master in / var /lib/jenkins/workspace/proj/feature%2Fadd-jenkinsfile [Pipeline] { [Pipeline] deleteDir [Pipeline] checkout Cloning the remote Git repository Cloning repository git@bitbucket.org:team/proj.git > git init / var /lib/jenkins/workspace/proj/feature%2Fadd-jenkinsfile # timeout=10 Fetching upstream changes from git@bitbucket.org:team/proj.git > git --version # timeout=10 using GIT_SSH to set credentials > git -c core.askpass= true fetch --tags --progress git@bitbucket.org:team/proj.git +refs/heads/*:refs/remotes/origin/* > git config remote.origin.url git@bitbucket.org:team/proj.git # timeout=10 > git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10 > git config remote.origin.url git@bitbucket.org:team/proj.git # timeout=10 Fetching upstream changes from git@bitbucket.org:team/proj.git using GIT_SSH to set credentials > git -c core.askpass= true fetch --tags --progress git@bitbucket.org:team/proj.git +refs/heads/*:refs/remotes/origin/* Checking out Revision 7911cc863d326253d1333cc899a837883dced255 (feature/add-jenkinsfile) > git config core.sparsecheckout # timeout=10 > git checkout -f 7911cc863d326253d1333cc899a837883dced255 > git rev-list 7911cc863d326253d1333cc899a837883dced255 # timeout=10 [Pipeline] bitbucketStatusNotify [Pipeline] } [Pipeline] // node [Pipeline] End of Pipeline java.lang.Exception: Credentials could not be found! at org.jenkinsci.plugins.bitbucket.BitbucketBuildStatusHelper.sendBuildStatusNotification(BitbucketBuildStatusHelper.java:262) at org.jenkinsci.plugins.bitbucket.BitbucketBuildStatusHelper.notifyBuildStatus(BitbucketBuildStatusHelper.java:252) at org.jenkinsci.plugins.bitbucket.BitbucketBuildStatusNotifierStep$Execution.run(BitbucketBuildStatusNotifierStep.java:189) at org.jenkinsci.plugins.bitbucket.BitbucketBuildStatusNotifierStep$Execution.run(BitbucketBuildStatusNotifierStep.java:140) at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1$1.call(AbstractSynchronousNonBlockingStepExecution.java:52) at hudson.security.ACL.impersonate(ACL.java:213) at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:49) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang. Thread .run( Thread .java:745) Finished: FAILURE

          Itai Sanders added a comment -

          lessless now you have a Credentials not Found exception. did you set them in the Jenkins Global Configurations?

          if you want some general help with Jenkins maybe it will be better to move to a more general platform e.g. https://devopsengineers.slack.com/archives/jenkins-ci (once there, feel free to pm me if you'd like. although I do follow the jenkins-ci channel anyway)

          Itai Sanders added a comment - lessless now you have a Credentials not Found exception. did you set them in the Jenkins Global Configurations? if you want some general help with Jenkins maybe it will be better to move to a more general platform e.g. https://devopsengineers.slack.com/archives/jenkins-ci (once there, feel free to pm me if you'd like. although I do follow the jenkins-ci channel anyway)

          Before I used generated snippet to checkout the repository,

          checkout([$class: 'GitSCM', branches: [[name: 'master']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'c6bcc00a-8dea-4671-bdd3-8335a959d610', url: 'git@bitbucket.org:org/proj.git']]])
          

          but changed it to the `checkout scm` to fully reproduce your snippet.

          Yevhenii Kurtov added a comment - Before I used generated snippet to checkout the repository, checkout([$class: 'GitSCM' , branches: [[name: 'master' ]], doGenerateSubmoduleConfigurations: false , extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'c6bcc00a-8dea-4671-bdd3-8335a959d610' , url: 'git@bitbucket.org:org/proj.git' ]]]) but changed it to the `checkout scm` to fully reproduce your snippet.

          Itai Sanders added a comment -

          lessless I think you are gettin mixed up.
          you need to provide credentials to your repository in order to access it.

          you can either:
          1. provide them in the job configurations (and place the Jenkinsfile inside the scm), in which case you can simply call on 'scm checkout' to checkout the entire code. Jenkins then will use the credentials you used to access the Jenkinsfile in order to checkout that same repo.
          2. provide them inside the checkout call, as you first did, in case you are writing your pipeline code inside Jenkins (so you never configured the scm in the job configurations) or in case you wish to checkout a different repo than the one you used to store the Jenkinsfile.

          either way, you will still need to provide the notifier plugin with the credentials to mark the build status. you configure it inside the Jenkins Configure System (inside Manage Jenkins, not in the specific job). you will need to produce a dedicated OAuth credentials.

          this and more you can find in the very good README in github: https://github.com/jenkinsci/bitbucket-build-status-notifier-plugin

          and again - this is getting much more general than the discussed issue. you should raise those questions in Slack, or if you want you can Telegram me and I wouldn't mind helping you out as far as I can.

          Itai Sanders added a comment - lessless I think you are gettin mixed up. you need to provide credentials to your repository in order to access it. you can either: 1. provide them in the job configurations (and place the Jenkinsfile inside the scm), in which case you can simply call on 'scm checkout' to checkout the entire code. Jenkins then will use the credentials you used to access the Jenkinsfile in order to checkout that same repo. 2. provide them inside the checkout call, as you first did, in case you are writing your pipeline code inside Jenkins (so you never configured the scm in the job configurations) or in case you wish to checkout a different repo than the one you used to store the Jenkinsfile. either way, you will still need to provide the notifier plugin with the credentials to mark the build status. you configure it inside the Jenkins Configure System (inside Manage Jenkins, not in the specific job). you will need to produce a dedicated OAuth credentials. this and more you can find in the very good README in github: https://github.com/jenkinsci/bitbucket-build-status-notifier-plugin and again - this is getting much more general than the discussed issue. you should raise those questions in Slack, or if you want you can Telegram me and I wouldn't mind helping you out as far as I can.

          Could we merge the pull request of itaisanders for Pipeline Multibranch Support: https://github.com/jenkinsci/bitbucket-build-status-notifier-plugin/pull/30?

          Allan BURDAJEWICZ added a comment - Could we merge the pull request of itaisanders for Pipeline Multibranch Support: https://github.com/jenkinsci/bitbucket-build-status-notifier-plugin/pull/30?

          Itai Sanders added a comment -

          that would be great allan_burdajewicz!

          btw, I didn't get to test it myself (since I am using my locally compiled merged version), but I think if you don't use the default parameters of the plugin and define your own legal parameters manually, you would work around this bug (along with the "key per job and not per build" sort-of-a-bug).

          Itai Sanders added a comment - that would be great allan_burdajewicz ! btw, I didn't get to test it myself (since I am using my locally compiled merged version), but I think if you don't use the default parameters of the plugin and define your own legal parameters manually, you would work around this bug (along with the "key per job and not per build" sort-of-a-bug).

          Is there a way, in a pipeline build, to override the global oauth credentials?

          Jonathan Baker added a comment - Is there a way, in a pipeline build, to override the global oauth credentials?

          Code changed in jenkins
          User: Jesse Glick
          Path:
          COMPATIBILITY.md
          http://jenkins-ci.org/commit/pipeline-plugin/c84a9af380854dbafd66e265b63cd05969ad7c47
          Log:
          Merge pull request #439 from alexbrjo/alexbrjo-compat-update

          JENKINS-32263 JENKINS-32650 JENKINS-33841 JENKINS-33310 JENKINS-26591 JENKINS-30522 Updated support status for several plugins

          Compare: https://github.com/jenkinsci/pipeline-plugin/compare/23d473486c8e...c84a9af38085

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: COMPATIBILITY.md http://jenkins-ci.org/commit/pipeline-plugin/c84a9af380854dbafd66e265b63cd05969ad7c47 Log: Merge pull request #439 from alexbrjo/alexbrjo-compat-update JENKINS-32263 JENKINS-32650 JENKINS-33841 JENKINS-33310 JENKINS-26591 JENKINS-30522 Updated support status for several plugins Compare: https://github.com/jenkinsci/pipeline-plugin/compare/23d473486c8e...c84a9af38085

            flagbit Antonio Mansilla
            sajfer Anton Bretting
            Votes:
            8 Vote for this issue
            Watchers:
            18 Start watching this issue

              Created:
              Updated:
              Resolved: