一、起因:
因为集成Android Studio 到Jenkins自动发布,安装了最新gradle插件,导致Jenkins自启后很多job丢失,这些job是节省时间、避免出错的重要工具,一定需要恢复。
二、解决:
-
(1)在mac找到jenkins 目录,备份之(一般在目录/Users/Shared/Jenkins/Home)
-
(2)升级Jenkins 到建议的版本。
这里直接下载Jenkins.war 文件,替换mac 应用程序中的 Jenkins.war。
mac 应用程序Jenkins目录可以在Finder中快速找到:
(3)升级后Jenkins启动失败的处理:
升级后,如果报错如下,再换回原来的Jenkins.war多半也是不行的。为什么启动失败,可能是因为新版本兼容的格式已经发生了变化,而咱们的配置并没有改。
找了很久,最后发现可能是Jenkins版本固有的问题。
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$16.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$5.runTask(Jenkins.java:1129)
at org.jvnet.hudson.reactor.Reactor$2.run(Reactor.java:214)
at org.jvnet.hudson.reactor.Reactor$Node.run(Reactor.java:117)
at jenkins.security.ImpersonatingExecutorService$1.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$3.run(WebAppMain.java:295)
Caused: hudson.util.HudsonFailedToLoad
at hudson.WebAppMain$3.run(WebAppMain.java:312)
解决:
从以下网址下载该版本Jenkins,替换重启解决问题。
https://get.jenkins.io/war-stable/2.263.1/
参考:
https://stackoverflow.com/questions/65441139/how-to-fix-jenkins-java-lang-illegalstateexception-an-attempt-to-save-the-globa