【问题标题】:Repository Group authentication on settings.xmlsettings.xml 上的存储库组身份验证
【发布时间】:2012-01-05 22:31:24
【问题描述】:

我正在使用 nexus 为这个场景生成一个 maven settings.xml:

  • my-releases-repo
  • 我的快照存储库

都进入我的组,我有一个角色允许用户在我的组中进行操作。

因此,在settings.xml 中定义了服务器,ID 为my-group,对应的用户和密码。当然也将存储库定义为活动配置文件,如下所示:

<repositories>
   <repository>
      <id>my-group</id>
      <releases>
         <enabled>true</enabled>
         <checksumPolicy>warn</checksumPolicy>
      </releases>
      <snapshots>
         <enabled>true</enabled>
         <updatePolicy>always</updatePolicy>
         <checksumPolicy>warn</checksumPolicy>
      </snapshots>
      <url>http://my.nexus.corp/content/groups/my-group</url>
   </repository>

使用此配置,用户可以对两个存储库进行身份验证并从中下载工件,但不能进行部署。

最后的问题是:settings.xml 中提供的服务器身份验证仅适用于为存储库组定义的读取、查看方法?

当然,如果我添加指向每个存储库 ID 的服务器(不在配置文件中添加这些存储库,只保留我的组),则部署工作。

我的想法是使用存储库组身份验证提供更简单的 settings.xml,避免为每个服务器(repo)设置密码,因为它是同一个用户。

【问题讨论】:

    标签: maven settings nexus


    【解决方案1】:

    听起来您在 pom.xml 或 settings.xml 文件中缺少 &lt;distributionManagement&gt; 节。如果你想将工件部署到你的仓库,你需要这个。

    请注意,您在 &lt;servers&gt; 节内的 settings.xml 文件中定义的凭据适用于存储库、pluginRepositories 和配置。您只需要添加额外的东西 - 例如,这是我的来自我们用作所有 Maven 项目的父级的标准 pom:

    <repositories>
        <!-- WARNING: If you change the Id of ANY of these repos, you will need to update every settings.xml
            file on every machine including the Hudson CI server. -->
        <!-- NOTE: All of these repositories use externally accessible URLs, but you can override with LAN
            URLs by configuring mirrors in settings.xml -->
        <repository>
            <id>mycorp-release</id>
            <name>Nexus repository for artifact releases</name>
            <url>https://intranet.mycorp.com/nexus/content/repositories/releases</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
        <repository>
            <id>mycorp-snapshot</id>
            <name>Nexus repository for artifact SNAPSHOTs</name>
            <url>https://intranet.mycorp.com/nexus/content/repositories/snapshots</url>
            <releases>
                <enabled>false</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
    </repositories>
    <pluginRepositories>
        <pluginRepository>
            <id>mycorp-plugin-release</id>
            <name>Nexus repository for plugin artifact releases</name>
            <url>https://intranet.mycorp.com/nexus/content/repositories/releases</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </pluginRepository>
    </pluginRepositories>
    <distributionManagement>
        <repository>
            <!-- Where to put released artifacts -->
            <id>mycorp-release</id>
            <name>Nexus release artifact deployment repository</name>
            <url>https://intranet.mycorp.com/nexus/content/repositories/releases</url>
        </repository>
        <snapshotRepository>
            <!-- Where to put snapshot artifacts -->
            <id>mycorp-snapshot</id>
            <name>Nexus snapshot artifact deployment repository</name>
            <url>https://intranet.mycorp.com/nexus/content/repositories/snapshots</url>
        </snapshotRepository>
    </distributionManagement>
    

    【讨论】:

      【解决方案2】:

      您可以对所有服务器使用相同的 id,只要它们位于不同的上下文中即可。我建议对具有相同 ID 的发布和快照部署使用 distributionManagement。

      为了重新读取 jars,我只想引用您添加发布和快照存储库的公共组。然后 settings.xml 看起来就像它在 Repository Management with Nexus 一书中所做的那样:

      http://books.sonatype.com/nexus-book/reference/maven-sect-single-group.html

      【讨论】:

        猜你喜欢
        • 2021-07-30
        • 1970-01-01
        • 2011-03-07
        • 2015-02-21
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-09-24
        • 2017-03-01
        相关资源
        最近更新 更多