How can I configure a Hudson job to use a specific JDK?

后端 未结 9 1836
情话喂你
情话喂你 2020-12-05 06:44

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 t

相关标签:
9条回答
  • 2020-12-05 07:33

    We have both Java 5 and Java 6 configured for use in our Hudson instance.

    Under Manage Hudson -> Configuration System you can add a number of JDKs and specify the path for JAVA_HOME. In the configuration for each job you then selected which JDK you would like that job to run on.

    0 讨论(0)
  • 2020-12-05 07:38

    you can use like this.

    in batch command window intially u can set the variable name JAVA_HOME, Assign this custom variable name to PATH variable. then u can call an ant script to choose specific file.

    Example:

    set JAVA_HOME=C:/java/jdk1.6.1

    PATH=%JAVA_HOME%/bin;%PATH%

    ant build.xml

    0 讨论(0)
  • 2020-12-05 07:41

    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. In the job configuration page Tick "This build is parameterized"
    2. Add an new String parameter called JAVA_HOME and with the default value set to the JDK location

    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.

    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.

    0 讨论(0)
提交回复
热议问题