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,463,730
Community Members
 
Community Events
176
Community Groups

How can I create PR Validation Trigger in bitbucket pipelines?

Trigger options I have looked at are:

- `branches` will run automatically on a commit to a branch

- `pull-requests` in my testing will run when a pull request is created or merged

 

I would like a trigger that runs on each commit to a branch that is currently part of a pull request.

 

I am considering using the branches trigger for all branches and writing a custom pipe to check the Bitbucket API to get any related PRs for the commit. The downside being that it would require a pipeline run for every commit to any branch and I am not sure what I would do in the case no PR was found. I guess in that instance I could fail the build but that is not an ideal outcome to have a bunch of failed builds in my pipeline history.

1 answer

1 accepted

0 votes
Answer accepted
Patrik S Atlassian Team May 24, 2022

Hello @Wayne Pichotta ,

Welcome to Atlassian Community!

When you use the pull-requests trigger, it will trigger the pipeline in the Pull-Request creation, as well as in every push to the source branch of the pull request.

Let's take the below YML file as an example:

pipelines:

pull-requests:
'**': #this runs as default for any branch not elsewhere defined
- step:
script:
- echo "Runs for any branch not defined below"
feature/*: #any branch with a feature prefix
- step:
script:
- echo "Runs for any branch that starts with feature"

Supposing that I have created a branch called feature/1 from master. When I create a Pull Request from feature/1 to master, the pull request pipeline feature/* will be triggered. While the Pull request is open, every subsequent commit to the source branch of the PR (in this case feature/1) will also trigger the pipeline  feature/*

You can use something similar to the above in your yml to get the pipeline to trigger in every commit to a branch that is the source of a pull request.

Hope that helps! Let me know in case you have any questions.

Thank you, @Wayne Pichotta .

Kind regards,

Patrik S

@Patrik S wow that is embarrassing. It does exactly what I was asking for. I thought it was not acting that way in my testing last week. Thanks for your patience and taking the time to answer. This is great.

Like Patrik S likes this
Patrik S Atlassian Team May 25, 2022

Hey @Wayne Pichotta ,

No worries at all :) I'm glad to have been of some help.

Thank you, @Wayne Pichotta !

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events