5

环境:Linux/Windows7、Java 1.6.0.03/37 或 1.7

我下载了 jenkins.war,在使用以下脚本/命令进行初始设置后,我下载了一些插件(10-15)并尝试重新启动 Jenkins,它成功了。然后,我又得到了一些插件(总共 30-40 个),我选择了安装或下载+然后+安装,Jenkins 没有出现。

即使用 startJenkins.sh(仅限 Linux)。注意:在 Windows7 上,Jenkins 作为 Windows 服务启动。

#!/bin/bash
export JAVA_HOME=/production/jenkinsAKS/java/jdk1.6.0_03
export JENKINS_HOME=/production/jenkinsAKS
export PATH=${JAVA_HOME}/bin:${PATH}
export JENKINS_HTTP_PORT=9040
export JENKINS_AJP13_PORT=9949
now=`date +%Y%m%d_%H%M%S`

echo  $0 begins ${now}
echo "   java-home=${JAVA_HOME}, jenkins-home=${JENKINS_HOME}, path=${PATH}"
java -jar ${JENKINS_HOME}/lib/jenkins.war -XX:MaxPermSize=4096m --logfile=${JENKINS_HOME}/log/jenkins.log${now} --httpPort=${JENKINS_HTTP_PORT} --ajp13Port=${JENKINS_AJP13_PORT} &

最初我没有使用“-XX:MaxPermSize=4096m”参数,但是当我看到以下错误消息时,我尝试了各种值,如 128/512/1024,2048,4096m 等,但对错误没有帮助。

