Reputation: 1
we are using jenkins declarative pipeline with multi branches the repo hosted on bitbucket with webhooks configured on merged , push and approved , as we have many features branches so the builds are generated based on this like creating the dns zones configuring the db connection etc , and everything work like charm the problem is when the branch closed/merged jenkins become un-aware of that so the housekeeping jobs not triggered tried to google things how to make jenkins aware of those branches being closed/deleted or merged on same pipeline with no luck any hints or thoughts on this are appreciated
tried work around for job to watch the branches and fire the housekeeping jobs but things got messy so fast and become so complex
Upvotes: -1
Views: 217
Reputation: 2550
Multibranch config runs pipelines from branches. If your branch is deleted, which pipeline do you expect Jenkins to run?
Make a cleanup job that is triggered by repo:push
with push.changes.closed
set to true
(from here). A periodic job would make sense too for any missed web hooks.
Upvotes: 0
Reputation: 3430
Multi-branch pipelines only trigger when a branch receives a commit, and doesn't notice when the branch is merged or deleted. You could take a look at the MultiBranch Action Triggers plugin that might do what you want. Since you're on Bitbucket, consider using webhooks. Look at this answer for more.
You could also handle this whole thing manually, where you run a build periodically that lists down all the branches that exist in your repo. The next time the build runs it lists down the branches again and also checks against the previous list from the earlier run to see if any branches have been deleted. If so, you could get it to trigger a job that does the housekeeping.
Upvotes: 0