I got around this issue by creating this function in our Global Pipeline Library and calling it at the beginning of each pipeline I have.
def call(buildId, jobName) {
if ("${buildId}" == "1") {
build job: "${jobName}", wait: false
currentBuild.result = 'ABORTED'
error("Skipping build ${buildId} as it doesn't play nice with bitbucket notifications")
}
}
And it's called with this line in the Pipeline
script {
rerunBuildOne(env.BUILD_ID, env.JOB_NAME)
}
It's pretty crude, but all is does is abort the build and start a new build for the same job if it's the first build. Which fixes the issue while I wait for this bug to be fixed.
Also if it helps I've noticed that the commit ID that the notifier is supplying to BitBucket is the same commit ID as my Global Pipeline Library repository instead of the commit for the code being built. This explains why BitBucket says that it can't find the commit for the given repo, and will hopefully give you an easier way to recreate the bug.
stephenconnolly probably would have a better idea than anyone else.