INFO: Beginning extraction from war file
Jenkins home directory: /production/jenkinsAKS found at: EnvVars.masterEnvVars.get("JENKINS_HOME")
Aug 1, 2013 1:17:15 PM winstone.Logger logInternal
INFO: HTTP Listener started: port=9040
Aug 1, 2013 1:17:15 PM winstone.Logger logInternal
INFO: AJP13 Listener started: port=9949
Aug 1, 2013 1:17:15 PM winstone.Logger logInternal
INFO: Winstone Servlet Engine v0.9.10 running: controlPort=disabled
Aug 1, 2013 1:17:16 PM jenkins.InitReactorRunner$1 onAttained
INFO: Started initialization
Aug 1, 2013 1:17:16 PM jenkins.InitReactorRunner$1 onAttained
INFO: Listed all plugins
Aug 1, 2013 1:17:16 PM hudson.plugins.ansicolor.PluginImpl start
INFO: AnsiColor: eliminating boring output (https://github.com/dblock/jenkins-ansicolor-plugin)
Aug 1, 2013 1:17:16 PM org.jvnet.hudson.plugins.backup.BackupPluginImpl loadConfiguration
INFO: Loading configuration...
Aug 1, 2013 1:17:16 PM org.jvnet.hudson.plugins.backup.utils.BackupPersistence loadConfig
INFO: Config file not found.
Aug 1, 2013 1:17:18 PM ruby.RubyRuntimePlugin start
INFO: Injecting JRuby into XStream
Trying to load models from /production/jenkinsAKS/plugins/pathignore/WEB-INF/classes/models
Loading /production/jenkinsAKS/plugins/pathignore/WEB-INF/classes/models/pathignore_wrapper.rb
Aug 1, 2013 1:17:26 PM hudson.plugins.greenballs.PluginImpl start
INFO: Green Balls!
Aug 1, 2013 1:17:26 PM jenkins.InitReactorRunner$1 onAttained
INFO: Prepared all plugins
Aug 1, 2013 1:17:32 PM hudson.ExtensionFinder$GuiceFinder$FaultTolerantScope$1 error
WARNING: Failed to instantiate optional component org.jfrog.hudson.ivy.ArtifactoryIvyConfigurator$DescriptorImpl; skipping
Aug 1, 2013 1:17:32 PM jenkins.InitReactorRunner$1 onAttained
INFO: Started all plugins
Aug 1, 2013 1:17:32 PM jenkins.InitReactorRunner$1 onAttained
INFO: Augmented all extensions
Aug 1, 2013 1:17:32 PM jenkins.InitReactorRunner$1 onAttained
INFO: Loaded all jobs
Aug 1, 2013 1:17:32 PM hudson.plugins.scm_sync_configuration.ScmSyncConfigurationBusiness queueChangeSet
INFO: Queue of changeset     A hudson.model.UpdateCenter.xml
 aborted (scm manipulator not settled !)
Aug 1, 2013 1:17:32 PM org.jenkinsci.main.modules.sshd.SSHD start
INFO: Started SSHD at port 36227
Aug 1, 2013 1:17:32 PM jenkins.InitReactorRunner$1 onAttained
INFO: Completed initialization
Aug 1, 2013 1:17:32 PM hudson.TcpSlaveAgentListener <init>
INFO: JNLP slave agent listener started on TCP port 46056
The following triggers are available for your jobs
[Trigger] - Build periodically
[Trigger] - Build when another project is promoted
[Trigger] - Maven Dependency Update Trigger
[Trigger] - Poll SCM
[Trigger] - [BuildResultTrigger] - Monitor build results of other jobs
[Trigger] - [FSTrigger] - Monitor files
[Trigger] - [FSTrigger] - Monitor folder
[Trigger] - [IvyTrigger] - Poll with an Ivy script
[Trigger] - [ScriptTrigger] - Poll with a Groovy script
[Trigger] - [ScriptTrigger] - Poll with a shell or batch script
[Trigger] - [URLTrigger] - Poll with a URL
Aug 1, 2013 1:17:33 PM hudson.WebAppMain$2 run
INFO: Jenkins is fully up and running
Exception in thread "Jenkins cron thread" java.lang.OutOfMemoryError: PermGen space
Exception in thread "JmDNS(sagrdev3sb12.local.).State.Timer" java.lang.OutOfMemoryError: PermGen space
Exception in thread "ConnectorThread:[http-9040]" java.lang.OutOfMemoryError: PermGen space
Exception in thread "JmDNS(sagrdev3sb12.local.).Timer" java.lang.OutOfMemoryError: PermGen space
Exception in thread "WinstoneHostConfigurationMgmt:default" java.lang.OutOfMemoryError: PermGen space

或者有时我会看到:

    30  Aug 1, 2013 1:50:29 AM jenkins.InitReactorRunner$1 onAttained
    31  INFO: Prepared all plugins
    32  Exception in thread "pool-2-thread-20" java.lang.OutOfMemoryError: PermGen space
    33  Aug 1, 2013 1:51:10 AM winstone.Logger logInternal
    34  WARNING: Untrapped Error in Servlet
    35  java.lang.OutOfMemoryError: PermGen space
    36  Aug 1, 2013 1:51:12 AM winstone.Logger logInternal
    37  SEVERE: Error in the error servlet
    38  java.lang.OutOfMemoryError: PermGen space
    39  Exception in thread "Jenkins cron thread" java.lang.OutOfMemoryError: PermGen space
-bash-3.2$

我该如何解决这个问题?当我在我的 Windows 台式机上做同样的练习时,同样的问题出现了。我需要使用更少或有限数量的插件吗?

谢谢

4

2 回答 2

9

在我的 ~/.bash_profile 文件中,我设置了以下 3 个变量。请注意,此文件中还有其他变量,即 JAVA_HOME、ANT_HOME、SONAR_HOME、SONAR_RUNNER_HOME 等:

export JAVA_OPTS="-XX:MaxPermSize=512m -Xms512m -Xmx1024m"
export GRADLE_OPTS="-XX:MaxPermSize=512m"
export SONAR_RUNNER_OPTS="-Xmx512m -XX:MaxPermSize=512m"

所有 - 现在工作。

第一个导出行:将使 Jenkins 在没有 PermGen 错误的情况下运行,当 Jenkins 调用 Gradle 脚本(通过另一个包装脚本,例如 .sh/etc)时,第二行将使 Gradle 运行,第三行使“sonar-runner”命令工作正常(否则,在 sonar-runner 命令输出期间的“Initialize Hibernate”... 行之后,我收到 PermGen 的错误)。您在已编译 java、与静态代码分析工具 (pmd/checkstyle/findbugs) 和其他代码覆盖率报告 (jacoco/cobertura) 相关的报告的工作区中运行 sonar-runner 命令。工作区应该有“sonar-project.properties”文件。查找有关此文件的 SonarQube 帮助页面以及它包含的项目的所有变量。

所有这些选项都记录在此处: http ://docs.oracle.com/javase/8/docs/technotes/tools/windows/java.html 或者如果您使用的是 Java 7,则在此处:http: //docs.oracle.com /javase/7/docs/technotes/tools/windows/java.html

于 2013-09-03T14:13:22.900 回答
0

如果您使用 Gradle,您可以通过在 Jenkins 全局配置中添加 GRADLE_OPTS 全局环境变量来设置 -Xmx 或 -XX:MaxPermSize。为此,请单击管理 Jenkins,然后单击配置系统。在 Global properties 部分,单击 Environment Variables 复选框,然后添加一个名为 GRADLE_OPTS 的新环境变量,其值设置如下:

name: GRADLE_OPTS value: -Xmx1024m -XX:MaxPermSize=1024m

其中 1024 是指定的内存。您可以根据需要更改它。

Maven 需要类似的配置。有关详细信息,请参阅下面的链接: https ://wiki.jenkins-ci.org/display/JENKINS/Builds+failing+with+OutOfMemoryErrors

于 2016-04-18T08:56:47.073 回答