5

I am attempting to implement the Jenkins bitbucket-build-status-notifier-plugin, found here: https://github.com/jenkinsci/bitbucket-build-status-notifier-plugin

We used the shared-pipeline code functionality of Jenkinsfile, along with multibranch pipelines- all our Jenkinsfile code lives in one repo and each application makes only a parameterized call to a function in this repo.
The problem comes when the plugin posts status- it posts to the repo of the shared pipeline code, not the application being built! It is otherwise working correctly, authenticating and posting status quickly.

The plugin is not parameterized to allow me to pass in a commit ID- meaning that this is being derived from an environment variable, presumably in a novel way that other plugins are not using. The plugin specifically cites changes to facilitate Jenkinsfile and multi-branch pipelines. I suspect I may have a race condition with the scm checkout command, perhaps the bitbucket plugin is being initialized before any call to scm checkout is made?

Does anyone have any advice on debugging this? jenkins.err does not contain any errors, since nothing is throwing. Is there an environment variable I can change in order to force a context switch from the shared pipeline code repo to the application code repo?

4

This is a known bug. See JENKINS-42878 and JENKINS-41996. This bug has been resolved upstream, which means you should be able to fix the bug by upgrading the plugin to the latest version.

  • Thanks for responding. I am using the latest version of this plugin - both of these bugs appear to reference the issue I am having, but only as an incidental side effect, and I suspect that this fix may not have been verified. This is good background on the issue though- thank you! I am unclear how a plugin with thousands of monthly downloads could have such a glaring issue with no open bugs! – esoterydactyl Oct 28 '17 at 1:39
2

Based on this PR, the repoSlug was added and now the status is sent to the right repository.

When it was not working:

post {
    success {
        bitbucketStatusNotify(
                buildState: 'SUCCESSFUL',
                commitId: env.GIT_COMMIT
        )
    }
    failure {
        bitbucketStatusNotify(
                buildState: 'FAILED',
                commitId: env.GIT_COMMIT
        )
    }
}

Now it works:

post {
    success {
        bitbucketStatusNotify(
                buildState: 'SUCCESSFUL',
                repoSlug: 'repoSlug aka repositoryName, e.g. some-app',
                commitId: env.GIT_COMMIT
        )
    }
    failure {
        bitbucketStatusNotify(
                buildState: 'FAILED',
                repoSlug: 'repoSlug aka repositoryName, e.g. some-app',
                commitId: env.GIT_COMMIT
        )
    }
}

The README in the Github repo emphasized that:

Note that the repoSlug and commitId parameters work only when they are both specified.

  • 1
    repoSlug is simply the name of the repository, I wasted a couple of hours until I figured this out. So if you have this repo: bitbucket.org/company/saas-frontend. The reposlug would be: saas-frontend – Shachar Hamuzim Rajuan Sep 3 at 8:47
  • 1
    @ShacharHamuzimRajuan Yes that is true. I will update the answer. – 030 Sep 3 at 10:31
0

One could also use bcbsn as a replacement. This tool associates the build status with the right commit and sends the build status to the right repository.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.