【问题标题】:Maven build error in Jenkins (Semi time sensitive)Jenkins 中的 Maven 构建错误(半时间敏感)
【发布时间】:2024-04-24 20:15:02
【问题描述】:

我通常会等到我们的 Dev 上线,但那还要再等 12 个小时,在这种情况下太晚了,我无法实现某个目标。

但是,我试图通过我们的 Jenkins 面板构建我们的网站项目,但构建失败了。我已经确定这不是我对它所做的最新更改的 b/c,因为我恢复了并且仍然有同样的问题。

而且我已经阅读了错误,但对编程的了解还不够(除了我随着时间的推移自学的内容,这并不多)来得出明确的答案和/或解决方案这个问题。所以我想我会在这里问,并可能及时得到一些答案/可能的解决方案。提前谢谢你!

[ERROR] Failed to execute goal on project moduleCommon: Could not resolve 
dependencies for project com.mtgprice:moduleCommon:jar:1.0: Failed to collect dependencies
at com.google.appengine.tools:appengine-gcs-client:jar:RELEASE
-> >com.google.http-client:google-http-client:jar:[1.19.0,2.0): No versions >available for
com.google.http-client:google-http-client:jar:[1.19.0,2.0) within >specified range -> [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
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :moduleCommon>Build step 'Invoke top-level Maven targets' marked build as failure
Started calculate disk usage of build
Finished Calculation of disk usage of build in 0 seconds
Started calculate disk usage of workspace
Finished Calculation of disk usage of workspace in 0 seconds
Finished: FAILURE

【问题讨论】:

    标签: maven jenkins


    【解决方案1】:

    我今天也有同样的问题。 com.google.http-client 的最新版本是 1.22.0,它肯定在 [1.19.0,2.0) 范围内。

    不确定是什么导致了分辨率错误,但这里有一个 hacky 解决方法。

    在本地 maven 存储库中找到 appengine-gcs-client-0.6.pom。

    例如我的位于 $HOME/.m2/repository/com/google/appengine/tools/appengine-gcs-client/0.6/appengine-gcs-client-0.6.pom 下。

    将版本范围更改为最新版本。

    <dependency>
      <groupId>com.google.http-client</groupId>
      <artifactId>google-http-client</artifactId>
      <!-- <version>[1.19.0,2.0)</version> -->
      <version>1.22.0</version>
    </dependency>
    

    一旦找到真正的解决方案,我会更新答案。

    更新: 我认为问题的原因是http://central.maven.org/maven2/com/google/http-client/google-http-client/maven-metadata.xml 的内容已过时。

    <?xml version="1.0" encoding="UTF-8"?>
    <metadata>
      <groupId>com.google.http-client</groupId>
      <artifactId>google-http-client</artifactId>
      <versioning>
        <latest>1.5.3-beta</latest>
        <release>1.5.3-beta</release>
        <versions>
          <version>1.5.0-beta</version>
          <version>1.5.3-beta</version>
        </versions>
        <lastUpdated>20111021163718</lastUpdated>
      </versioning>
    </metadata>
    

    您还可以更新您的 pom.xml 以排除有问题的传递依赖并显式添加它。

    <!-- mapreduce -->
    <dependency>
        <groupId>com.google.appengine.tools</groupId>
        <artifactId>appengine-mapreduce</artifactId>
        <version>0.8.5</version>
        <exclusions>
            <exclusion>
                <!-- TODO remove me after the issue is fixed https://github.com/google/google-http-java-client/issues/330 -->
                <groupId>com.google.http-client</groupId>
                <artifactId>google-http-client</artifactId>
            </exclusion>
        </exclusions> 
    </dependency>
    
    <dependency>
        <groupId>com.google.appengine.tools</groupId>
        <artifactId>appengine-gcs-client</artifactId>
        <version>0.6</version>
        <exclusions>
            <exclusion>
                <!-- TODO remove me after the issue is fixed https://github.com/google/google-http-java-client/issues/330 -->
                <groupId>com.google.http-client</groupId>
                <artifactId>google-http-client</artifactId>
            </exclusion>
        </exclusions> 
    </dependency>
    
    <!-- Add the transitive dependency explicity  -->
    <dependency>
        <groupId>com.google.http-client</groupId>
        <artifactId>google-http-client</artifactId>
        <version>1.22.0</version>
    </dependency>
    

    【讨论】:

    • 现在试试这个,很快就会报告,让你知道它是否有帮助。谢谢!不过,从它的声音来看,这似乎更像是别人的问题。但同样,我在这个领域的知识有限,所以我会避免做出毫无根据的假设。
    • 好吧,这个 hacky 解决方法绝对有帮助,所以谢谢你!不过,我现在只剩下一个问题。也就是说,我知道在我的本地 mvn 存储库中的何处/如何进行更改。但我不知道如何在我们的 Jenkins mvn 存储库中这样做。我应该有足够的访问权限,但只是不确定在哪里可以找到和/或编辑文件。碰巧有这方面的指示吗?
    • 如果您发现此类过时的元数据,您应该像我在这里所做的那样需要更新:issues.sonatype.org/browse/MVNCENTRAL-1187
    • 完美,非常感谢 Arrix!通常我会以同样的方式报告 khmarbaise,但在这种特殊情况下,我真的不知道该去哪里这样做。
    【解决方案2】:

    这里是 google-http-client 的维护者。

    我们手动推送了缺失的 1.24.1 父版本。我在本地测试过,似乎可以解决问题。请仔细检查,如果问题仍然存在,请告诉我。

    https://repo1.maven.org/maven2/com/google/http-client/google-http-client-parent/1.24.1/

    【讨论】: