Gitlab-CI如何引用另一个项目的源代码?

发布于 2025-01-12 15:25:38 字数 364 浏览 3 评论 0原文

我有两个项目,第一个是SOURCES(技术库),第二个是蚂蚁软件。 我在第二个项目上创建了 gitlab-ci.yml,但构建管道始终出错,因为未引用源库。

在我的 build.xml 中,源的引用如下:${SOURCES_DIRRECTORY}/folder/lib/library.jar 在 gitlab-ci.yml 中,我可以设置 SOURCES_DIRRECTORY 但放置其他项目的 url 似乎不起作用。

禁止的解决方案是将源添加到本地 lib 文件夹中。 (以免重复)

是否可以从我的 CI 引用另一个 gitlab 项目? 否则,我如何检索并使用源项目生成的工件来获取我的软件项目上的库?

谢谢您的回答

I have two projects, first is SOURCES (technical base) and second is an ant software.
I have create a gitlab-ci.yml on the second project but the build pipeline is always in error because sources libraries are not referenced.

In my build.xml, sources are referenced like this: ${SOURCES_DIRRECTORY}/folder/lib/library.jar
In the gitlab-ci.yml I can set SOURCES_DIRRECTORY but putting the url of the other project doesn't seem to work.

A prohibited solution is to add the sources in an local lib folder. (so as not to duplicate)

Is it possible to reference another gitlab project from my CI ?
Otherwise, how can I retrieve and use the artifact generated by the sources project to obtain the libraries on my software project?

Thank you for your answers

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

春花秋月 2025-01-19 15:25:38

您可以使用 GitLab CI API下载其他项目中制作的工件。

我在我的一个项目中做了类似的事情,它对我有用

curl -k --location --output artifacts.zip --header  "JOB-TOKEN: $CI_JOB_TOKEN" "$CI_API_V4_URL/projects/$CI_PROJECT_ID/jobs/artifacts/devel/download?job=$STAGE_NAME"

在这种情况下,我下载了同一项目中另一个分支制作的工件,所以我已经默认设置了变量,我可以使用 JOB-TOKEN< /code>,您应该使用 PRIVATE-TOKEN,它是具有 API 权限授予的访问令牌。你应该有类似的东西

curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/jobs/artifacts/main/download?job=test"

You can use the GitLab CI APIs to download the artifacts made in the other project.

I do something similar in one of my project and it work for me

curl -k --location --output artifacts.zip --header  "JOB-TOKEN: $CI_JOB_TOKEN" "$CI_API_V4_URL/projects/$CI_PROJECT_ID/jobs/artifacts/devel/download?job=$STAGE_NAME"

In this case i download the artifacts made by another branch in the same project, so I already have setted by default the variables and I can use JOB-TOKEN, instead you should use the PRIVATE-TOKEN that is an ACCESS TOKEN with the API permission grant. You should have something like that

curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/jobs/artifacts/main/download?job=test"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文