Bitbucket pipelines on PR - using PHP Code Sniffer only on changed files

Sebastian Ruchlewicz September 19, 2019

Is it possible to somehow pass only the changed files in bitbucket-pipelines.yml? I want to run PHP Code Sniffer only on changed files while creating pull request. I couldn't find answer anywhere, all solutions where that I should hardcode the path to the project files. Thanks!

1 answer

1 accepted

1 vote
Answer accepted
mkleint
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 8, 2019

you should be able to generate an app password that allows you to call specific bitbucket APIs.

https://confluence.atlassian.com/bitbucket/deploy-build-artifacts-to-bitbucket-downloads-872124574.html

 

then possibly using the pullrequest API (https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Busername%7D/%7Brepo_slug%7D/pullrequests) and/or diffstat API you could be able to figure out what files changed in the given changesets that comprise the pull request?

Sebastian Ruchlewicz November 13, 2019

@mkleintyeap, that API endpoint did the trick, thanks :)

To be correct I used this one -> https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Busername%7D/%7Brepo_slug%7D/pullrequests/%7Bpull_request_id%7D/diffstat as it provides a param for specific PR

boden.garman January 15, 2020

Can you post how you integrated this in the yml file please?

Like Emily Stamey likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events