[英]How to pull shared library during build in gitlab-ci docker?
I have a simple gitlab-ci
pipeline.我有一个简单的
gitlab-ci
管道。 Now I want to add a maven
dependency to a library that I want to share between different projects, eg my main project defines:现在我想向我想在不同项目之间共享的库添加一个
maven
依赖项,例如我的主项目定义:
<dependencies>
<dependency>
<groupId>my.projects</groupId>
<artifactId>my-commons</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
The my-commons is also a project in my gitlab
. my-commons 也是我的
gitlab
一个项目。
Question: how can I trigger a mvn clean install
into the ci-repository on that shared dependency during build of my main project?问题:如何在构建主项目期间触发
mvn clean install
到该共享依赖项的 ci-repository 中?
This is my gitlab-ci
from main project:这是我的主项目中的
gitlab-ci
:
image: adoptopenjdk/maven-openjdk11
#TODO how to trigger a mvn clean install on my-commons?
test:
stage: test
script: mvn test -B
build:
stage: build
script: mvn package -B -Dmaven.test.skip=true
artifacts:
paths:
- target/*.jar
deploy:
stage: deploy
script: ...
Sidenote: I know I could setup a local shared repository manager like nexus
, but I'd like to avoid that and simply add the common dependency into the build process.旁注:我知道我可以设置一个像
nexus
这样的本地共享存储库管理器,但我想避免这种情况,只需将公共依赖项添加到构建过程中即可。
You can build your own image and use it at gitlab-ci.您可以构建自己的映像并在 gitlab-ci 中使用它。
Example of Dockerfile: Dockerfile 示例:
FROM adoptopenjdk/maven-openjdk11
RUN mvn clean install
# ... other stuff
after you'll build your image and push it to docker hub you can use it inside your gitlab-ci.在构建映像并将其推送到 docker hub 之后,您可以在 gitlab-ci 中使用它。
useful links:有用的链接:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.