Get changed files by pull request instead of by commit?

Answered

In one of my build configurations, I have an environment variable set to %system.teamcity.build.changedFiles.file%. I use this to run a linting tool only on changed files, triggered by pull requests on github.

The problem I'm having is that the changed files apply to the latest commit, instead of to the diff between the pull request and the target branch. So basically you can get the linting check to pass simply by doing a bad-lint commit followed by a commit touching a single file that passes lint.

Going by commit is a reasonable default, I guess, but I really only care at the level of a PR. I want to know if the final state of the pull request passes the linting check, not if the tiny changes made to get it to the final state pass the linting check.

0
1 comment

Hello Craig,

There is no special support for this in TeamCity. You can use agent-side checkout and use git command to get the list of changed files. Another approaches are to use REST API or to create a plugin for TeamCity. Seems that solution with agent-side checkout is the easiest.

0

Please sign in to leave a comment.