【问题标题】:Why doesn't Jenkins download my latest snapshot?为什么 Jenkins 不下载我的最新快照?
【发布时间】:2012-08-31 09:55:39
【问题描述】:

我有一个 Maven 3 项目的 Jenkins 构建工作。该项目具有 SNAPSHOT 依赖项。构建失败,因为 Maven 找不到部署到 Intranet Sonatype Nexus Repository 的 SNAPSHOT 工件。 SNAPSHOT 存储库是“公共”组的一部分,它是 <mirrorOf>*</mirrorOf> 的镜像 URL。
Jenkins 配置为在工作区本地创建一个本地 Maven 存储库(每个作业一个存储库)。
所有其他非快照依赖项都已解决并很好地下载。没有 SNAPSHOT 依赖项的项目的其他作业也已成功构建。 到目前为止我尝试过的事情(没有成功):

  • Nexus 中的缓存已过期
  • 检查了本地存储库(在作业目录中) - 没有工件目录
  • 在作业配置中将“构建 -> 目标和选项”设置为“-U 全新安装”
  • 等一小时

我的设置:
视窗服务器 2003
Java 1.6.0_31
詹金斯 1.480
Maven 3.0.3

【问题讨论】:

  • 你能从部署 Jenkins 的机器连接到 nexus(比如通过浏览器)吗?另外,检查它是否需要任何防火墙例外。
  • 我还要补充一点:验证 nexus 中的日志以验证 SNAPSHOT 版本是否实际正在上传。
  • @Chris 请查看我的更新,该设置适用于其他依赖项。
  • @Augusto 我可以在 Nexus 中看到依赖项
  • 2) 您是否尝试在同一作业目录中从命令行运行 mvn build?值得。

标签: java maven jenkins


【解决方案1】:

这可能是我也发现的“陷阱”,从 Nexus 下载快照修订版。

Nexus book中提供了解决方案,但没有完全解释:

<settings>
  <mirrors>
    <mirror>
      <id>nexus</id>
      <url>http://myserver/nexus/content/groups/public</url>
      <mirrorOf>central</mirrorOf>
    </mirror>
  </mirrors>
  <profiles>
    <profile>
      <id>nexus</id>
      <!--Enable snapshots for the built in central repo to direct -->
      <!--all requests to nexus via the mirror -->
      <repositories>
        <repository>
          <id>central</id>
          <url>http://central</url>
          <releases><enabled>true</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
        </repository>
      </repositories>
    </profile>
  </profiles>
  <activeProfiles>
    <!--make the profile active all the time -->
    <activeProfile>nexus</activeProfile>
  </activeProfiles>
</settings>

似乎必须明确告诉 Maven Nexus 提供的存储库组也可以包含快照修订。据推测,这会触发 Maven 开始寻找特殊的元数据文件,这些元数据文件用于发现哪个时间戳文件实际上是最新的快照。

【讨论】:

  • 是的,就是这样!非常感谢。如果将mirrorOf 设置为*,它也可以工作。
  • @Mulmoth 将“mirrorOf”设置为 * 告诉 Maven 忽略 POM 中的“存储库”部分。如果您使用的是 Nexus,您可能想要这种行为
【解决方案2】:

由于您已经定义了mirrorOf/*,只需将其添加到您的.m2/settings.xml 中即可指示maven 也搜索该镜像以获取快照:

<profile><id>alwaysactive</id>
    <activation><activeByDefault>true</activeByDefault></activation>
    <repositories>
        <repository><id>unused</id><url>unused</url></repository>
    </repositories>
</profile>

【讨论】:

    猜你喜欢
    • 2017-01-23
    • 1970-01-01
    • 2020-09-23
    • 2020-07-11
    • 2013-07-29
    • 2019-02-08
    • 2022-11-22
    • 2011-08-19
    相关资源
    最近更新 更多