Validatnig code in Pull Request

Answered

Hi All.

 

I'm trying to set up job runnig tests on code that is changed in Pull Request.

I have VSC trigger, Pull Requests and Commit Status Publisher set up.

When PR is raised job is triggered and results are published in github - so far so good.

 

I want to check only files that has changed - i use system.teamcity.build.changedFiles.file to determine them.

Now issues starts.

I have found few ways to walkaround such checks.

 

First - this file is not present if you rerun job. So if your checks have failed just goto TC and rerun job - will end with success (*depends on job setup).

Adding extra step that checks if changedFiles file is empty can prevent such scenario. 

 

Second - changedFiles file does not contain files that are changed across PR but only from last commit.

That means that you can circumvent checks by making change in one file within pull request AFTER PR checks have been done.

This will once again trigger job that will validate only that one file instead of all files that are changed across PR.

 

As far as files in workdir are not git clones I am unable to run git diff.

 

What are my options to determine which files are changed in given PR?

 

Kind regards

Hubert Mach

 

1 comment
Comment actions Permalink

Hi Hubert,

 

TeamCity does not have a direct way to tell you changes for a full pull request, as that's the task of the VCS tooling. TeamCity tracks changes between different builds instead. If you shared how and why you need to have access to this information, it might be possible for us to make a suggestion, as the information can probably be gathered with a bit of scripting in multiple ways (you could collect it directly from the vcs information, as a pull request is just a branch or from teamcity's REST API)

0

Please sign in to leave a comment.