Дженкинс не может прочитать config.xml : хадсон.безопасность.Глобальная матрица авторизации стратегии Хадсон.безопасность.LDAPSecurityRealm

#jenkins

#дженкинс

Вопрос:

Использование Jenkins 2.169

Сегодня сервер Jenkins внезапно вышел из строя со следующей ошибкой:

 SEVERE: Failed Loading global config
java.io.IOException: Unable to read /somewhere/jenkins/home/config.xml
    at hudson.XmlFile.unmarshal(XmlFile.java:181)
    at hudson.XmlFile.unmarshal(XmlFile.java:161)
    at jenkins.model.Jenkins.loadConfig(Jenkins.java:3043)
    at jenkins.model.Jenkins.access$1300(Jenkins.java:309)
    at jenkins.model.Jenkins$13.run(Jenkins.java:3145)
    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:1096)
    at org.jvnet.hudson.reactor.Reactor$2.run(Reactor.java:214)
    at org.jvnet.hudson.reactor.Reactor$Node.run(Reactor.java:117)
    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:748)
    Caused by: jenkins.util.xstream.CriticalXStreamException: hudson.security.GlobalMatrixAuthorizationStrategy :   hudson.security.GlobalMatrixAuthorizationStrategy
    ---- Debugging information ----
    message             : hudson.security.GlobalMatrixAuthorizationStrategy
    cause-exception     :   com.thoughtworks.xstream.mapper.CannotResolveClassException
    cause-message       : hudson.security.GlobalMatrixAuthorizationStrategy
    class               : hudson.model.Hudson
    required-type       : hudson.model.Hudson
    converter-type      : hudson.util.RobustReflectionConverter
    path                : /hudson/authorizationStrategy
    line number         : 12
    version             : not available
    -------------------------------
    at hudson.util.RobustReflectionConverter.doUnmarshal(RobustReflectionConverter.java:354)
    at hudson.util.RobustReflectionConverter.unmarshal(RobustReflectionConverter.java:268)
    at  com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
    at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.start(TreeUnmarshaller.java:134)
    at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.unmarshal(AbstractTreeMarshallingStrategy.java:32)
    at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1189)
    at hudson.util.XStream2.unmarshal(XStream2.java:161)
    at hudson.util.XStream2.unmarshal(XStream2.java:132)
    at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1173)
    at hudson.XmlFile.unmarshal(XmlFile.java:178)
    ... 12 more
    Caused by: com.thoughtworks.xstream.mapper.CannotResolveClassException: hudson.security.GlobalMatrixAuthorizationStrategy
  

Выяснилось, что причиной были два отсутствующих плагина:
matrix-auth
ldap

Я мог бы восстановить Jenkins, вручную скопировав плагины с другого сервера. Скопированные файлы:

 jenkins/home/plugins/matrix-auth
jenkins/home/plugins/matrix-auth.jpi
jenkins/home/plugins/ldap
jenkins/home/plugins/ldap.jpi
  

Сначала я установил matrix-auth. Затем я получил следующую ошибку, которая указывала, что у ldap также были проблемы:

 Caused by: jenkins.util.xstream.CriticalXStreamException:
hudson.security.LDAPSecurityRealm : hudson.security.LDAPSecurityRealm
---- Debugging information ----
message             : hudson.security.LDAPSecurityRealm
cause-exception     :   
com.thoughtworks.xstream.mapper.CannotResolveClassException
cause-message       : hudson.security.LDAPSecurityRealm
class               : hudson.model.Hudson
required-type       : hudson.model.Hudson
converter-type      : hudson.util.RobustReflectionConverter
path                : /hudson/securityRealm
line number         : 53
version             : not available
-------------------------------
  

После дальнейшего расследования выяснилось, что было удалено множество плагинов (кроме того, я выяснил виновника, и это не связано с Дженкинсом). Итак, частью решения было скопировать весь каталог плагинов с другого сервера Jenkins.

Комментарии:

1. Вам удалось это исправить?

2. Я помню, что мне пришлось скопировать плагины (к счастью, у меня был другой сервер Jenkins с такой же конфигурацией, поэтому я просто скопировал недостающие плагины).

Ответ №1:

Это произошло из-за неправильного синтаксиса вашего файла конфигурации.

 sudo service jenkins stop

mv config.xml config.xml_bkp

sudo service jenkins start
  

это исправит это, поскольку создаст новый config.xml в каталоге jenkins на вашем главном сервере

Ответ №2:

Это случилось со мной при попытке обновить Jenkins, используя старую версию стратегии аутентификации Matrix.

Я был в ужасе от простоя службы (у нас не было хорошей промежуточной среды). Но все прошло хорошо после обновления плагина до последней версии, а затем и обновления Jenkins.