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 ...
Just to check, are you setting the experiment as active on your agent? It is listed as an experimental feature, so in your config you’ll need to ensure that experiment
is active:
...
experiment="git-fetch-flags"
Cheers
I’m getting WARN Unknown experiment "git-fetch-flags"
Agent version: 3.73 (just updated from 3.6 something)
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
# Git Fetch Tags
git-fetch-flags="-v --prune --tags"
As seen in our documentation about Running builds on git tags and 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
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)
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”.
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*"
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)
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.