使用Hudson来构建特定的git commit [英] Use Hudson to build a specific git commit

查看:131
本文介绍了使用Hudson来构建特定的git commit的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个哈德森构建服务器。源代码由git存储库管理。对于每个版本,检出并编译最新版本。现在我想告诉哈德森不要使用最新版本,而是使用旧版本的代码(由我指定)。

在哈德森我有两个可以设置的参数。第一个存储库名称,默认值为origin,第二个 refspec ,值为 + refs / heads / *:refs / remotes / origin / * 。我尝试了一些类似于 origin / [commitid] + refs / heads / *:refs / remotes / origin / [commitid] code>。但没有按预期工作。



我认为我必须使用参数化作业,以便我可以将作为参数的提交作业。



我如何告诉hudson使用特定的提交而不是最新的提交?

解决方案

我只想这个回答更清楚。
如何使您的工作逐步检出特定的提交:


  1. 将字符串参数添加到作业中,名称,在我的例子中让它成为 COMMIT

  2. 选择Git as SCM(由詹金斯Git插件)。

  3. 在Git SCM属性中设置您的repo属性。

  4. 在Git SCM中,要构建的分支键入 $ {COMMIT} ,它是作业参数的参考,在构建过程中解决这个问题。

就是这样,启动构建并在日志中看到如下所示的内容:

 克隆远程Git存储库
克隆存储库ssh://your-repo.git
从ssh获取上游更改: //your-repo.git
使用GIT_SSH设置凭证
使用GIT_SSH设置凭证
从ssh://your-repo.git获取上游更改
检出Rev ision af63e2102b65953316e512c0bb659578bb143a33(分离)

请注意,还有其他方法可以在SCM结帐之前设置环境变量,即使用运行步骤准备环境EnvInject插件(你甚至可以使用Groovy)。



另外,如果你没有看到我正在谈论的选项, t工作,确保你有一个新版本的Git插件在我的情况下它是2.2.0。


I have a hudson build server. The source code is managed by a git repository. For each build the latest version is checked out and compiled. Now i'd like to tell hudson to use not the latest version, but an older version of the code (specified by me).

In hudson i have two parameters which can be set. First "name of repository", with default value "origin" and second refspec with value +refs/heads/*:refs/remotes/origin/*. I tried a bit around something like origin/[commitid] or +refs/heads/*:refs/remotes/origin/[commitid]. But nothing worked as expected.

I think i had to use a parameterized job, so that i can give the commit as parameter to the job.

How can i tell hudson to use a specific commit instead of the latest one?

解决方案

I just want to this answer more clear. How to make your job to checkout a specific commit, step by step:

  1. Add string parameter to your job with name, let it be COMMIT in my example.
  2. Choose Git as SCM (provided by Jenkins Git plugin).
  3. In Git SCM properties set your repo properties.
  4. In Git SCM, in the paragraph Branches to build type ${COMMIT} which is the reference to the job parameter and will be resolved during the build.

That's it, launch the build and in the log you will see something like this:

Cloning the remote Git repository
Cloning repository ssh://your-repo.git
Fetching upstream changes from ssh://your-repo.git
using GIT_SSH to set credentials 
Fetching upstream changes from ssh://your-repo.git
using GIT_SSH to set credentials 
Checking out Revision af63e2102b65953316e512c0bb659578bb143a33 (detached)

Note, that there are other ways to set the environment variable before the SCM checkout, i.e. using Prepare environment for the run step from the EnvInject Plugin (you could even use Groovy for this).

Also, if you don't see the options I'm talking about or they don't work, ensure you have a new version of a Git plugin In my case it is 2.2.0.

这篇关于使用Hudson来构建特定的git commit的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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