Jenkins erroneously deleted all builds in one multibranch pipeline

Hi,

We have a local Jenkins server that builds multiple repos under multiple Bitbucket projects. I didn’t set it up, but as far as I can tell, we have a few organizational folders for projects, and each repo has a Jenkinsfile (declarative) driving the Jenkins build.

At some point mid April, only for one of these organizational folders, Jenkins deleted all the builds in the respective histories. Some of the repos use the build number Jenkins provides to generate a build number, so it was quite confusing to go from version x.y.0.61 to x.y.0.1. Now, I’ve checked the logs and only noticed this warning:

2022-04-17 05:17:12.328+0000 [id=3741] WARNING c.c.j.p.b.h.WebhookAutoRegisterListener$1#doRun: Could not register hooks for /

But that log message also shows up for other projects and repos where the builds haven’t been erased.

My question is: how can I investigate this situation? Would Jenkins leave any sort of explanation for this in the logs? Or maybe is there something else I can check?

I’ve tried googling for this, but I only managed to find instructions on how to delete the build history, or configure the number of builds to discard.

We’re running Jenkins 2.319.1 on Linux (Ubuntu 20.04).

That seems similar to https://github.com/jenkinsci/bitbucket-branch-source-plugin/issues/476. Are you using Bitbucket Cloud?

@kon we don’t seem to be using Bitbucket Cloud (the dropdown in our organized folder configuration says “Bitbucket Server (<internal_server>)”).

I see the issue you’ve mentioned says in their case the jobs also get deleted. In our case, the jobs were still there, it’s just the builds that had vanished. But also from that bug I see it would’ve been useful to look at the “Scan Organization Folder Log” when this happened, I’ll keep that in mind.

If only the builds had been deleted, I think the next build number would not have been reset. I think it’s more likely that the organization folder scan failed and deleted the jobs, and then a subsequent scan created the jobs again.

Understood. Is there a way to see other organization folder scan logs besides the last one?

I don’t really have experience with organisation folders and don’t know how much logs they save.

I’ve asked inside our organization, and it seems others have seen this as well. They did suggest one workaround: setting the “Orphaned Item Strategy → Days to keep old items” to something non-zero, like 1 day.

Reference:
https://issues.jenkins.io/browse/JENKINS-36029?focusedCommentId=272281&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-272281