Reputation: 21
I have Jenkins setup when a branch is deleted the associate jenkins job for that branch is also deleted. However, I want to add some commands (kubernetes clean up) after the branch is deleted.
I am trying to use this plugin here: https://github.com/jenkinsci/multibranch-action-triggers-plugin
I want to check two things:
How can I use the multibranch via jenkinsfile?
Have you guys already done this before? How?
Thank you
Upvotes: 0
Views: 343
Reputation: 6859
Your question could be much improved if you would pinpoint the source control system you use.
Anyhow, in a situation where you have multiple branches, it's better to use appropriate plugins for multibranch setups. There are a couple available for Git and Github, if that's your case. In this setup, there is a copy of Jenkinsfile in each branch (as with other files, the Jenkinsfile may be — but doesn't have to be — the same in all branches). These plugins usually create new "sub-jobs" for new branches (or pull requests) and remove the deleted ones as necessary.
Additionally, there is a somewhat unexplained use case where you have to do some actions on branch removal, for reasons that are unclear. Most cleanups are done after a job is finished, not after a branch is deleted. However, you may still implement that if your setup allows for the notifications on these events. Github, for example, can be configured to send a notification (webhook) to your Jenkins that can parse that notification and do something in the case. The way to do that is outlined in this answer.
Upvotes: 1