活动Git分支是“(不分支)”在哈德逊CI上 [英] Active Git branch is "(no branch)" on hudson CI

查看:127
本文介绍了活动Git分支是“(不分支)”在哈德逊CI上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Ant build.xml脚本以

开头

 < property environment =env/> 
< echo> GIT_BRANCH = $ {env.GIT_BRANCH}< / echo>
< echo> PWD = $ {env.PWD}< / echo>

Hudson CI设置为在任何分支发生更改时生成。控制台输出是...

 开始构建版本90906a63929e9074035eb5b10c71ee055ad3e13c(原始/ DPM-48)
GitAPI创建
检出修订版90906a63929e9074035eb5b10c71ee055ad3e13c(origin / DPM-48)
[工作区] $ git.exe签出-f 90906a63929e9074035eb5b10c71ee055ad3e13c
[工作区] $ cmd.exe / C'C:\程序文件\\WinAnt\bin\ant.bat-file build.xml ...'
[echo] GIT_BRANCH = $ {env.GIT_BRANCH}
[echo] PWD = / cygdrive / d /。 hudson

在控制台输出中,Hudson知道它正在构建主题分支DPM-48,但环境变量GIT_BRANCH是没有设置,'git branch'返回git处于'detached HEAD'状态

  *(no branch)
master
DPM-48

我想知道我正在建造哪个分支在哈德森。

解决方案

已解决



Hudson bug 6856 中看到abayer的评论后,我采取了以下步骤:
$ b


  • 使用Hudson插件管理器,我更新了我的Hudson Git Plugin版本1.1)以获得abayer的修复。

  • 使用哈德森作业配置,我点击源代码管理 - >分支到构建下的高级按钮。然后,我改变了使用本地分支来使用某个名称。然后我点击保存按钮,并使用立即生成开始构建




生成日志显示

  alt =alt text> 

[工作区] $ git.exe checkout -b ChangeTester d6caef27759495c5714923c1ddf19551a70d6083

而不是

  [工作区] $ git.exe checkout -f d6caef27759495c5714923c1ddf19551a70d6083 

这意味着我不处于'分离头部'状态,因此可以进行提交,创建标签和推送。

我可以使用'git rev-parse HEAD'获取提交散列,并在'git show-ref'的输出中找到该分支的真实名称(如果我需要的话)。



我现在可以将成功的构建标签推送到我的git仓库。


My Ant build.xml script starts with

<property environment="env"/>
<echo>GIT_BRANCH = ${env.GIT_BRANCH}</echo>
<echo>PWD = ${env.PWD}</echo> 

Hudson CI is setup to build when any branch changes. Console output is...

Commencing build of Revision 90906a63929e9074035eb5b10c71ee055ad3e13c (origin/DPM-48)
GitAPI created
Checking out Revision 90906a63929e9074035eb5b10c71ee055ad3e13c (origin/DPM-48)
[workspace] $ git.exe checkout -f 90906a63929e9074035eb5b10c71ee055ad3e13c
[workspace] $ cmd.exe /C '"C:\Program Files\WinAnt\bin\ant.bat" -file build.xml ...'
 [echo] GIT_BRANCH = ${env.GIT_BRANCH}
 [echo] PWD = /cygdrive/d/.hudson

From the console output, Hudson knows it is building topic branch DPM-48 but environment variable GIT_BRANCH is not set and 'git branch' returns that git is at a 'detached HEAD' state

* (no branch)
master
DPM-48

What I want to know is which branch I'm building on hudson. There must be a way to do this.

解决方案

RESOLVED

After seeing the comment by abayer in Hudson bug 6856, I took the following steps:

  • Using the Hudson Plugin Manager, I updated my Hudson Git Plugin version 1.1) to get abayer's fix.
  • Using the Hudson Job Configuration, I clicked the "Advanced" button under "Source Code Management" -> "Branches to Build". I then changed the "Local branch to use" to something to use for a name. It doesn't matter what.
  • Then I clicked the "Save" button and started a build with "Build Now"

The build log shows

[workspace] $ git.exe checkout -b ChangeTester d6caef27759495c5714923c1ddf19551a70d6083

Instead of

[workspace] $ git.exe checkout -f d6caef27759495c5714923c1ddf19551a70d6083

Which means that I am not in a 'detached head' state and can therefore do commits, create tags, and push.

I can use 'git rev-parse HEAD' to get the commit hash and find that in the output of 'git show-ref' to find the real name of the branch if I need it.

I'm now able to push successful build tags to my git repo.

这篇关于活动Git分支是“(不分支)”在哈德逊CI上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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