Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,559,325
Community Members
 
Community Events
184
Community Groups

How to trigger a pipeline on branch delete?

I tried to search a lot but have not got proper answer.

In my case, I want to run a pipeline when a branch is deleted, basically it will help to remove the resources used for example k8s pods/deployments.

We create development environments whenever a branch is created so now to want to remove these environments once that branch is deleted.

Please do suggest a valid way to do so. Is there any add-on available?

1 answer

1 vote
Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
Mar 21, 2023

Hello @Rahul Raut ,

Thank you for reaching out to Atlassian Community!

I'm afraid that it would not be possible to run a pipeline for a deleted branch, as the pipeline will look for the bitbucket-pipelines.yml file on that branch and since the branch is gone the file would no longer exist.

Since your goal is to do some cleanup in the environments that were used from previous pipelines, I would suggest using a custom pipeline. Custom pipelines are only manually triggered and you can select in the UI which branch or commit you want it to run. Also, it's possible to provide variables during the pipeline trigger of a custom pipeline, which allows you to have dynamic values in each run.

Following is an example of using a custom pipeline with variables : 

pipelines:
  custom:
    custom-name-and-region:
      - variables:
          - name: Username
          - name: Region
            default: ap-southeast-2  # optionally provide a default value
      - step:
          script:
            - echo "User name is $Username"
            - echo "and they are in $Region"

 In this example, the pipeline would expect the variables Username and Region to be provided. You will be prompted to provide those variables when running the pipeline manually from Pipelines page > Run Pipeline. For variables that have a default value, if no different value is provided, the default one will be used.

You can read more about custom pipelines in our Scheduled and manually triggered pipelines documentation.

Thank you, @Rahul Raut !

Patrik S

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events