一个项目的Gitlabs工件用于其他项目 [英] Gitlabs artifact of one project used in further projects

查看:192
本文介绍了一个项目的Gitlabs工件用于其他项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


  • 在CI阶段使用docker容器时,在项目之间携带工件(jar,class,war)的最佳方法是什么? 。

让我详细解释我的问题,请不要停止阅读... =)

Let me explain my issue in details, please don't stop the reading... =)


  • 单元测试

  • 等...

  • 软件包


  • 单元测试

  • 等...

  • 构建(失败)


    • 这里我需要一个在project1中生成的工件(jar)


    • 我正在使用docker,因此在每个.gitlab-ci.yml中,我将拥有独立的容器

    • 在project1中一切正常

    • 如果我在.gitlab-ci.yml中使用 shell而不是docker,则可以磁盘中的project1中的jar文件,并在project2启动构建时使用

    • 今天,当project1完成正常工作时,我在调用project2时触发了触发器
    • 我的工件不是RPM,所以我不会添加到我的仓库中

    • I'm using dockers so in each .gitlab-ci.yml I'll have independent containers
    • All is working fine in project1
    • If I use "shell" instead of dockers in my .gitlab-ci.yml I can keep the jar file from the project1 in the disk and use when project2 kicks the build
    • Today my trigger on call project2 when project1 finish is working nicely
    • My artifact is not an RPM so I'll not add into my repo
    • I can commit the artifact of project1 and checkout when need to build project2
    • I need to study if cache feature from gitlabs is designed for this purpose (gitlab 8.2.1, How to use cache in .gitlab-ci.yml)

    推荐答案

    您好,您必须看看名为 get-last-successful-build-artifact.sh的脚本并由 morph027 开发。

    Hello you must take a look at a script named get-last-successful-build-artifact.sh and developed by morph027.

    https://gitlab.com/morph027/gitlab-ci-helpers

    此脚本允许下载工件并将其解压缩到项目根目录中。它使用Gitlab API检索最新成功的构建并下载相应的工件。您可以将多个工件组合在一起,并在任何需要的地方解压缩,只需稍微更新一下脚本即可。

    This script allow to download an artifact and unzip it in the project root. It use Gitlab API to retrieve latest successful build and download corresponding artifact. You can combine multiple artifacts and unzip wherever you want just by updating the script a little.

    我目前也正在启动 PHP库来处理构建工件,但它处于非常早期的阶段,目前与laravel捆绑在一起。

    I'm also currently starting a PHP library to handle build artifacts but it's in a very early stage and tied with laravel for the moment.

    目前尚无简便的方法来处理项目之间的工件使用,您必须使用该工具构建自己的工具。

    For the moment there is no easy way to handle artifact usage between projects, you must build your own using that tools.

    我认为使用shell executor不是正确的解决方案,这非常危险,因为您无法验证构建期间使用的服务器上的文件!

    I think using shell executor is not the right solution, it's very dangerous because you can't verify the file on the server used during the build !

    希望获得帮助:)

    这篇关于一个项目的Gitlabs工件用于其他项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