mathop
mathop

Reputation: 71

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.

Upvotes: 4

Views: 1446

Answers (1)

Juha Syrjälä
Juha Syrjälä

Reputation: 34271

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.

Upvotes: 2

Related Questions