Bitbucket (on premise) is showing wrong Jenkins build status in PR - green but still running

Viewed 919

Setup

I have a bitbucket server (6.2.0) and a Jenkins (2.190) build server.

On Jenkins side I have a Bitbucket Team/Project (delivered by https://github.com/jenkinsci/bitbucket-branch-source-plugin).

Issue

Sometimes the bitbucket build status of the PullRequest is not correct. E.g. a build is currently running and bitbucket says it's a successful build. It links to to the "success" build in Jenkins but this build is still running.

Did I understand anything wrong or is this a bug?

1 Answers

I found the issue. The issue was with the Jenkinsfile. In the very beginning I had this line in my scripted Jenkinsfile:

currentBuild.result = "SUCCESS"

At the end I corrected this status to FAILURE if neccessary. So I removed this line in the beginning.

But it seems that a "Bitbucket Team project" send this status as soon as it's set back to Bitbucket.

I was missleaded by other code old snippets in our Jenkinsfile like

notifyBitbucket(buildStatus: 'INPROGRESS')

which had no effect on Bitbucket and are legacy from bitbucketNotifier Plugin (https://github.com/jenkinsci/stashnotifier-plugin)

The only thing what I don't like that in jenkins the running build is red initially but who wants to see the jenkins as long it is green in the end and bitbucket has the right status ;-): enter image description here

Related