如何在竹制建筑中标记git repo [英] How to tag a git repo in a bamboo build

查看:82
本文介绍了如何在竹制建筑中标记git repo的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Bamboo版本中标记红宝石宝石的git repo.我以为在红宝石中做这样的事情会做得到

I'm trying to tag the git repo of a ruby gem in a Bamboo build. I thought doing something like this in ruby would do the job

`git tag v#{current_version}`
`git push --tags`

但是问题是仓库没有来源.竹以某种方式摆脱了origin 有任何线索吗?

But the problem is that the repo does not have the origin. somehow Bamboo is getting rid of the origin Any clue?

推荐答案

是的,如果导航到作业工作区,您会发现Bamboo并没有直接"进行简单的git clone,而远程是设置为内部文件路径.

Yes, if you navigate to the job workspace, you will find that Bamboo does not do a straightforward git clone "under the hood", and the the remote is set to an internal file path.

幸运的是,Bamboo确实将原始存储库URL存储为$ {bamboo.repository.git.repositoryUrl},因此您所需要做的就是设置一个指向原始对象的远程指针并推送到该原始对象.这就是我一直在基本Git存储库和Stash中使用的,并根据内部版本号创建标签.

Fortunately, Bamboo does store the original repository URL as ${bamboo.repository.git.repositoryUrl}, so all you need to do is set a remote pointing back at the original and push to there. This is what I've been using with both basic Git repositories and Stash, creating a tag based on the build number.

git tag -f -a ${bamboo.buildNumber} -m "${bamboo.planName} build number ${bamboo.buildNumber} passed automated acceptance testing." ${bamboo.planRepository.revision}
git remote add central ${bamboo.planRepository.repositoryUrl}
git push central ${bamboo.buildNumber}
git ls-remote --exit-code --tags central ${bamboo.buildNumber} 

最后一行只是在无法回读新创建的标记时导致任务失败.

The final line is simply to cause the task to fail if the newly created tag cannot be read back.

不要试图使用变量$ {bamboo.repository.git.repositoryUrl},因为这不一定指向您工作中检出的存储库.

Do not be tempted to use the variable ${bamboo.repository.git.repositoryUrl}, as this will not necessarily point to the repo checked out in your job.

还要记住,如果要从多个来源签出,则$ {bamboo.planRepository.repositoryUrl}指向源代码签出"任务中的第一个存储库.通过以下网址引用更具体的URL:

Also bear in mind that if you're checking out from multiple sources, ${bamboo.planRepository.repositoryUrl} points to the first repo in your "Source Code Checkout" task. The more specific URLs are referenced via:

${bamboo.planRepository.1.repositoryUrl}
${bamboo.planRepository.2.repositoryUrl}
...

以此类推.

这篇关于如何在竹制建筑中标记git repo的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