Hudson subversion 插件:参数化构建找不到凭据

发布于 2024-12-15 07:17:17 字数 1833 浏览 6 评论 0原文

我尝试在 Hudson 中设置参数化构建。它是一个字符串参数,当我手动触发构建时将设置该参数。这是示例存储库 URL。
svn://xxx/java/common/tags/${revision}

当我尝试使用 $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)

我已经设置了用户名/上面存储库 url 的密码。由于 url 是动态生成的,Subversion 插件似乎无法获取凭据。如果我将 URL 设置为静态 URL 并相应地设置用户名/密码,我就可以查看该项目。任何帮助将不胜感激。谢谢。

哈德森版本:2.1.0
Subversion 插件版本:2.0.1

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

忘你却要生生世世 2024-12-22 07:17:17

感谢 mliebelt 的快速回复。不知怎的,我找到了一个解决方法。
这是我在 hudson 项目文件夹下找到的 subversion.credentials。

您可以看到有一个哈希表将 url 映射到凭证。
看一下第三个条目。在运行时,当参数 $revision 被解析时,插件可能无法找到具有匹配密钥的凭证。
出于无奈,我添加了相同的凭据,并添加了“覆盖全局凭据”,并打开了“是”标志。这是下面的第四个条目。看来确实能达到目的。我猜全局身份验证仅基于主机名存储?

<?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><svn://xxx:3690> 01f58c58-b008-11dd-a3df-af2b63c5a78d</string>
      <hudson.scm.SubversionSCM_-DescriptorImpl_-PasswordCredential reference="../../entry[2]/hudson.scm.SubversionSCM_-DescriptorImpl_-PasswordCredential"/>
    </entry>
  </credentials>
</hudson.scm.PerJobCredentialStore>

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><svn://xxx:3690> 01f58c58-b008-11dd-a3df-af2b63c5a78d</string>
      <hudson.scm.SubversionSCM_-DescriptorImpl_-PasswordCredential reference="../../entry[2]/hudson.scm.SubversionSCM_-DescriptorImpl_-PasswordCredential"/>
    </entry>
  </credentials>
</hudson.scm.PerJobCredentialStore>
倾城°AllureLove 2024-12-22 07:17:17

我已经在我们的哈德逊装置之一上对其进行了测试。我已完成以下操作:

  1. 创建了一个新的 hudson 作业。
  2. 将 SVN URL 复制到 Ant 项目,并将最后一段替换为 `${project}。

    之前:https://our.svn.com/svn/trunk/public/develop/build/ant/ant-simple

    现在是:https://our.svn.com/svn/trunk/public/develop/build/ant/${project}

  3. 然后我向构建添加了一个参数:

    • 类型:字符串参数
    • 名称:项目
    • 默认值:ant-simple
  4. 作为构建步骤,我使用目标 clean 定义了 Ant。
  5. 配置对话框告诉我存储库中不存在 SVN URL(其中包含 ${project}),并提供更新凭据。
    在此处输入图像描述
  6. 我不执行更新凭据

当我现在开始构建时,它会询问参数(我不更改默认值),挂起几秒钟(带有消息 pending - ???),然后构建正确。这是有效的原因(我怀疑,但你可以证明这一点),是 Hudson 有一个缓存,用于存储它正在使用的凭证(如果可能的话)。

作为一种解决方法,您应该启动一个不带参数的构建作业(只需复制当前构建,然后通过将 URL 设置为 .../tags/1.0.0.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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文