0
votes

My Jenkins build uses Subversion for Source Code Management. In the appropriate fields in the GUI I've set up the repository url https://host:port/svn/project/trunk and added the credentials.

The build then has a number of steps, each being an invoke of an ant target on a build.xml which came with the SVN checkout.

The checkout itself works fine, I can verify this by seeing the expected files in the workspace. So the credentials work and Jenkins can connect to the SVN server.

THEN this happens when one of the build steps wants to delete and create an SVN tag (to which files will be copied in a next step - the tag is used by a packaging system later on):

16:54:17 04.svn-tagging:
16:54:17      [echo] svn delete tag https://host:port/svn/project/tags/tagname    
16:54:17      [exec] svn: E175013: Unable to connect to a repository at URL 'https://host:port/svn/project/tags/tagname'
16:54:17      [exec] svn: E175013: Access to 'https://host:port/svn/project/tags/tagname' forbidden
16:54:18      [exec] Result: 1
16:54:18      [echo] svn create tag https://host:port/svn/project/tags/tagname
16:54:18      [exec] svn: E175013: Unable to connect to a repository at URL 'https://host:port/svn/project/tags'
16:54:18      [exec] svn: E175013: Access to 'https://host:port/svn/project/tags' forbidden
16:54:19 

As the server was already able to connect to https://host:port/svn/project/trunk, why would it not be able to connect to https://host:port/svn/project/tags? In the Additional Credentials (under Subversion) I've tried adding credentials for https://host:port/svn/project/tags and https://host:port/svn/project but that doesn't change anything.

Possibly the literal svn commands are being executed with whatever user Jenkins is running as? How can I tell Jenkins to use specific credentials for this task (and how can I configure those credentials in Jenkins)?

1

1 Answers

0
votes

The credentials used for the checkout are not propagated to the consecutive build steps. These are run as the default user for your Jenkins setup. In this case, that user doesn't have access to that repository.

Few options seem available if you don't have global access to the Jenkins build server. Our solution has been to (in the job configuration):

  1. Go to Build Environment (it's a header)
  2. Check the box Mask passwords and regexes (and enable global passwords)
  3. Add a Name/Password pair e.g. Name = svnpass & Password = ...
  4. Then you can use the password in the ant-script ${svnpass}
  5. Add username/password to the ant-calls, e.g. svn delete ... --username ... --password ${svnpass}