Search code examples
continuous-integrationgitlabgitlab-cigitlab-ci-runner

Gitlabs artifact of one project used in further projects


Question

  • What is the best way to carry artifacts (jar, class, war) among projects when using docker containers in CI phase.

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

Gitlabs project1

  • unit tests
  • etc...
  • package

Gitlabs project2

  • unit test
  • etc...
  • build (failing)
    • here I need one artifact (jar) generated in project1

Current scenario / comments

  • 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

Possible solutions


Solution

  • 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

    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.

    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.

    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 !

    Hope this help :)