问题
I am using the Git Plugin of Jenkins ans use Douglas Creager's get_git_version script. This uses git describe to get some sensible version for python modules. Usually this creates something like 0.1-11-g80fe130
, but on jenkins I get:
+ git describe
fatal: No names found, cannot describe anything.
I have configured the plugin not to come up with its own tags through 'skip internal tags'.
Doing an extra checkout of the master branch like in this question about pushing from jenkins doesn't help.
回答1:
Regarding tags (as described in "Git Tip of the Week: Tags")
If no annotated tags are found then it will print
fatal: No names found, cannot describe anything
.
To allow describe to use non-annotated tags, run withgit describe --tags
.
It’s also possible to get it to describe against a branch usinggit describe --all
, although this only makes sense if the branch is known remotely.
So it is possible that your current repo against which the Git Plugin is doing a simple git describe doesn't contain any annotated tag (which explains why a checkout of a tip of a branch doesn't solve the issue: this isn't about a DETACHED HEAD situation)
You need to clone the repo, including the tags.
Actually, the OP Jasper Van Den Bosch reports:
I wasn't pushing the tags correctly
No tags pushed, means Jenkins doesn't get those tags when updating its own clone, means the git describe
cannot work properly.
回答2:
git describe
doesn't work until you have a tag (preferable an annotated tag) in the history before what is currently checked out.
/tmp/repo$ git describe
fatal: No names found, cannot describe anything.
/tmp/repo$ git tag foo
/tmp/repo$ git describe
fatal: No annotated tags can describe '14d827c72b2f277a5cd3e65e7b0e0502edc58fa3'.
However, there were unannotated tags: try --tags.
/tmp/repo$ git tag -a 'annotated-tag' -m 'whatever'
/tmp/repo$ git describe
annotated-tag
来源:https://stackoverflow.com/questions/10268641/jenkins-git-plugin-git-describe-cannot-describe-anything