# "git describe --tags" doesn't work in CI environment

**URL:** <https://forum.buildkite.community/t/git-describe-tags-doesnt-work-in-ci-environment/3722>\
**Category:** General\
**Created:** [June 2, 2024, 10:05pm UTC](https://forum.buildkite.community/t/git-describe-tags-doesnt-work-in-ci-environment/3722 "2024-06-02T22:05:05Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![muratgozel](https://avatars.discourse-cdn.com/v4/letter/m/e480ec/32.png) [@muratgozel](https://forum.buildkite.community/u/muratgozel)\
**Post date:** [June 2, 2024, 10:05pm UTC](https://forum.buildkite.community/t/git-describe-tags-doesnt-work-in-ci-environment/3722/1 "2024-06-02T22:05:05Z")

</div>

Seems like the agent doesn’t do shallow clone and i also tried to set `BUILDKITE_GIT_FETCH_FLAGS="-v --prune --tags"` yet `git describe --tags --abbrev=0` still returns an error: `fatal: No tags can describe ...`

---

<div class="post-metadata">

**Author:** ![benmc](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.buildkite.community/benmc/32/1159_2.png) [@benmc](https://forum.buildkite.community/u/benmc)\
**Post date:** [June 2, 2024, 11:49pm UTC](https://forum.buildkite.community/t/git-describe-tags-doesnt-work-in-ci-environment/3722/2 "2024-06-02T23:49:32Z")

</div>

@muratgozel 👋

Just to check, are you setting the experiment as active on your agent? It is [listed](https://buildkite.com/docs/agent/v3/configuration#experimental-feature) as an experimental feature, so in your config you’ll need to ensure that `experiment` is active:

```auto
...
experiment="git-fetch-flags"

```

Cheers

---

<div class="post-metadata">

**Author:** ![muratgozel](https://avatars.discourse-cdn.com/v4/letter/m/e480ec/32.png) [@muratgozel](https://forum.buildkite.community/u/muratgozel)\
**Post date:** [June 3, 2024, 4:36pm UTC](https://forum.buildkite.community/t/git-describe-tags-doesnt-work-in-ci-environment/3722/3 "2024-06-03T16:36:54Z")

</div>

I’m getting `WARN Unknown experiment "git-fetch-flags"`

Agent version: 3.73 (just updated from 3.6 something)

---

<div class="post-metadata">

**Author:** ![stephanie.atte](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.buildkite.community/stephanie.atte/32/1357_2.png) [@stephanie.atte](https://forum.buildkite.community/u/stephanie.atte)\
**Post date:** [June 3, 2024, 6:15pm UTC](https://forum.buildkite.community/t/git-describe-tags-doesnt-work-in-ci-environment/3722/4 "2024-06-03T18:15:35Z")

</div>

Hey @muratgozel

Stepping in for Ben!

The following steps should help to see the tag in the Build.

- Set the agent git-fetch-flags in the agent configuration file. Its an experimental feature but there is no experiment for this. It’s usage should be

```auto
# Git Fetch Tags 

git-fetch-flags="-v --prune --tags"

```

As seen in our documentation about [Running builds on git tags](https://buildkite.com/docs/integrations/github#running-builds-on-git-tags) and [git-fetch-flags](https://buildkite.com/docs/agent/v3/configuration#git-fetch-flags)

- Next In the Pipeline’s Github Setting, we need to have Build Tags enabled on the pipeline.  

- The pipeline configuration below uses the metadata to set the Git Tag

```auto
  steps: 
    - label: Get and Output the Git Tags
      command: | 
          buildkite-agent meta-data set meta_tag "$(git describe --tags --abbrev=0)" 
          echo The Git Tag is: $(buildkite-agent meta-data get meta_tag)

```

---

<div class="post-metadata">

**Author:** ![muratgozel](https://avatars.discourse-cdn.com/v4/letter/m/e480ec/32.png) [@muratgozel](https://forum.buildkite.community/u/muratgozel)\
**Post date:** [June 3, 2024, 7:18pm UTC](https://forum.buildkite.community/t/git-describe-tags-doesnt-work-in-ci-environment/3722/5 "2024-06-03T19:18:56Z")

</div>

to be more clear, it’s scanning for certain kind of tags inside the script: `git describe --tags --abbrev=0 --match="..."` so it needs older tags, not the one we just pushed.

nevertheless, it should be able to list the tags because i see it executes  
`git fetch -v --prune --tags -- origin e1ff92...` before executing the command, strange that i get `fatal: No tags can describe 'e1ff92b...'` or just the tag i pushed when i enabled “Build tags”.

---

<div class="post-metadata">

**Author:** ![stephanie.atte](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.buildkite.community/stephanie.atte/32/1357_2.png) [@stephanie.atte](https://forum.buildkite.community/u/stephanie.atte)\
**Post date:** [June 3, 2024, 9:42pm UTC](https://forum.buildkite.community/t/git-describe-tags-doesnt-work-in-ci-environment/3722/6 "2024-06-03T21:42:53Z")

</div>

Hey @muratgozel

The `git describe` command finds the most recent reachable tag from a commit. To show only the specific tags that match a pattern.

You would get a fatal error if the command does not return any names and it needs to be in Glob Format

`git describe --tags --abbrev=0 --match="V2*"`

OR

`git tag -l "V2*"`

```auto
steps:
  - label: Get Tag and Match
    command: |
      buildkite-agent meta-data set meta_tag "$(git tag -l "V2*")”
      echo The Git Tag is: $(buildkite-agent meta-data get meta_tag)

 - label: Describe Tag and Match
    command: |
      buildkite-agent meta-data set meta_tag "$(git describe --tags --abbrev=0 --match="V2*"”
      echo The Git Tag is: $(buildkite-agent meta-data get meta_tag)

```

---

<div class="post-metadata">

**Author:** ![muratgozel](https://avatars.discourse-cdn.com/v4/letter/m/e480ec/32.png) [@muratgozel](https://forum.buildkite.community/u/muratgozel)\
**Post date:** [June 4, 2024, 6:05am UTC](https://forum.buildkite.community/t/git-describe-tags-doesnt-work-in-ci-environment/3722/7 "2024-06-04T06:05:58Z")

</div>

I just realized that the tag CI created wasn’t reachable from the commit I recently pushed. I remember that I did fetch and merge in my device when that tag generated but I guess I’m wrong in somewhere. Anyway, thanks for the guidance 🙏 This kind of releasing workflow can make the workflow more fragile. I will try to make sure the releasing script properly pulls the latest tags before pushing.
