snippetgitMinor
How do I trigger scripts on a merge or when a branch is deleted?
Viewed 0 times
scriptstriggerhowmergedeletedwhenbranch
Problem
I am using jenkins multibranch pipelines. If a branch is merged and deleted jenkins removes the branch from the pipeline as well.
This is great, but I want to run a command/script when a branch is removed, how can I have jenkins run a command when a branch is removed? Is there a way to have jenkins trigger a job before it removes the branch?
Edit: I should add I'm using bitbucket. It would be neat if Jenkins could trigger an event when purging a branch of a multibranch pipeline. Ideally it wouldn't matter what my git provider is.
This is great, but I want to run a command/script when a branch is removed, how can I have jenkins run a command when a branch is removed? Is there a way to have jenkins trigger a job before it removes the branch?
Edit: I should add I'm using bitbucket. It would be neat if Jenkins could trigger an event when purging a branch of a multibranch pipeline. Ideally it wouldn't matter what my git provider is.
Solution
"This is great, but I want to run a command/script when a branch is removed, how can I have jenkins run a command when a branch is removed?"
You will need to use a webhook for this, I use the following
settings in Github:
Bitbucket only supports the following webhooks:
"Is there a way to have Jenkins trigger a job before it removes the branch?"
Not that I can see, but in Github you can create a custom label and
trigger a job via a webhook when the label is added to a branch.
You will need to use a webhook for this, I use the following
settings in Github:
Bitbucket only supports the following webhooks:
"Is there a way to have Jenkins trigger a job before it removes the branch?"
Not that I can see, but in Github you can create a custom label and
trigger a job via a webhook when the label is added to a branch.
Context
StackExchange DevOps Q#2568, answer score: 4
Revisions (0)
No revisions yet.