Hello all!
Short descriptions:
I have a problem with displaying the latest Jenkins builds on the Bitbucket Cloud PR pages - sometimes Bitbucket displays non-last build (e.g. latest build is #5, but bitbucket displays #3).
System description:
The project I'm working on is located on Bitbucket Cloud (bitbucket.org).
The project builds are done using self-hosted Jenkins.
Communication between BB and Jenkins is done using Bitbucket Branch Source Plugin (ver: 734.v2f848c5e6ea2). Also, there is Bitbucket Pipeline for Blue Ocean plugin installed (not sure, if that matters).
One more thing.
During Jenkins build, Jenkins Pipeline code adds one more build object to a PR - it is used to display if a PR has the latest base branch merged in.
It is done via BB API.
So the PR has two different builds displayed at once.
Long description of the problem:
The problem occurs not for all builds and I don't see any regularity in it...
When a non-first (e.g. there already were builds for a PR) build is done on Jenkins, Bitbucket might display a link to a previous build.
In addition, we have slack notifications set for build results and they also show strange things.
The notifications are sent using the Bitbucket Cloud app.
Sometimes, when a build is done on Jenkins, a notification is sent to Slack, but that notification contains info about some old/previous build
Example
A PR has 5 Jenkins builds and a few commits.
However, Bitbucket displayed results of build #3 (failed one), instead of build number #5 (a successful one)
It appeared that the problem was in a backup Jenkins instance being (by coincidence/mistake) executed on another machine (simultaneously with the main Jenkins instance).