Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins Pipeline with Multibranch Workflows: Execute action on branch deletion

Is there a hook/post action, etc. in Jenkins when working with Multibranch Workflows Pipeline so that an action can be executed after (or just before) the branch is deleted?

I need to clean up some resources after branch has been removed, but google gives zero clues on that.

I could always have a hook from github side, but wondering is something similar in Jenkins:

  • On branch create allocate resource X
  • On branch delete de-allocate resource X
like image 202
gerasalus Avatar asked Jan 19 '17 15:01

gerasalus


1 Answers

I have not tested this, but there is a multibranch-job-teardown-plugin which should allow release of resources.

For the setup you might have to fall back on evaluating your build history to find out if this is the first run of a job. Checking currentBuild.getPreviousBuild() for null should help to discover this, allowing to allocate some resources.

like image 165
Dominik Gebhart Avatar answered Nov 09 '22 14:11

Dominik Gebhart