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

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Is it possible to run a pipeline script on only the updated files in the pull request?

I have a PHP project that i am wanting to add CodeSniffer (phpcs) to via a pipeline. I currently have it running unit tests, so I am not worried about getting it working generally. I will have no issues being able to run the code sniffer over all files. However, there are will over 1000 files in the project, so it will take a while to run. I would love to be able to run the sniffer only over those files that were changed in the pull request. Is there a way to do that? I can't seem to locate any information on this.

I have these two git commands that should give me what I am looking for, but haven't determined which is more consistent:

git diff --name-only HEAD...master


git --no-pager diff --name-only FETCH_HEAD $(git merge-base FETCH_HEAD master)

Any help on how to get that information inside a pipeline would be greatly appreciated. Thank you.

1 answer

0 votes
mkleint Atlassian Team Feb 02, 2020

You might want to check this bitbucket API that should return you the files changed in the pullrequest


in PR triggered builds you get the pull request's ID as environment variable - BITBUCKET_PR_ID (

Suggest an answer

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

New improvements to user management in Bitbucket Cloud 👥

Hey Community! We’re willing to wager that quite a few of you not only use Bitbucket, but administer it too. Our team is excited to share that we’ll be releasing improvements throughout this month of...

3,710 views 10 16
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