Checkout fails on workflow triggered by annotated git tag

,

I have a workflow configured to run only when a release tag is created.

Example job and workflow definitions:

jobs:
  my_job:
    steps:
      - checkout
      - run: more_stuff
workflows:
  version: 2
  my_workflow:
    jobs:
      - my_job:
          filters:
            tags:
              only: /^v.*/
            branches:
              ignore: /.*/

When I create an annotated tag (git tag -a my-annotated-tag) and push it to GitHub, my_workflow runs as expected, but my_job fails during Checkout code with one of these two outputs:

Enumerating objects: 8, done.
Counting objects: 100% (8/8), done.
Compressing objects: 100% (7/7), done.
Total 3493 (delta 1), reused 2 (delta 1), pack-reused 3485
reference not found

or

Enumerating objects: 24, done.
Counting objects: 100% (24/24), done.
Compressing objects: 100% (18/18), done.
Total 3839 (delta 5), reused 18 (delta 4), pack-reused 3815
object not found

However, if I create a lightweight git tag (git tag my-lightweight-tag), Checkout code is successful. My hypothesis is that the object/reference that is not found is the annotated tag and that it is missing because CircleCI is doing a shallow clone against a hash, thereby excluding the tag object.

I strongly prefer using annotated tags over lightweight tags for releases, so this is a major issue.

Yes your hypothesis is correct. By default CircleCI does a shallow clone. There is no way to modify the checkout step so instead I would suggest not using the checkout step at all, and instead writing your own custom checkout command that does a full clone.

Good to know I was on the right track.

As a follow up, would you happen to know how to access CircleCI’s native git client directly? If it’s readily available, I’d love to use it over tweaking my current docker image, but I’ve found very little information on this. The closest is this ignored thread.

Some more information I’ve found.

After installing my own git client (2.18.1-r0), I found I was able to make a shallow clone with git clone --branch "${CIRCLE_TAG}" --depth 1 "${CIRCLE_REPOSITORY_URL}" . and, at least on 2.18.1-r0, git was able to do the checkout just fine. I.e., it seems like using a shallow clone is okay, but perhaps the exact clone command being used by the built-in checkout step has an issue or perhaps the git binary needs to be updated.

I’m hoping that in the New Year I can get in touch with someone at CircleCI and eventually go back to using the built-in checkout.

All of the CircleCI images use upstream docker images. This change would ultimately need to be made upstream. Since the majority of these upstream images are based on debian, the version of git that is built in by default is quite old.

I was using a custom image that did not have git installed. When I did so, CircleCI has a native client that it can use instead. This is the client I presume could be updated and without altering upstream Debian images or I could call directly on my own in steps to fetch the objects I need. If not, I am fine adding git and ssh to my image for now. It just feels like a gap for annotated tags to not work out of the box.

Example of using checkout when the image does not have git or ssh:

Either git or ssh (required by git to clone through SSH) is not installed in the image. Falling back to CircleCI's native git client but the behavior may be different from official git. If this is an issue, please use an image that has official git and ssh installed.

Thanks for the responses. Have a happy new year!

Thank for the clarification, thanks makes a lot of sense. I made a feature request for this.

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