如何修复 Jenkins java.lang.IllegalStateException:在加载之前尝试保存全局配置
How to fix Jenkins java.lang.IllegalStateException: An attempt to save the global configuration was made before it was loaded
我从 jenkins 2.219 升级到 2.272(撰写本文时的最新版本),现在在 Jenkins 启动时得到下面的堆栈跟踪。
Jenkins 文档说发生这种情况是由于配置为代码插件并将 jvm 参数设置为 -Dio.jenkins.plugins.casc.ConfigurationAsCode.initialDelay=9000
。文档还说要增加值直到错误消失,但到目前为止我在 480000
并且仍然收到错误。我也没有看到我安装了 Configuration as Code 插件。
如何解决这个问题?
java.lang.IllegalStateException: An attempt to save the global configuration was made before it was loaded
at jenkins.model.Jenkins.save(Jenkins.java:3379)
at jenkins.model.Jenkins.saveQuietly(Jenkins.java:3398)
at jenkins.model.Jenkins.setSecurityRealm(Jenkins.java:2637)
at jenkins.model.Jenkins.run(Jenkins.java:3342)
at org.jvnet.hudson.reactor.TaskGraphBuilder$TaskImpl.run(TaskGraphBuilder.java:169)
at org.jvnet.hudson.reactor.Reactor.runTask(Reactor.java:296)
at jenkins.model.Jenkins.runTask(Jenkins.java:1129)
at org.jvnet.hudson.reactor.Reactor.run(Reactor.java:214)
at org.jvnet.hudson.reactor.Reactor$Node.run(Reactor.java:117)
at jenkins.security.ImpersonatingExecutorService.run(ImpersonatingExecutorService.java:68)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused: org.jvnet.hudson.reactor.ReactorException
at org.jvnet.hudson.reactor.Reactor.execute(Reactor.java:282)
at jenkins.InitReactorRunner.run(InitReactorRunner.java:50)
at jenkins.model.Jenkins.executeReactor(Jenkins.java:1162)
at jenkins.model.Jenkins.<init>(Jenkins.java:962)
at hudson.model.Hudson.<init>(Hudson.java:85)
at hudson.model.Hudson.<init>(Hudson.java:81)
at hudson.WebAppMain.run(WebAppMain.java:295)
Caused: hudson.util.HudsonFailedToLoad
at hudson.WebAppMain.run(WebAppMain.java:312)
我遇到了同样的问题。我已经从 https://www.jenkins.io/download/ 下载了 jenkins.war 的早期版本 (2.263.1)。停止 jenkins 并将 war 替换为我的安装目录 (C:\Program Files\Jenkins)。并开始了 jenkins.This 的工作。
我们升级到最新版本后遇到了同样的问题。
经过一番搜索后,我们决定使用具有 LTS 支持的较低版本,在本例中为 2.263.1。
该版本立即运行,所以我认为这个错误是一个错误。
我们有类似的问题,通过降级从 URL 下载的 jenkins.war 文件解决:https://get.jenkins.io/war-stable/2.263.1/
对于遇到此问题的任何人,是的,首先需要降级到 https://get.jenkins.io/war-stable/2.263.1/。然后重新启动服务,然后升级所有插件,然后再次尝试 LTS 升级,至少对我来说它工作得很好。
有关此问题的更多详细信息,请点击此处:
https://www.jenkins.io/doc/upgrade-guide/2.204/
SEVERE jenkins.InitReactorRunner#onTaskFailed: Failed
ConfigurationAsCode.init java.lang.IllegalStateException: An attempt
to save the global configuration was made before it was loaded If
you encounter this, you can tell the plugin to delay configuration for
an amount of time to give Jenkins time to load the global
configuration before the configuration is applied by the plugin.
To enable this set the
io.jenkins.plugins.casc.ConfigurationAsCode.initialDelay system
property to a number of milliseconds to delay the initialisation. The
required value will be dependant on aspects of your system (cpu/disk)
and configuration, and how it can be found is mostly a trial and
error. A suggestion would be to start with 5000 (5 Seconds) and then
increment by 2000 (2 seconds) until you no longer exhibit the issue
and finally add 1000 (1 second) for some extra safety. For example, to
delay the configuration by 9 seconds you would use something like the
following command java
-Dio.jenkins.plugins.casc.ConfigurationAsCode.initialDelay=9000 -jar jenkins.war. Exactly how and where you specify this option depends on
the installation method used to install Jenkins
但是对我来说,如果没有先降级,升级所有插件,然后最后再次升级核心,解决方法就不起作用了。
您可以下载 hpi 并将 hpi 文件放入 JENKINS_HOME/plugins 文件夹。通常 jenkins 插件目录将在 - /var/lib/jenkins/plugins/
.
下
link 获取 Role strategy hpi 插件 - https://updates.jenkins.io/latest/role-strategy.hpi。并使用此命令重新启动 Jenkins:systemctl restart jenkins
.
为了在你没有安装Casc插件的情况下提前避免这个问题:
Update to https://github.com/jenkinsci/role-strategy-plugin/releases/tag/role-strategy-3.1 and you should be OK.
当jenkins已经处于故障状态时:
download the hpi and drop the hpi file into JENKINS_HOME/plugins folder.
https://updates.jenkins.io/download/plugins/role-strategy/
(信息取自:https://github.com/jenkinsci/configuration-as-code-plugin/issues/1531)
我遇到过类似的问题,发现不需要降级。
以下是我执行的步骤,它对我有用
首先从 Jenkins 控制台升级全局插件,即基于角色的授权策略。
以下是我执行的步骤:
#on ubuntu, in /usr/share/jenkins
:
sudo service jenkins stop
sudo mv jenkins.war jenkins.war.old
sudo wget https://updates.jenkins-ci.org/latest/jenkins.war
sudo chown -R jenkins:jenkins jenkins.war
sudo service jenkins start
我的方案是将 Jenkins 升级到最新版本,然后恢复其中的数据,使其像以前一样工作。
从 Jenkins v2.263 升级到 v2.303 时,我遇到了同样的错误。唯一对我有用的是 升级我的全局插件,即首先升级基于角色的授权策略,然后是 Jenkins。它工作得很好。
我在 Jenkins 2.332.2 和更新的插件 role-strategy v483.v17281966f5c3 上有同样的错误。
我只好下载3.2.0版本的插件,直接放到jenkins plugins文件夹下。 (之前我删除了现有的“.jpi”文件)
然后重新启动 Jenkins /etc/init.d/jenkins restart
,问题就解决了。
谢谢你的情报!
我从 jenkins 2.219 升级到 2.272(撰写本文时的最新版本),现在在 Jenkins 启动时得到下面的堆栈跟踪。
Jenkins 文档说发生这种情况是由于配置为代码插件并将 jvm 参数设置为 -Dio.jenkins.plugins.casc.ConfigurationAsCode.initialDelay=9000
。文档还说要增加值直到错误消失,但到目前为止我在 480000
并且仍然收到错误。我也没有看到我安装了 Configuration as Code 插件。
如何解决这个问题?
java.lang.IllegalStateException: An attempt to save the global configuration was made before it was loaded
at jenkins.model.Jenkins.save(Jenkins.java:3379)
at jenkins.model.Jenkins.saveQuietly(Jenkins.java:3398)
at jenkins.model.Jenkins.setSecurityRealm(Jenkins.java:2637)
at jenkins.model.Jenkins.run(Jenkins.java:3342)
at org.jvnet.hudson.reactor.TaskGraphBuilder$TaskImpl.run(TaskGraphBuilder.java:169)
at org.jvnet.hudson.reactor.Reactor.runTask(Reactor.java:296)
at jenkins.model.Jenkins.runTask(Jenkins.java:1129)
at org.jvnet.hudson.reactor.Reactor.run(Reactor.java:214)
at org.jvnet.hudson.reactor.Reactor$Node.run(Reactor.java:117)
at jenkins.security.ImpersonatingExecutorService.run(ImpersonatingExecutorService.java:68)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused: org.jvnet.hudson.reactor.ReactorException
at org.jvnet.hudson.reactor.Reactor.execute(Reactor.java:282)
at jenkins.InitReactorRunner.run(InitReactorRunner.java:50)
at jenkins.model.Jenkins.executeReactor(Jenkins.java:1162)
at jenkins.model.Jenkins.<init>(Jenkins.java:962)
at hudson.model.Hudson.<init>(Hudson.java:85)
at hudson.model.Hudson.<init>(Hudson.java:81)
at hudson.WebAppMain.run(WebAppMain.java:295)
Caused: hudson.util.HudsonFailedToLoad
at hudson.WebAppMain.run(WebAppMain.java:312)
我遇到了同样的问题。我已经从 https://www.jenkins.io/download/ 下载了 jenkins.war 的早期版本 (2.263.1)。停止 jenkins 并将 war 替换为我的安装目录 (C:\Program Files\Jenkins)。并开始了 jenkins.This 的工作。
我们升级到最新版本后遇到了同样的问题。 经过一番搜索后,我们决定使用具有 LTS 支持的较低版本,在本例中为 2.263.1。 该版本立即运行,所以我认为这个错误是一个错误。
我们有类似的问题,通过降级从 URL 下载的 jenkins.war 文件解决:https://get.jenkins.io/war-stable/2.263.1/
对于遇到此问题的任何人,是的,首先需要降级到 https://get.jenkins.io/war-stable/2.263.1/。然后重新启动服务,然后升级所有插件,然后再次尝试 LTS 升级,至少对我来说它工作得很好。
有关此问题的更多详细信息,请点击此处: https://www.jenkins.io/doc/upgrade-guide/2.204/
SEVERE jenkins.InitReactorRunner#onTaskFailed: Failed ConfigurationAsCode.init java.lang.IllegalStateException: An attempt to save the global configuration was made before it was loaded If you encounter this, you can tell the plugin to delay configuration for an amount of time to give Jenkins time to load the global configuration before the configuration is applied by the plugin.
To enable this set the io.jenkins.plugins.casc.ConfigurationAsCode.initialDelay system property to a number of milliseconds to delay the initialisation. The required value will be dependant on aspects of your system (cpu/disk) and configuration, and how it can be found is mostly a trial and error. A suggestion would be to start with 5000 (5 Seconds) and then increment by 2000 (2 seconds) until you no longer exhibit the issue and finally add 1000 (1 second) for some extra safety. For example, to delay the configuration by 9 seconds you would use something like the following command java -Dio.jenkins.plugins.casc.ConfigurationAsCode.initialDelay=9000 -jar jenkins.war. Exactly how and where you specify this option depends on the installation method used to install Jenkins
但是对我来说,如果没有先降级,升级所有插件,然后最后再次升级核心,解决方法就不起作用了。
您可以下载 hpi 并将 hpi 文件放入 JENKINS_HOME/plugins 文件夹。通常 jenkins 插件目录将在 - /var/lib/jenkins/plugins/
.
link 获取 Role strategy hpi 插件 - https://updates.jenkins.io/latest/role-strategy.hpi。并使用此命令重新启动 Jenkins:systemctl restart jenkins
.
为了在你没有安装Casc插件的情况下提前避免这个问题:
Update to https://github.com/jenkinsci/role-strategy-plugin/releases/tag/role-strategy-3.1 and you should be OK.
当jenkins已经处于故障状态时:
download the hpi and drop the hpi file into JENKINS_HOME/plugins folder. https://updates.jenkins.io/download/plugins/role-strategy/
(信息取自:https://github.com/jenkinsci/configuration-as-code-plugin/issues/1531)
我遇到过类似的问题,发现不需要降级。 以下是我执行的步骤,它对我有用
首先从 Jenkins 控制台升级全局插件,即基于角色的授权策略。
以下是我执行的步骤: #on ubuntu, in
/usr/share/jenkins
:
sudo service jenkins stop
sudo mv jenkins.war jenkins.war.old
sudo wget https://updates.jenkins-ci.org/latest/jenkins.war
sudo chown -R jenkins:jenkins jenkins.war
sudo service jenkins start
我的方案是将 Jenkins 升级到最新版本,然后恢复其中的数据,使其像以前一样工作。
从 Jenkins v2.263 升级到 v2.303 时,我遇到了同样的错误。唯一对我有用的是 升级我的全局插件,即首先升级基于角色的授权策略,然后是 Jenkins。它工作得很好。
我在 Jenkins 2.332.2 和更新的插件 role-strategy v483.v17281966f5c3 上有同样的错误。
我只好下载3.2.0版本的插件,直接放到jenkins plugins文件夹下。 (之前我删除了现有的“.jpi”文件)
然后重新启动 Jenkins /etc/init.d/jenkins restart
,问题就解决了。
谢谢你的情报!