Gitlab CI maven 生成源失败,出现 400
Posted
技术标签:
【中文标题】Gitlab CI maven 生成源失败,出现 400【英文标题】:Gitlab CI maven generate sources fails with 400 【发布时间】:2021-11-28 20:21:00 【问题描述】:我正在尝试让我们的 maven 构建生成源并存储在 gitlab 工件存储库中。
在 POM 中添加了以下内容:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
当我运行 gitlab CI 时,构建会创建工件(包括常规 jar 和源 jar):
[INFO] Installing /builds/xxxxx/yyyyy/target/xxxxx-2.2.jar to /root/.m2/repository/com/xxxxx/2.2/xxxxx-2.2.jar
[INFO] Installing /builds/xxxxxxx/pom.xml to /root/.m2/repository/com/xxxxx/yyyy/2.2/xxxxx-2.2.pom
[INFO] Installing /builds/xxxxxx/yyyyyy/target/xxxxx-2.2-sources.jar to /root/.m2/repository/com/xxxxxx/yyyyyy/2.2/xxxxxx-2.2-sources.jar
Maven 然后部署工件,但在部署源工件时失败:
Uploading to gitlab-maven: https://gitlab.com/api/v4/projects/xxxxx/packages/maven/com/yyyy/zzzzz/maven-metadata.xml
Uploaded to gitlab-maven: https://gitlab.com/api/v4/projects/xxxxxx/packages/maven/com/yyyyyy/zzzzz/maven-metadata.xml (659 B at 418 B/s)
Uploading to gitlab-maven: https://gitlab.com/api/v4/projects/xxxxx/packages/maven/com/yyyyy/zzzzz/2.2/xxxxxxx-2.2-sources.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 33.828 s
[INFO] Finished at: 2021-10-09T00:48:16Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project forte-client: Failed to deploy artifacts: Could not transfer artifact com.xxxxxx:yyyyyyy:jar:sources:2.2 from/to gitlab-maven (https://gitlab.com/api/v4/projects/xxxxxx/packages/maven): Transfer failed for https://gitlab.com/api/v4/projects/xxxxx/packages/maven/com/xxxxx/yyyyyy/2.2/xxxxxxx-2.2-sources.jar 400 Bad Request -> [Help 1]
如果我删除了 maven-source-plugin,那么构建工作正常。
如果我在本地或通过 Gitlab CI 运行 Maven,就会发生这种情况。
【问题讨论】:
【参考方案1】:我遇到了同样的问题,我正在寻找解决方案。在一些(尝试失败)之后,唯一对我有用的解决方案是启用来自
【讨论】:
呃——这真是太可惜了。因为如果开发人员不修改版本,允许重复是一种非常好的方法,可以避免意外覆盖工件。你有没有为此想出一个解决方法?我希望异常正则表达式会有所帮助,但我还没有找到有效的设置(即“.*-SNAPSHOT|.*-sources”仍然会导致失败。以上是关于Gitlab CI maven 生成源失败,出现 400的主要内容,如果未能解决你的问题,请参考以下文章
GitLab CI 构建失败并出现错误,一些本地引用无法更新
为啥我的 .gitlab-ci.yml 在纱线测试中不断失败,并出现错误“/bin/sh: 1: react-scripts: not found”?