SVN command line in jenkins fails due to server certificate mismatch

Viewed 19097

When I run the svn command line from the Jenkins shell I get this error:

 D:\Jenkins\jobs\Merge Trunk to Stable\workspace\stable>svn up --trust-server-cert --non-interactive 
 Updating '.':
 svn: E175002: Unable to connect to a repository at URL 'https://xxx/stable'
 svn: E175002: OPTIONS of 'https://xxx/stable': Server certificate verification failed: certificate issued for a different hostname,  issuer is not trusted (https://xxx)

But when I run the same from the command line CMD window it is OK:

 D:\Jenkins\jobs\Merge Trunk to Stable\workspace\stable>svn up
 Updating '.':
 At revision 1797.

or

 D:\Jenkins\jobs\Merge Trunk to Stable\workspace\stable>svn up --trust-server-cert --non-interactive
 Updating '.':
 At revision 1797.

Any idea how to solve this??

8 Answers

Pretty old question, but still quite alive.

As you know, the problem is that the accepted certificate cache (as well as the username/password cache) is per-user, and since Jenkins is running as a different user (most likely SYSTEM), it has no idea of your regular user cache.

Not all SVN clients let you do the "echo p" thing there (it didn't work for me), and the --trust-server-cert apparently doesn't work in this case either.

What worked for me was to open a console window as SYSTEM, and do the interactive acceptcertificate-login-password dance in there.

Since all of this is cached, you only need to do this once, and from then on, all svn up and similar requests will work.

This may happen even you had accept the certificate.

In Linux, Jenkins use its own username. You can use command sudo su jenkins switch to jenkins user , then use command cd ~ and ls to see the jenkins user's root path. For me, it is the jenkins install path (var/lib/jenkins).

You can see .subversion package in your user package. If you had accept the certificate before, you can see auth package in .subversion.

Copy the whole .subversion package to the jenkins install package(jenkins user's root path).

Try it again, use svn up command in jenkins shell and it would work.

My English is poor, thanks for your reading.

Related