| I have an idea for a workaround for this that I want to try out: write a Groovy script that is executed periodically as part of a pipeline (through the Jenkins CLI to get the necessary permissions) and scans the deleted pull requests/branches that are in the grace period in which they have not been deleted yet from the Jenkins multiproject folder. If I can get that list, it would be easy to then idempotently run cleanup jobs. They won't run as soon as the pull request/branch is gone, but the frequency of this cleanup can be tuned. I use a similar approach to clean up old agents: https://github.com/elifesciences/elife-alfred-formula/blob/master/jenkinsfiles/ec2-plugin-nodes-retirement.groovy although here it's more difficult to understand the API to traverse and whether it's possible to list all of these. |