如何配置Hudson作业以使用特定的JDK? [英] How can I configure a Hudson job to use a specific JDK?

查看:100
本文介绍了如何配置Hudson作业以使用特定的JDK?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在Hudson奴隶上运行的项目.我希望其中之一在Java6而不是默认值(我的环境中为Java5)下运行Ant.

I have a number of projects running on a Hudson slave. I'd like one of them to run Ant under Java6, rather than the default (which is Java5 in my environment).

在项目配置视图中,我希望找到其中一个:

In the project configuration view, I was hoping to find either:

  • 一个明确的选项,允许我设置用于此项目的自定义JDK位置.
  • 为该项目设置自定义环境变量的方法,这将允许我进行设置 JAVA_HOME到JDK6位置.这样可以使Ant随心所欲地在Java6上运行.
  • An explicit option allowing me to set a custom JDK location to use for this project.
  • A way to set custom environment variables for this project, which would allow me to set JAVA_HOME to the JDK6 location. The would make Ant pick up and run on Java6 as desired.

是否可以执行以上任一操作?如果这些功能之一可用,我看不到如何使用它.我正在运行哈德森1.285.

Is there a way to do either of the above? If one of those facilities is available, I can't see how to access it. I'm running on Hudson 1.285.

如果可能的话,我宁愿避免使用执行shell"操作而不是调用Ant"操作:我的从服务器在z/OS上,并且Hudson似乎在此平台上未正确创建临时shell脚本(可能编码问题).

I would rather avoid using an "execute shell" operation instead of the "invoke Ant" operation if possible: my slave is on z/OS and Hudson doesn't seem to create the temporary shell scripts properly on this platform (probably an encoding issue).

推荐答案

事实证明,如果将构建参数化,则添加的任何字符串参数都将成为环境变量.通过这种方法,可以为构建设置任何环境变量,包括JAVA_HOME,这是Ant拾取的.

It turns out that if you make the build parametrised, any string parameters you add become environment variables. With this approach, it is possible to set any environment variable for the build, including JAVA_HOME, which is picked up by Ant.

所以对我来说最好的解决方案是:

So the best solution for me was:

  1. 在作业配置页面中,勾选此构建已参数化"
  2. 添加一个名为JAVA_HOME的新String参数,并将默认值设置为JDK位置

构建字符串参数成为环境变量并不明显,但是一旦您知道它们确实是环境变量,就很容易以这种方式设置JDK.

It's not obvious that build string parameters become environment variables, but once you know that they do, it's easy to set the JDK this way.

Hudson邮件列表上的开发人员

The developers on the Hudson mailing list recommended another approach using the master JDK configurations and overrides in the node configurations... but just setting the JAVA_HOME env var seems way easier to me.

这篇关于如何配置Hudson作业以使用特定的JDK?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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