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

Webhook requests from Build do not contain branch name

Jonathan Duncan December 14, 2023

The webhook ["Push" event payload] contains the name of the branch that that the commit was pushed on.

The webhook "Build status created" (`repo:commit_status_created`) and "Build status updated" (`repo:commit_status_updated`) event payloads do not contain the name of the branch.

Is this a feature or an oversight? If it is like this on purpose, I am curious as to the reasoning. If this was an oversight, I would like to request that this feature be added.

1 answer

1 accepted

1 vote
Answer accepted
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 18, 2023

Hi Jonathan,

When a commit is pushed, it is pushed to a specific branch. Builds, however, do not necessarily run on branches.

For example, with Bitbucket Pipelines it is possible to run builds on tags or pull requests. It is also possible to run a build on a certain commit if you open that commit on Bitbucket website and select the option Run pipeline. That build will not be associated with a certain branch. If we were to return the branches this commit is reachable from, then e.g. for the initial commit of the repo that would be all branches. For a repo with a large number of branches that would be a large number of references which would probably not be very useful.

Are you looking for the branch the commit belongs to? Or for the trigger of the build (branch name for builds triggered on branches, PR number for pull-requests triggered builds, tag for tags-triggered builds, and commit hash for commit-triggered builds)?

Kind regards,
Theodora

Jonathan Duncan January 2, 2024

Thank you for your response. I can see how the current branch would not be useful.

As you mentioned, yes, I am actually looking for the branch that the commit belongs to or that triggered the build.

I need this information to help automate a process that depends on knowing which branch a build was started on.

I know I could take the commit information and use some of that to make an API call to get more information about the commit, but it would be convenient to have that in the webhook. It would save me some extra work. :)

Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 3, 2024

Hi Jonathan!

Thank you for your reply.

Our API for commits does not return the branches a commit is reachable from for the same reason I explained earlier (if a commit is reachable from a large number of branches, we would need to return a large number of refs which would probably not be very useful).

What you could do is check the url in the webhook payload, and if that returns a url to the build, you could use the API of the CI/CD tool you are using to retrieve info for the build and the branch that triggered the build (in case it was indeed a branch-triggered pipeline). For example, if you use Bitbucket Pipelines, our API returns this info:

If you use another CI/CD tool you may be able to get that info from that build system's APIs.

I went ahead and created a feature request in our issue tracker for returning the build trigger in the payload:

You can add your vote and feedback there to express your interest. Implementation of features is done as per our policy here and any updates will be posted in the feature request.

Please feel free to let me know if you have any questions.

Kind regards,
Theodora

Like # people like this
Jonathan Duncan January 4, 2024

Thank you for the extra information and also for submitting a feature request.

Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 5, 2024

You are very welcome. Please feel free to reach out if you ever need anything else!

Suggest an answer

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

Atlassian Community Events