Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run script before removing job in Jenkins Pipelines

I'm setting up a development environment where I have Jenkins as CI server (using pipelines), and the last build step in Jenkinsfile is a deployment to staging. The idea is to have a staging environment for each branch that is pushed.

Whenever someone deletes a branch (sometimes after merging), Jenkins automatically removes its respective job.

I wonder if there is a way to run a custom script before the automatic job removal, then I would be able to connect to the staging server and stop or remove all services that are running for the job that is going to be deleted.

like image 915
mathop Avatar asked Sep 02 '25 05:09

mathop


1 Answers

The plugin multibranch-action-triggers-plugin might be worth a look.

This plugin enables building/triggering other jobs when a Pipeline job is created or deleted, or when a Run (also known as Build) is deleted by a Multi Branch Pipeline Job.

like image 147
Juha Syrjälä Avatar answered Sep 04 '25 23:09

Juha Syrjälä