【问题标题】:Hudson subversion plugin: parameterized build failed to find credentialHudson 颠覆插件:参数化构建找不到凭证
【发布时间】:2011-11-15 06:47:43
【问题描述】:

我尝试在 Hudson 中设置参数化构建。这是一个字符串参数,将在我手动触发构建时设置。这是示例存储库网址。
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
颠覆插件版本:2.0.1

【问题讨论】:

  • 您能解释一下参数化构建的含义吗?当我做一个新的构建工作并选择复选框This build is parameterized 时,我只有几个选项。你在那里用过哪一个?它是一个字符串参数,然后在您的 URL 中使用到 Subversion 吗?请将此信息添加到问题中。
  • 是的,它是一个字符串参数,在我的 URL 中用于颠覆。

标签: svn continuous-integration hudson hudson-plugins


【解决方案1】:

感谢您的快速响应。不知何故,我找到了解决方法。 这是我在 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>&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>

【讨论】:

    【解决方案2】:

    我已经在我们的一个 Hudson 装置上对其进行了测试。我做了以下事情:

    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. 作为构建步骤,我使用 target clean 定义了 Ant。
    5. 配置对话框告诉我存储库中不存在 SVN URL(其中包含 ${project})并提供更新凭据。
    6. 我不做Update credentials

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

    作为一种解决方法,您应该启动一个不带参数的构建作业(只需复制您当前的构建,并通过将 URL 设置为 .../tags/1.0.0.0 来删除参数)并构建一次。您必须在那里输入正确的凭据,现在参数化构建现在应该可以工作了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-02-29
      • 1970-01-01
      • 2011-03-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-01
      • 2016-10-17
      相关资源
      最近更新 更多