Over at the CIRCLE_COMPARE_URL is only set for jobs that run on the master branch.
pull(from member):

I wanted to have a list of changed files on the branch CI is running compared to master. Turns out that CircleCI uses hard resets when checking out so git diff master... does not work. Parsing the compare url was my next approach but it is empty when needed. I settled on git rev parse origin/master but that seems to cause some troubles. Using the compare url would be better and ideal would be to expose just the commit range.


The checkout command is optional - if you want to replace it with your own Git command, you can do that.


It would be enough to not reset hard to the commit that triggered the build. Do you know why CircleCI does that?


No idea, sorry. The checkout command has always suited my needs, and I’ve had no call to look into alternatives. Would it be complicated to write an alternative? It seems to me it’s just two steps: install the SSH key and do a clone.

Edit: of course, you could use the checkout and then do another Git operation on top. You have the full history there, so such a command should be possible.


The default checkout command does quite a bit so I’d rather not reduce it to two lines. I could just copy it and remove the hard reset but that seems to hacky.

The diff to master isn’t such a good idea in the first place considering our use case. It includes also files that got change on master during the lifetime of the branch. I basically want to run a code formatter on the files changed in the pull request and see if they conform.

It comes down to finding the commit where the branch was created. Not sure if this is possible. Since TravisCI already has a builtin environment variable I guess it is.


Anybody has fixed this? or is there any workaround?


I don’t think there is anything to fix (or it is not clear what you want fixing). Most users (and I include myself here) do not understand the black magic of the checkout command - it just works. If you want to do something non-standard, then install an SSH key and use git manually.


CIRCLE_COMPARE_URL is empty is also the case for me. I am referring to the output in the “Spin up Environment” section:

Using build environment variables:

If I understand @eps1lon correctly, they want to use the CIRCLE_COMPARE_URL. I also think that @sibelius was referring to this problem and not intended to continue the side discussion around replacing the checkout command.

In my specific use case, it would be interesting to see what directories have changed since the last successful build. However, I am not quite sure whether the CIRCLE_COMPARE_URL is very helpful in this situation, as it only includes all commits for the current build with no information on whether a previous build was successful.


This ENV VAR: CIRCLE_COMPARE_URL= is now empty for us as well. We use it for release notes. Thoughts on how to get this ENV VAR back??