【问题标题】:After upgrading to new Jenkins version, builds are failing升级到新的 Jenkins 版本后,构建失败
【发布时间】:2023-11-02 06:29:01
【问题描述】:

我刚刚将 jenkins 从 2.63 升级到 2.117(我现在很后悔)

这是我在所有作业结束时收到的错误消息。

请帮助我理解并解决这个问题。

    FATAL: java.lang.RuntimeException: Failed to serialize hudson.model.Actionable#actions for class hudson.model.FreeStyleBuild
java.lang.UnsupportedOperationException: Refusing to marshal java.io.PrintStream for security reasons; see https://jenkins.io/redirect/class-filter/
    at hudson.util.XStream2$BlacklistedTypesConverter.marshal(XStream2.java:543)
    at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
    at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
    at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:84)
    at hudson.util.RobustReflectionConverter.marshallField(RobustReflectionConverter.java:265)
    at hudson.util.RobustReflectionConverter$2.writeField(RobustReflectionConverter.java:252)
Caused: java.lang.RuntimeException: Failed to serialize org.jenkinsci.plugins.EnvironmentVarSetter#log for class org.jenkinsci.plugins.EnvironmentVarSetter
    at hudson.util.RobustReflectionConverter$2.writeField(RobustReflectionConverter.java:256)
    at hudson.util.RobustReflectionConverter$2.visit(RobustReflectionConverter.java:224)
    at com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider.visitSerializableFields(PureJavaReflectionProvider.java:138)
    at hudson.util.RobustReflectionConverter.doMarshal(RobustReflectionConverter.java:209)
    at hudson.util.RobustReflectionConverter.marshal(RobustReflectionConverter.java:150)
    at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
    at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
    at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:43)
    at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:88)
    at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.writeItem(AbstractCollectionConverter.java:64)
    at com.thoughtworks.xstream.converters.collections.CollectionConverter.marshal(CollectionConverter.java:74)
    at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
    at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
    at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:84)
    at hudson.util.RobustReflectionConverter.marshallField(RobustReflectionConverter.java:265)
    at hudson.util.RobustReflectionConverter$2.writeField(RobustReflectionConverter.java:252)
Caused: java.lang.RuntimeException: Failed to serialize hudson.model.Actionable#actions for class hudson.model.FreeStyleBuild
    at hudson.util.RobustReflectionConverter$2.writeField(RobustReflectionConverter.java:256)
    at hudson.util.RobustReflectionConverter$2.visit(RobustReflectionConverter.java:224)
    at com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider.visitSerializableFields(PureJavaReflectionProvider.java:138)
    at hudson.util.RobustReflectionConverter.doMarshal(RobustReflectionConverter.java:209)
    at hudson.util.RobustReflectionConverter.marshal(RobustReflectionConverter.java:150)
    at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
    at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
    at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:43)
    at com.thoughtworks.xstream.core.TreeMarshaller.start(TreeMarshaller.java:82)
    at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.marshal(AbstractTreeMarshallingStrategy.java:37)
    at com.thoughtworks.xstream.XStream.marshal(XStream.java:1026)
    at com.thoughtworks.xstream.XStream.marshal(XStream.java:1015)
    at com.thoughtworks.xstream.XStream.toXML(XStream.java:988)
    at hudson.XmlFile.write(XmlFile.java:193)
Caused: java.io.IOException
    at hudson.XmlFile.write(XmlFile.java:200)
    at hudson.model.Run.save(Run.java:1923)
    at hudson.model.Run.setDisplayName(Run.java:803)
    at org.jenkinsci.plugins.buildnamesetter.BuildNameSetter.setDisplayName(BuildNameSetter.java:76)
    at org.jenkinsci.plugins.buildnamesetter.BuildNameSetter.access$000(BuildNameSetter.java:31)
    at org.jenkinsci.plugins.buildnamesetter.BuildNameSetter$1.tearDown(BuildNameSetter.java:64)
    at hudson.model.Build$BuildExecution.doRun(Build.java:174)
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:504)
    at hudson.model.Run.execute(Run.java:1727)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    at hudson.model.ResourceController.execute(ResourceController.java:97)
    at hudson.model.Executor.run(Executor.java:429)

注意:其他使用旧版本 jenkins 的人,很有可能你的所有工作都会搞砸。所以,现在请不要更新詹金斯。 (https://jenkins.io/blog/2018/03/15/jep-200-lts/)

【问题讨论】:

  • 听起来您在 Jenkins 的文件上丢失了“写入”权限。你能检查一下 Jenkins 试图写入的文件,并确保他们有权限吗?
  • 你是说詹金斯战争文件?
  • Caused: java.io.IOException at hudson.XmlFile.write(XmlFile.java:200) at hudson.model.Run.save(Run.java:1923) 我的意思是这个文件,即导致异常
  • 你有 Build-name-setter 插件吗?如果不是,可能是其他未更新的插件
  • @luc 我想我可以为此设置权限。但是,是的,让我检查一下。

标签: java jenkins continuous-integration jenkins-pipeline hudson


【解决方案1】:

你可以试试Jenkins官网给出的解决方案 https://issues.jenkins-ci.org/browse/JENKINS-49144

将以下三个条目添加到 whitelisted-classes.txt:

java.util.concurrent.locks.ReentrantLock
java.util.concurrent.locks.ReentrantLock$NonfairSync
java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject

【讨论】:

  • 好的。但是,我对这些东西有点陌生。在哪里可以找到 whitelisted-classes.txt?
【解决方案2】:

这与两件事有关。

  1. 更新到 .war 文件的权限。
  2. Build Pipeline 插件需要更新。

这解决了我的问题。

【讨论】:

    【解决方案3】:

    这是 Jenkins https://github.com/jenkinsci/jep/tree/master/jep/200 中已知的安全修复程序。

    您可以查看受影响插件列表https://wiki.jenkins.io/display/JENKINS/Plugins+affected+by+fix+for+JEP-200 并升级受影响的插件以克服错误。

    【讨论】: