We use SVN with SSH because it is better than anonymous access and the HTTP setup looked complicated and difficult to use when I was setting up authenticated SVN.
Subversion uses a custom port because it is running in a docker image and we use the default SSH port for SSH access to the host.
We use the .ssh/config file to automatically select the correct port.
As a result, all our SVN externals do not specify the port number. Maybe they should. I don’t know, but it will be a huge amount of work to change them.
The result is that when I configure a job, which has externals because they all do, I can specify a port number in the top level SVN URL, but that doesn’t help me because checking out all the externals fails.
I tried setting the SVN_SSH environment variable, but maybe I need to reload Jenkins or something because it doesn’t seem to help at all.
If I create /home/jenkins/.ssh/config on the docker image, will that solve the problem? Will the Jenkins Subversion plugin pick it up? Or does it need to be in /var/lib/jenkins/.ssh/config?
If you create the .ssh/config file on the Docker image, it will not solve the problem, as Jenkins runs as a separate process and has its own home directory.
The Jenkins Subversion plugin uses the .subversion/config file in the home directory of the Jenkins user to read the SSH configuration. You can try adding the necessary configuration to this file by following these steps:
Connect to the Jenkins server using SSH or any other method that allows you to access the file system.
Navigate to the home directory of the Jenkins user, which is typically /var/lib/jenkins.
Create the .subversion directory if it does not exist: mkdir ~/.subversion.
Create the config file in the .subversion directory: touch ~/.subversion/config.
Open the config file in a text editor and add the necessary SSH configuration, such as:
[tunnels]
ssh = ssh -p 2222
Replace 2222 with the custom port number that you are using for SSH.
Save the file and exit the text editor.
After adding the SSH configuration to the config file, you may need to restart the Jenkins service for the changes to take effect. Once the changes are in effect, the Jenkins Subversion plugin should be able to read the SSH configuration from the config file and use the correct port number when checking out the externals.
When explicitly setting the port number in the main URL, I get:
`Started by user Alastair Growcott
Running as SYSTEM
Building in workspace /var/lib/jenkins/workspace/Firmware/AzipodDriver
Checking out a fresh workspace because there’s no workspace at /var/lib/jenkins/workspace/Firmware/AzipodDriver
Cleaning local Directory . Checking out svn+ssh://subversion.dynautics.local:2223/storage/repo/trunk/Firmware/AzipodDriver at revision ‘2023-03-06T10:53:50.660 +0000’ --quiet
Using sole credentials jenkins (Subversion) in realm ?svn+ssh://subversion.dynautics.local:2223?
Using sole credentials jenkins (Subversion) in realm ?svn+ssh://subversion.dynautics.local:2223?
Using sole credentials jenkins (Subversion) in realm ?svn+ssh://subversion.dynautics.local?
← Got one external: DriverLib, svn url: svn+ssh://subversion.dynautics.local/storage/repo/trunk/Firmware/DriverLib →
Using sole credentials jenkins (Subversion) in realm ?svn+ssh://subversion.dynautics.local?
Fetching ‘svn+ssh://subversion.dynautics.local/storage/repo/trunk/Firmware/DriverLib’ at -1 into ‘/var/lib/jenkins/workspace/Firmware/AzipodDriver/DriverLib’ failed!
ERROR: Failed to check out svn+ssh://subversion.dynautics.local:2223/storage/repo/trunk/Firmware/AzipodDriver`
Which is followed by a load of Java error reporting, which is followed by yet more Java error reporting as the email plugin fails horribly too. On a side note I am using the extended email plugin or something which, unlike the ordinary one, has no option to send a test email
If I remove the explicit port number in the URL, I get this:
Started by user Alastair Growcott Running as SYSTEM Building in workspace /var/lib/jenkins/workspace/Firmware/AzipodDriver Checking out a fresh workspace because the workspace is not svn+ssh://subversion.dynautics.local/storage/repo/trunk/Firmware/AzipodDriver Cleaning local Directory . Checking out svn+ssh://subversion.dynautics.local/storage/repo/trunk/Firmware/AzipodDriver at revision 2023-03-06T10:59:42.727 +0000' --quiet Using sole credentials jenkins (Subversion) in realm ?svn+ssh://subversion.dynautics.local? Using sole credentials jenkins (Subversion) in realm ?svn+ssh://subversion.dynautics.local? ERROR: Subversion checkout has been canceled Build was aborted Finished: ABORTED
Here is some console output from within the docker image:
I posted a reply with lots of details. The spam filter hid it while I was trying to edit it to make it more readable. The “preformatted text” markers are a bit rubbish, so lines were being concatenated and not properly formatted, etc. etc.
If you need to specify a custom port for your Subversion repository in Jenkins, you could maybe do so by including the port number in the SVN URL. For example, if your repository is running on port 2222, you could specify the URL as svn+ssh://user@host:2222/path/to/repo.
If your externals do not specify the port number, you can specify the port number in the parent repository URL as described above, and the externals will inherit that port number.
Regarding the SVN_SSH environment variable, setting it to the path of your SSH binary should work to specify the path to the SSH binary used by the Subversion plugin. However, you may need to restart Jenkins for the change to take effect.
I just ran into a similar problem with git. Rather than use externals or git modules, we have a dependencies JSON file and use some CMake cleverness to automatically download the dependencies. This way we can manage both Subversion and Git dependencies. This works because, again, the SSH config file specifies the key to use when connecting to that gitlab instance.
Because Jenkins doesn’t have an SSH config file, when the build script runs there is no way to know which SSH key to use.