CIRCLE_COMPARE_URL is empty


#1

Over at https://github.com/mui-org/material-ui the CIRCLE_COMPARE_URL is only set for jobs that run on the master branch.
master: https://circleci.com/gh/mui-org/material-ui/41208
pull(from member): https://circleci.com/gh/mui-org/material-ui/41166

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.


#2

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


#3

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


#4

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.


#5

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.


#6

Anybody has fixed this? or is there any workaround?


#7

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.


#8

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:
  BASH_ENV=/tmp/.bash_env-5bf683e0dc1d530008e33ad3-0-build
  CI=true
  CIRCLECI=true
  CIRCLE_BRANCH=develop
  CIRCLE_BUILD_NUM=72
  ...
  CIRCLE_COMPARE_URL=
  ...
  CIRCLE_WORKING_DIRECTORY=~/project

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.


#9

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??