SHA1 of previous build




I’d like to fetch the commit hash of the previous build. The current one is available as CIRCLE_SHA1, and there is also CIRCLE_COMPARE_URL, but no sha1 of previous build.
Is there an easier way than parsing CIRCLE_COMPARE_URL?

Thanks in advance!


Even better would be to have the SHA1 of the last build and the SHA1 of the last successful build.


Hi there, any update on this? It would be extremely useful.
I’m curious how people are getting around this currently.


So to do this within the build, create an API_KEY in your build with full permissions, and run this inside your build

LAST_SUCCESSFUL_COMMIT=$(curl -Ss -u "$API_KEY:" "$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME?filter=completed&limit=1" | jq -r '.[0]["vcs_revision"]')


+1 to this feature request. It would be very nice to have this info readily available to help decrease build times. Tools such as Lerna, Bazel and others can make use of this information to only rebuild what needs building.


This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.