如何在Jenkins中为每个作业全局设置JVM选项?

时间:2021-04-26 17:21:40

I've recently installed a new JDK (1.7u9), and I got some very strange VerifyErrors. In a thread I found that it could help me if I use a -XX:-UseSplitVerifier magic switch for the compilation.

我最近安装了一个新的JDK(1.7u9),我得到了一些非常奇怪的VerifyErrors。在一个帖子中,我发现如果我使用-XX:-UseSplitVerifier魔术开关进行编译,它可以帮助我。

What I would like to do is to set this Java option globally in Jenkins, but haven't found any configurations for it. Can someone help me out how can I do this?

我想要做的是在Jenkins中全局设置这个Java选项,但是没有找到它的任何配置。有人可以帮我解决这个问题吗?

The closest thing I was able to come up with is to set the argument through Maven, but I have to do it for each project configuration - and I'd like to avoid that.

我能够提出的最接近的事情是通过Maven设置参数,但我必须为每个项目配置执行此操作 - 我想避免这种情况。

Thanks in advance.

提前致谢。

4 个解决方案

#1


13  

Under the main menu item Manage Jenkins->Configure System you can set it in the box for Global MAVEN_OPTS.

在主菜单项Manage Jenkins-> Configure System下,您可以在Global MAVEN_OPTS的框中进行设置。

It is a bit unclear whether you want the option turned on for the Jenkins container itself or only the jobs running in it, but if the latter and you're only running maven jobs, that's what I would do.

您是否希望为Jenkins容器本身启用该选项或仅在其中运行的作业有点不清楚,但如果后者并且您只运行maven作业,那就是我要做的。

Cheers,

干杯,

#2


5  

If you deploy the Jenkins to the Tomcat or Glassfish, I would like to suggest you to set further configuration as the following:-

如果您将Jenkins部署到Tomcat或Glassfish,我建议您按以下方式设置进一步的配置: -

The Tomcat

Set the environment variable named CATALINA_OPTS, e.g.

设置名为CATALINA_OPTS的环境变量,例如

SET CATALINA_OPTS="-XX:-UseSplitVerifier"
EXPORT CATALINA_OPTS

The Glassfish

Edit the [your_domain]/config/domain.xml

编辑[your_domain] /config/domain.xml

<java-config ....>
    ....
    <jvm-options>-XX:-UseSplitVerifier</jvm-options>
</java-config>

Anyhow if you deploy it to another application server, please refer to your application server administrator guide to configure further JVM options.

无论如何,如果将其部署到另一个应用程序服务器,请参阅应用程序服务器管理员指南以配置更多JVM选项。

UPDATED:

If you only would like to apply this JVM option to the Maven project, please set the environment variable named MAVEN_OPTS, e.g.

如果您只想将此JVM选项应用于Maven项目,请设置名为MAVEN_OPTS的环境变量,例如:

SET MAVEN_OPTS="-XX:-UseSplitVerifier"
export MAVEN_OPTS

I hope this may help.

我希望这可能有所帮助。

Regards,

问候,

Charlee Ch.

Charlee Ch。

#3


2  

On Windows there's a jenkins.xml in Jenkins home directory. Simply add the required JVM options under arguments tag:

在Windows上,Jenkins主目录中有一个jenkins.xml。只需在参数标记下添加所需的JVM选项:

<arguments>
    -Xrs -Xmx256m -XX:-UseSplitVerifier 
    -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle 
    -jar "%BASE%\jenkins.war" --httpPort=8080
</arguments>

For most of the Linux distributions, modify JENKINS_ARGS inside file: /etc/default/jenkins (or jenkins-oc)

对于大多数Linux发行版,修改文件中的JENKINS_ARGS:/ etc / default / jenkins(或jenkins-oc)

For CentOS, modify JENKINS_JAVA_OPTIONS inside file: /etc/sysconfig/jenkins (or jenkins-oc)

对于CentOS,修改文件中的JENKINS_JAVA_OPTIONS:/ etc / sysconfig / jenkins(或jenkins-oc)

#4


0  

Apparently, the only way to set system-wide JVM properties in Jenkins is with a Groovy Script .

显然,在Jenkins中设置系统范围JVM属性的唯一方法是使用Groovy脚本。

Create a init.groovy.d in Jenkins home and place a groovy file in it (load-properties.groovy). In the Groovy script, set system properties programmatically (see link above for details):

