0

I created a Bitbucket pipeline where I create a feature Environment per feature branch (on pull request creation event) but I need to add a cleanup step on pull request close or merge

in bitbucket documentation there is no mention of event that can be used.

this is my bitbucket pipeline yaml file for feature deployment:

image: atlassian/default-image:3

pipelines:
  pull-requests:
    feature/*:
      - step:
          runs-on:
            - self.hosted
            - linux.shell
          name: feature
          script:
            - echo "deploy my feature branch for review"

gharbiBdr
  • 31
  • 4
  • So, if I understood that, you would like to run a pipeline on the "PR merged/declined" event that would be a cleanup for things that happened in the "PR created/updated" pipeline? – N1ngu Jan 11 '23 at 10:57

1 Answers1

0

A possible workflow that comes to my mind would be to write a manual continuation to your pipeline with another step so you can run it manually.

image: atlassian/default-image:3

pipelines:
  pull-requests:
    feature/*:

      - step:
          name: feature
          trigger: automatic # this is implicit
          script:
            - echo "deploy my feature branch for review"

      - step:
          name: cleanup feature
          trigger: manual
          script:
            - echo "cleanup"

Drawbacks would be:

  • this is manual
  • this is flaky if you squash and delete the origin branch when merging because the commit the runner should clone could have been already wiped

Theoretically, you could use the API to trigger the second step but that is beyond my knowledge.

N1ngu
  • 2,862
  • 17
  • 35