Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SVN command line in jenkins fails due to server certificate mismatch

Tags:

svn

jenkins

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??

like image 912
Ran Cohen Avatar asked Aug 14 '12 11:08

Ran Cohen


2 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.

like image 147
Panda Pajama Avatar answered Sep 20 '22 14:09

Panda Pajama


I finally managed to solve the problem! What I did is simply put in Jenkins script:

echo p | svn up --username <usr> --password <pwrd>

This solved it! since the echo emulated the manual input to accept permanently the certificate.

Root Cause is the fact that Jenkins shell scripts run under the windows service user - thus uses a different place for the user profile cache (in C:\Windows\System32\config\systemprofile\AppData\Roaming\Subversion instead of %USERPROFILE%\AppData\Roaming\Subversion\)

like image 39
Ran Cohen Avatar answered Sep 16 '22 14:09

Ran Cohen