在Jenkins home中创建一个init.groovy.d并在其中放置一个groovy文件(load-properties.groovy)。在Groovy脚本中,以编程方式设置系统属性(有关详细信息,请参阅上面的链接):

       props.each { key, value ->
        System.setProperty(key, value)

The above solution saved my day as I needed to disable jsse.enableSNIExtension during SCM checkout and it should be available to the SVN plugin, not to Maven.

上面的解决方案节省了我的一天,因为我需要在SCM结账期间禁用jsse.enableSNIExtension,它应该可用于SVN插件,而不是Maven。

There's a config.xml file with jdks/jdk/properties XML tags, but it's undocumented.

有一个带有jdks / jdk / properties XML标记的config.xml文件,但它没有文档。

#1


13  

Under the main menu item Manage Jenkins->Configure System you can set it in the box for Global MAVEN_OPTS.

在主菜单项Manage Jenkins-> Configure System下,您可以在Global MAVEN_OPTS的框中进行设置。

It is a bit unclear whether you want the option turned on for the Jenkins container itself or only the jobs running in it, but if the latter and you're only running maven jobs, that's what I would do.

您是否希望为Jenkins容器本身启用该选项或仅在其中运行的作业有点不清楚,但如果后者并且您只运行maven作业,那就是我要做的。

Cheers,

干杯,

#2


5  

If you deploy the Jenkins to the Tomcat or Glassfish, I would like to suggest you to set further configuration as the following:-

如果您将Jenkins部署到Tomcat或Glassfish,我建议您按以下方式设置进一步的配置: -

The Tomcat

Set the environment variable named CATALINA_OPTS, e.g.

设置名为CATALINA_OPTS的环境变量,例如

SET CATALINA_OPTS="-XX:-UseSplitVerifier"
EXPORT CATALINA_OPTS

The Glassfish

Edit the [your_domain]/config/domain.xml

编辑[your_domain] /config/domain.xml

<java-config ....>
    ....
    <jvm-options>-XX:-UseSplitVerifier</jvm-options>
</java-config>

Anyhow if you deploy it to another application server, please refer to your application server administrator guide to configure further JVM options.

无论如何,如果将其部署到另一个应用程序服务器,请参阅应用程序服务器管理员指南以配置更多JVM选项。

UPDATED:

If you only would like to apply this JVM option to the Maven project, please set the environment variable named MAVEN_OPTS, e.g.

如果您只想将此JVM选项应用于Maven项目,请设置名为MAVEN_OPTS的环境变量,例如:

SET MAVEN_OPTS="-XX:-UseSplitVerifier"
export MAVEN_OPTS

I hope this may help.

我希望这可能有所帮助。

Regards,

问候,

Charlee Ch.

Charlee Ch。

#3


2  

On Windows there's a jenkins.xml in Jenkins home directory. Simply add the required JVM options under arguments tag:

在Windows上,Jenkins主目录中有一个jenkins.xml。只需在参数标记下添加所需的JVM选项:

<arguments>
    -Xrs -Xmx256m -XX:-UseSplitVerifier 
    -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle 
    -jar "%BASE%\jenkins.war" --httpPort=8080
</arguments>

For most of the Linux distributions, modify JENKINS_ARGS inside file: /etc/default/jenkins (or jenkins-oc)

对于大多数Linux发行版,修改文件中的JENKINS_ARGS:/ etc / default / jenkins(或jenkins-oc)

For CentOS, modify JENKINS_JAVA_OPTIONS inside file: /etc/sysconfig/jenkins (or jenkins-oc)

对于CentOS,修改文件中的JENKINS_JAVA_OPTIONS:/ etc / sysconfig / jenkins(或jenkins-oc)

#4


0  

Apparently, the only way to set system-wide JVM properties in Jenkins is with a Groovy Script .

显然,在Jenkins中设置系统范围JVM属性的唯一方法是使用Groovy脚本。

Create a init.groovy.d in Jenkins home and place a groovy file in it (load-properties.groovy). In the Groovy script, set system properties programmatically (see link above for details):

在Jenkins home中创建一个init.groovy.d并在其中放置一个groovy文件(load-properties.groovy)。在Groovy脚本中,以编程方式设置系统属性(有关详细信息,请参阅上面的链接):

       props.each { key, value ->
        System.setProperty(key, value)

The above solution saved my day as I needed to disable jsse.enableSNIExtension during SCM checkout and it should be available to the SVN plugin, not to Maven.

上面的解决方案节省了我的一天,因为我需要在SCM结账期间禁用jsse.enableSNIExtension,它应该可用于SVN插件,而不是Maven。

There's a config.xml file with jdks/jdk/properties XML tags, but it's undocumented.

有一个带有jdks / jdk / properties XML标记的config.xml文件,但它没有文档。