This week, in a customer, I had to write a Groovy script to import some projects from an old installation. The SVN URL had changed. Not only the domain, but now the SVN structure was broken in modules (i.e. instead of /svn/… now there was /repo1/…, /repo2/…, etc).
The solution I found, was scan the SVN directory structure with Perl and produce a JSON file. Then I wrote a quick PHP application (with Slim) with an URL like /repo?projectName=XYZ, that returned the new repository URL.
The last step was the hardest, since I needed to query the REST application. The script would get the current SVN address from the SVN SCM, query the REST URL to get the new URL, and lastly update the job with the new URL.
The solution I found was copy the necessary jars to jenkins lib/ folder, restart the server and execute my script. Then stop the server, remove the jars and check the new SVN URL’s. Here’s the list of jars I had to copy.
If you have a Maven project with your REST client, you can get a list of dependencies with
mvn dependency:copy-dependencies
. Then copy the jars to Jenkins class path.