3

Working with a multibranch jenkins pipeline (Jenkinsfile defined) - what techniques do people use for performing actions when the branch no longer exists?

EG. Get Jenkins to perform removal of resources on a cloud provider such as AWS when a branch no longer exists.

eggsy84
  • 1,059
  • 1
  • 14
  • 26

1 Answers1

1

There is a jira ticket with this request, but as far as comments go it doesn't seem it will be done anytime soon: https://issues.jenkins-ci.org/browse/JENKINS-40606

The easiest solution would be to make sure that each branch adds the branch name to the resources the branch creates, i.e. tags in aws or docker. Then either create a separate job in jenkins or a section in jenkinsfile that fetches all existing branches from git, all existing tags from your resources and drops/deletes resources that have tags other than the branches you currently have.

norbitheeviljester
  • 952
  • 1
  • 6
  • 17