Jenkins Git plugin: git describe cannot describe anything

别等时光非礼了梦想. 提交于 2020-04-14 02:28:08

问题


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 with git describe --tags.
It’s also possible to get it to describe against a branch using git 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!