【问题标题】:Maven in Azure DevOps can't find jarAzure DevOps 中的 Maven 找不到 jar
【发布时间】:2022-01-04 12:35:35
【问题描述】:

我正在使用 Azure DevOps YAML 构建管道来编译一些 java 代码。 java代码使用azure-storage-blob

TL;DR

我可以安装一堆 maven jar,但 azure-storage-blob 返回“找不到工件”。我注意到它的路径是https://repo1.maven.org,而不是https://repo.maven.org

更多详情

我的 pom.xml 中有这个:

<dependency>
    <groupId>com.azure</groupId>
    <artifactId>azure-security-keyvault-secrets</artifactId>
    <version>4.0.0</version>
</dependency>

<dependency>
    <groupId>com.azure</groupId>
    <artifactId>azure-storage-blob</artifactId>
    <version>12.14.0</version>
</dependency>

maven 输出的一部分如下所示:

Downloaded from central: https://repo.maven.apache.org/maven2/com/microsoft/azure/azure-keyvault-core/1.0.0/azure-keyvault-core-1.0.0.jar
Downloaded from central: https://repo.maven.apache.org/maven2/org/slf4j/slf4j-nop/1.7.21/slf4j-nop-1.7.21.jar (4.0 kB at 660 B/s)
Downloaded from central: https://repo.maven.apache.org/maven2/com/google/guava/guava/20.0/guava-20.0.jar (2.4 MB at 399 kB/s)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  01:53 min
[INFO] Finished at: 2021-11-26T12:22:10Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project XYZ: Could not resolve dependencies for project com.function:Decryption_POC_JAVA:jar:1.0-SNAPSHOT: Could not find artifact com.azure:azure-storage-blob:jar:12.4.0 in central (https://repo.maven.apache.org/maven2) -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
The process '/usr/bin/mvn' failed with exit code 1
Could not retrieve code analysis results - Maven run failed.

所以它可以成功地从 https://repo.maven.apache.org/maven2/com/microsoft/azure/

但它不能只下载 blob jar

我发现这个文件不存在

https://repo.maven.org/maven2/com/azure/azure-storage-blob/12.14.0/azure-storage-blob-12.14.0.jar

(我假设这是它正在寻找的地方,但我无法让它显示它)

但是这个文件是这样的:

https://repo1.maven.org/maven2/com/azure/azure-storage-blob/12.14.0/azure-storage-blob-12.14.0.jar

注意这是 repo1 而不是 repo。我发现这个只是因为this Maven 页面指定了它。

所以我试图通过将它添加到 pom.xml 来强制查看 repo1

  <repositories>
    <repository>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <id>central1</id>
      <name>Maven Repository Switchboard</name>
      <url>http://repo1.maven.org/maven2</url>
    </repository>
  </repositories>

错误变为

收集失败 com.azure:azure-storage-blob:jar:12.4.0 的依赖项:未能 读取 com.azure:azure-storage-blob:jar:12.4.0 的工件描述符: 无法传输工件 com.azure:azure-storage-blob:pom:12.4.0 从/到 maven-default-http-blocker (http://0.0.0.0/):被阻止的镜像 对于存储库:[central1(http://repo1.maven.org/maven2,默认

我的问题是:

  1. 我可以让 maven 显示它下载的 URL 吗?
  2. 为什么这个文件在 repo1 而不是 repo(其他文件在 repo 而不是 repo1)
  3. 如果 maven 如此出色,为什么会发生这种愚蠢的事情,我该如何解决它

请注意,我正在使用 Azure DevOps,而且我没有很多 maven 经验,所以我不确定我是否可以清除缓存或清除本地 maven 存储库或类似的东西。这也是我正在尝试使用的现有设置。

以下是 YAML 中重要的部分:

trigger:
  paths:
    include:
      - "src/*"
      - "pom.xml"

stages:
- stage: Build
  jobs: 
    - job: mavenBuild
      pool:
        vmImage: 'ubuntu-latest'
      steps:
        - task: Maven@3
          inputs:
            mavenPomFile: 'pom.xml'
            mavenOptions: '-Xmx3072m'
            javaHomeOption: 'JDKVersion'
            jdkVersionOption: '1.8'
            jdkArchitectureOption: 'x64'
            publishJUnitResults: true
            testResultsFiles: '**/surefire-reports/TEST-*.xml'
            goals: 'package'

【问题讨论】:

  • 最后我只是删除了工件以使其运行,它实际上似乎构建正常

标签: azure-devops yaml maven-3


【解决方案1】:

我也在 Azure Pipeline Could not find artifact com.azure:azure-storage-blob:jar:12.4.0 中发现了这个问题。

我从这个maven link 中发现了一些有趣的东西,即Jar (474KB) 链接已损坏。于是我把com.azure:azure-storage-blob:jar版本改成了最新版本12.14.2

这是工作。 Azure Pipelines 可以从 Maven Central Repo 下载此工件。

【讨论】:

  • 感谢您的确认。我还怀疑它在 Maven 中被破坏了。 Maven 的全部目的是交付包,但它的链接断开,这有点荒谬。
猜你喜欢
  • 1970-01-01
  • 2019-05-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多