使用 Hudson 构建时保存 Git SHA1 类似于 CVS 的 CVS_BRANCH 标签 [英] Saving Git SHA1 when building with Hudson similar to the CVS_BRANCH tag for CVS

查看:25
本文介绍了使用 Hudson 构建时保存 Git SHA1 类似于 CVS 的 CVS_BRANCH 标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们已经从 CVS 迁移到 Git.我们的 Hudson 构建脚本用于在生成的构建中保存 CVS_BRANCH 环境变量的值以及 Hudson BUILD_ID 以供以后调查.

We have migrated from CVS to Git. Our Hudson build script used to save the value of the CVS_BRANCH environment variable in the generated build along with the Hudson BUILD_ID to allow for later investigation.

我无法弄清楚 Hudson(或 Git 插件)如何将当前提交的 Git SHA1 名称呈现给 ant 脚本,因为我找不到任何明确的来源说明我应该在哪里查看.

I cannot figure out how Hudson (or the Git plugin) presents the Git SHA1 name of the current commit to the ant script, as I cannot locate any definite source saying where I should look.

如果环境中存在 git,我不希望调用 git 来获取它,但如果有必要可以这样做.

I'd prefer not to invoke git to get it if it is present in the environment, but can do if that is necessary.

我错过了什么?

推荐答案

原来 jGit 支持rev-parse HEAD"命令,结合 <java jar="jgit...jar" fork="true" args="rev-parse HEAD" outputproperty="git.SHA1"/> 正是我想要的,即将 SHA1 放入一个 ant 属性中,以便我以后可以使用它.

It turned out that jGit supports the "rev-parse HEAD" command, which in combination with the <java jar="jgit...jar" fork="true" args="rev-parse HEAD" outputproperty="git.SHA1" /> did exactly what I wanted, namely got the SHA1 into an ant property so I could use it later.

这篇关于使用 Hudson 构建时保存 Git SHA1 类似于 CVS 的 CVS_BRANCH 标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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