Load Jenkins config from config.xml

Jenkins

I'm attempting to get my infrastucture defined as code. To do this I've spun up 2 jenkins servers with puppet. I then manually configured one, and copied the working config.xml to the other.

Since jenkins has the ability to read in the config.xml file, I would expect the second jenkins server to be an identical twin of the first.

Unfortunatly the second jenkins server crashes at startup with the following error:

Manager password must not be empty or null.

Things I've tried:

  • do a recursive grep of the /var/lib/jenkins directory looking for any string that matches 'managerPassword' (found 0)
  • copy the secrets files and directories from the old to the new one.

About:

Jenkins 1.572
Ldap plugin 1.10.2

I'm sure there is a way to copy the config from one jenkins server to another.
Has anyone done it?
What files am I missing?

Full Error:

hudson.util.HudsonFailedToLoad: org.jvnet.hudson.reactor.ReactorException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'initialDirContextFactory': Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'managerPassword' threw exception; nested exception is java.lang.IllegalArgumentException: Manager password must not be empty or null.
at hudson.WebAppMain$3.run(WebAppMain.java:234)
Caused by: org.jvnet.hudson.reactor.ReactorException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'initialDirContextFactory': Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'managerPassword' threw exception; nested exception is java.lang.IllegalArgumentException: Manager password must not be empty or null.
at org.jvnet.hudson.reactor.Reactor.execute(Reactor.java:269)
at jenkins.InitReactorRunner.run(InitReactorRunner.java:44)
at jenkins.model.Jenkins.executeReactor(Jenkins.java:896)
at jenkins.model.Jenkins.<init>(Jenkins.java:795)
at hudson.model.Hudson.<init>(Hudson.java:82)
at hudson.model.Hudson.<init>(Hudson.java:78)
at hudson.WebAppMain$3.run(WebAppMain.java:222)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'initialDirContextFactory': Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'managerPassword' threw exception; nested exception is java.lang.IllegalArgumentException: Manager password must not be empty or null.
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1279)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1010)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
at java.security.AccessController.doPrivileged(Native Method)
at

Update

I tried recursivly (and while preserving permissions) copying the entire /var/lib/jenkins directory from the primary server to the secondary and restarted. It gives the same error about 'managerPassword'

Best Answer

I had the same exact error very recently. I realized after setting security to false in config.xml and manually setting up ldap on the new host that I forgot to import the certificate to the java keystore as we are using ldaps. Here are the steps I took to resolve the problem. For reference, I'm using java-1.7.0-openjdk-1.7.0.65, jenkins v1.568 on Centos 6.5 fully updated.

Stop Jenkins

service jenkins stop

Sync Jenkins home dir (used -I flag to overwrite existing files):

rsync -avI user@old_host:/var/lib/jenkins/* /var/lib/jenkins/

Backup cacerts on the new host:

cp /etc/pki/java/cacerts /some/backup/dir

Copy cacerts from old host to new (or import via keytool if you have other certs on that new host you need to keep):

scp user@old_host:/etc/pki/java/cacerts /etc/pki/java/cacerts

(import method: keytool -import -alias "some-name-for-cert" -keystore cacerts -trustcacerts -file "/path/to/cert.crt")

Start Jenkins

service jenkins start

Unfortunately I don't have enough reputation to comment and recommend importing a cert so please don't be harsh if this doesn't fix it. I signed up here when I came across your error. Hope it helps!

Related Topic