2

I tried to set up a parameterized build in Hudson. It is a string parameter that will be set when I trigger a build manually. This is the sample repository url.
svn://xxx/java/common/tags/${revision}

I got the following exception when I tried to do a build with $revision=1.0.0.0

error: failed to check out svn://xxx/java/common/tags/1.0.0.0
org.tmatesoft.svn.core.SVNCancelException: svn: No credential to try. Authentication failed
    at org.tmatesoft.svn.core.internal.wc.SVNErrorManager.cancel(SVNErrorManager.java:37)
    at org.tmatesoft.svn.core.internal.wc.SVNErrorManager.cancel(SVNErrorManager.java:32)
    at org.tmatesoft.svn.core.internal.wc.DefaultSVNAuthenticationManager.getFirstAuthentication(DefaultSVNAuthenticationManager.java:219)
    at org.tmatesoft.svn.core.internal.io.svn.sasl.SVNSaslAuthenticator.createSaslClient(SVNSaslAuthenticator.java:304)
    at org.tmatesoft.svn.core.internal.io.svn.sasl.SVNSaslAuthenticator.authenticate(SVNSaslAuthenticator.java:91)
    at org.tmatesoft.svn.core.internal.io.svn.SVNConnection.authenticate(SVNConnection.java:173)
    at org.tmatesoft.svn.core.internal.io.svn.SVNRepositoryImpl.authenticate(SVNRepositoryImpl.java:1265)
    at org.tmatesoft.svn.core.internal.io.svn.SVNRepositoryImpl.openConnection(SVNRepositoryImpl.java:1243)
    at org.tmatesoft.svn.core.internal.io.svn.SVNRepositoryImpl.getLatestRevision(SVNRepositoryImpl.java:168)
    at org.tmatesoft.svn.core.wc.SVNBasicClient.getRevisionNumber(SVNBasicClient.java:482)
    at org.tmatesoft.svn.core.wc.SVNBasicClient.getLocations(SVNBasicClient.java:873)
    at org.tmatesoft.svn.core.wc.SVNBasicClient.createRepository(SVNBasicClient.java:534)
    at org.tmatesoft.svn.core.wc.SVNUpdateClient.doCheckout(SVNUpdateClient.java:901)

I have already set up the username/password for the repository url above. It seems like Subversion plugin failed to get the credential as the url is dynamically generated. If I set up the URL as a static one and set up the username/password accordingly, I am able to check out the project. Any help will be greatly appreciated. Thx.

Hudson version: 2.1.0
Subversion plugin version: 2.0.1

iamsan
  • 31
  • 5
  • Could you explain what a parameterized build means? When I do a new build job, and select the checkbox `This build is parameterized`, I only have a handful of options. Which one have you used there? Is it a string parameter that is then used in your URL to Subversion? Please add this information to the question. – mliebelt Nov 15 '11 at 07:25
  • Yes, it's a string paramter that is used in my URL to subversion. – iamsan Nov 15 '11 at 07:46

2 Answers2

1

Thx mliebelt for your quick response. Somehow I find a workaround. This is the subversion.credentials I found under the hudson project folder.

You can see that there is a hashtable that map an url to a credential. Take a look at the third entry. At runtime, when the parameter $revision is resolved, the plugin may fail to find a credential with matching key. Out of desperation, I added the same credential with the "Override global credentials" with the "Yes" flag on. That is the fourth entry below. It seems to do the trick. I guess the global authentication is stored based on the hostname only?

<?xml version='1.0' encoding='UTF-8'?>
<hudson.scm.PerJobCredentialStore>
  <credentials class="hashtable">
    <entry>
      <string>svn://xxx/java/common</string>
      <hudson.scm.SubversionSCM_-DescriptorImpl_-PasswordCredential>
        <userName>chiangs</userName>
        <password>MWNoaWFuZ3MyMw==</password>
      </hudson.scm.SubversionSCM_-DescriptorImpl_-PasswordCredential>
    </entry>
    <entry>
      <string>svn://xxx/java/common/trunk</string>
      <hudson.scm.SubversionSCM_-DescriptorImpl_-PasswordCredential>
        <userName>chiangs</userName>
        <password>MWNoaWFuZ3MyMw==</password>
      </hudson.scm.SubversionSCM_-DescriptorImpl_-PasswordCredential>
    </entry>
    <entry>
      <string>svn://xxx/java/common/tags/${revision}</string>
      <hudson.scm.SubversionSCM_-DescriptorImpl_-PasswordCredential>
        <userName>chiangs</userName>
        <password>MWNoaWFuZ3MyMw==</password>
      </hudson.scm.SubversionSCM_-DescriptorImpl_-PasswordCredential>
    </entry>
    <entry>
      <string>&lt;svn://xxx:3690&gt; 01f58c58-b008-11dd-a3df-af2b63c5a78d</string>
      <hudson.scm.SubversionSCM_-DescriptorImpl_-PasswordCredential reference="../../entry[2]/hudson.scm.SubversionSCM_-DescriptorImpl_-PasswordCredential"/>
    </entry>
  </credentials>
</hudson.scm.PerJobCredentialStore>
iamsan
  • 31
  • 5
0

I have tested it on one of our Hudson installations. I have done the following:

  1. Created a new hudson job.
  2. Copied the SVN URL to an Ant project, and replaced the last segment by `${project}.

    Before it was: https://our.svn.com/svn/trunk/public/develop/build/ant/ant-simple

    Now it is: https://our.svn.com/svn/trunk/public/develop/build/ant/${project}

  3. Then I added a parameter to the build:

    • Type: string parameter
    • Name: project
    • Default Value: ant-simple
  4. As build step, I defined Ant with target clean.
  5. The configuration dialog tells me that the SVN URL (with ${project} in it) does not exist in the repository and offers to update the credentials. enter image description here
  6. I don't do the Update credentials.

When I start now the build, it asks for the parameter (I don't change the default), hangs for some seconds (with the message pending - ???), and then does the build correct. The reason why this is working (I suspect that, but you can prove it), is that Hudson has a cache for credentials that it is using if possible.

You should as a workaround start one build job without the parameter (just copy your current build, and remove the parameter by setting the URL to .../tags/1.0.0.0) and build it once. You have to enter there the correct credentials, and now the parameterized build should now work.

mliebelt
  • 15,345
  • 7
  • 55
  • 92