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
Community Members
Community Events
Community Groups

how to get changed file path on event based webhook json payload ?

I am trying to create a AWS codepipeline which will be trigger when certain files are uploaded on specific folders on the MonoRepo. for eg: I have a monorepo with my frontend in Folder_A (reponame/apps/folder_A)and Backend on Folder_B(reponame/apps/folder_B). If I make changes to a file inside Folder_A and push, AWS codepipeline (Codepipeline for Folder_A)  should be triggered.

This is how I planned to implement the solution. Whenever there is a PR, the webhook payload is sent to AWS API Gateway  which then triggers lambda and pushes payload to lambda. The code in lambda will identify the path of the file changed and triggers respective AWS code pipeline. But I am unable to get the information on which folder was updates on the  webhook payload i.e path of the file changed on bitbucket. I am looking for a way to get the filepath on webhook payload.

1 answer

0 votes
Mark C Atlassian Team Jul 01, 2021

Hi @Madan Shah

Welcome to the community.

I'm afraid Bitbucket Cloud Webhooks does not include file paths as payloads while triggering an event (e.g. push, pull request updates).
You can check this link for more information about Bitbucket Cloud Webhooks' available payloads. - (See "Trigger webhooks" section)

As a workaround, I believe your use-case is doable by using Bitbucket Pipelines.
Bitbucket Pipelines is a CI/CD tool within your repository where you can run scripts/commands to build, test, and deploy your code.

Based on your use case, assuming your mono-repositories are located in a single repository on Bitbucket Cloud:

  • apps/folder_A
  • apps/folder_B

You can set up a Pipelines YAML configuration that triggers by default and by using Conditional Steps.
Using Conditional steps, you can execute a step only if one of the modified files matches the expression in includePaths.

Here's a sample YAML file where you can use the default Pipelines trigger and Conditional steps:

    - step:
          name: "Monorepo 1"
                    - "apps/folder_A/**"
            - echo "Execute commands here (e.g. running a CodePipeline script/command)"
    - step:
          name: "Monorepo 2"
                    - "apps/folder_B/**"
            - echo "Execute commands here (e.g. running a CodePipeline script/command)"

The above YAML configuration will trigger a Pipelines build each time you push a commit in the branch where you pushed the YAML configuration (initially, it will be your main branch).
However, a step will be paused if the file changes made or pushed are not within the specified path (or includePaths).

Here are some links that will help you get started with Bitbucket Pipelines:

You can give it a try and let me know how it goes.

Mark C

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Bitbucket

Git push size limits are coming to Bitbucket Cloud starting April 4th, 2022

Beginning on April 4th, we will be implementing push limits. This means that your push cannot be completed if it is over 3.5 GB. If you do attempt to complete a push that is over 3.5 GB, it will fail...

2,154 views 2 9
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you