Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins not deleting old branches from multibranch pipeline

Tags:

jenkins

When scanning my multibranch pipeline, I am expecting old branches that are deleted from bitbucket to get deleted in Jenkins. This is the output of scanning my pipeline:

Evaluating orphaned items in *****
Will remove ****
Will remove ****
Finished: NOT_BUILT

But it doesn't remove the branches.

I have Prune setup and orphaned setting are all set to empty

Edit: Tried to add extensions: [[$class: 'PruneStaleBranch']] to my checkout step, it still doesn't remove old branches

like image 400
DevOps QA Avatar asked Oct 15 '25 16:10

DevOps QA


1 Answers

Update to Jenkins 2.474 and use removeLastBuild argument:

options {
    buildDiscarder(logRotator(numToKeepStr: '2', daysToKeepStr: '7', removeLastBuild: true))
}

This was fixed in JENKINS-68822

In older Jenkins, last successful build would never be removed.

like image 132
Basilevs Avatar answered Oct 19 '25 07:10

Basilevs



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!