Status: Resolved (View Workflow)
Jenkins ver. 2.40
Bitbucket Branch Source Plugin 2.0.2
Atlassian Bitbucket (server) v4.6.0
We use bitbucket server (former known as stash) to internally host a bunch of repos.
We have a number of "Bitbucket Team/Project" items set up. These map one to one with bitbucket server projects, and each one scans all of the repos (and their branches), looking for Jenkinsfiles and creating subitems for each repo (and branch). It also deletes branches (and I assume repos) when the branches and repos go away. This is all pretty sweet.
Then our Bitbucket Server "went down" (the JVM locked up) and we kicked it to get it fired back up. We found that almost all of the corresponding entities (repos and branches) had been deleted from our jenkins instance. We suspect that the repos that were not deleted were preserved because they were building in Jenkins at the time of the Bitbucket Server outage.
One of the negative outcomes from this is that all of our repos have been re-created in jenkins and the branches are starting with build 1. This isn't cool because we use the BUILD_TAG environment variable to uniquely identity build artifacts in various artifact repositories. So now our builds are all failing because jenkins-blah-master-1 "is already taken" and so on.
I'm not sure this would happen whenever Bitbucket server goes offline (I hope not), so I didn't mark this critical.
Under the configuration for our "Bitbucket Team/Project" items, we have "Discard old items" checked under "Orphaned Item Strategy". "Days to keep old items" was set to 2 and "Max # of old items to keep" was set to 0. I'm not sure what either of these mean, since branches seem to be deleted from jenkins immediately when they are deleted from source control. We've updated "Max # of old items to keep" to 2, hoping that this might help avert a similar disaster in the future, but have no evidence that it would.
JENKINS-36029 multibranch-job deleted when bitbucket communication fails
JENKINS-36029, which looks close enough. sorry!