你能在 GitLab CI/CD 中添加外部 Maven 库吗
Posted
技术标签:
【中文标题】你能在 GitLab CI/CD 中添加外部 Maven 库吗【英文标题】:Can you add External Maven Library in GitLab CI/CD 【发布时间】:2022-01-19 12:46:15 【问题描述】:我的 Maven 项目中有外部库。该库是本地的,是为该项目制作的。 我可以以某种方式添加外部库以便我的管道可以工作吗?
这是 GitLab CI/CD 的输出:
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.651 s
[INFO] Finished at: 2021-12-16T11:23:18Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project ServerTCPMaven: Could not resolve dependencies for project org.example:ServerTCPMaven:jar:1.0-SNAPSHOT: Could not find artifact org.example:MaNikFileLibrary:jar:1.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
ERROR: Job failed: exit code 1```
【问题讨论】:
【参考方案1】:您至少有两个选择:
您可以将依赖项上传到内部 Maven 存储库(例如 Nexus)。然后您可以配置您的 settings.xml 以使用此存储库。见https://maven.apache.org/settings.html#Repositories
您可以将依赖项移动到您的项目中并引用本地依赖项。见How to add local jar files to a Maven project?
【讨论】:
以上是关于你能在 GitLab CI/CD 中添加外部 Maven 库吗的主要内容,如果未能解决你的问题,请参考以下文章
如何使用GitLab和Rancher构建CI/CD流水线–Part 1
如何将 Azure AKS Kubernetes 集群自签名 CA 添加到 GitLab CI/CD Kubernetes 集成?