且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何配置Hudson作业以使用特定的JDK?

更新时间:2023-09-27 08:38:28

事实证明,如果将构建参数化,则添加的任何字符串参数都将成为环境变量.通过这种方法,可以为构建设置任何环境变量,包括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.