HamburgerJungeJr
HamburgerJungeJr

Reputation: 41

Gitlab-CI multi-project-pipeline

currently I'm trying to understand the Gitlab-CI multi-project-pipeline. I want to achieve to run a pipeline if another pipeline has finshed.

Example: I have one project nginx saved in namespace baseimages which contains some configuration like fast-cgi-params. The ci-file looks like this:

stages:
  - release
  - notify

variables:
  DOCKER_HOST: "tcp://localhost:2375"
  DOCKER_REGISTRY: "registry.mydomain.de"
  SERVICE_NAME: "nginx"
  DOCKER_DRIVER: "overlay2"

release:
  stage: release
  image: docker:git
  services:
  - docker:dind
  script:
    - docker build -t $SERVICE_NAME:latest .
    - docker tag $SERVICE_NAME:latest $DOCKER_REGISTRY/$SERVICE_NAME:latest
    - docker push $DOCKER_REGISTRY/$SERVICE_NAME:latest
  only:
    - master

notify:
  stage: notify
  image: appropriate/curl:latest
  script:
    - curl -X POST -F token=$CI_JOB_TOKEN -F ref=master https://gitlab.mydomain.de/api/v4/projects/1/trigger/pipeline
  only:
    - master

Now I want to have multiple projects to rely on this image and let them rebuild if my baseimage changes e.g. new nginx version.

             baseimage
                 |
    ---------------------------
    |            |            |
project1     project2     project3

If I add a trigger to the other project and insert the generated token at $GITLAB_CI_TOKEN the foreign pipeline starts but there is no combined graph as shown in the documentation (https://docs.gitlab.com/ee/ci/multi_project_pipelines.html)

How is it possible to show the full pipeline graph? Do I have to add every project which relies on my baseimage to the CI-File of the baseimage or is it possible to subscribe the baseimage-pipline in each project?

Upvotes: 2

Views: 4288

Answers (4)

HamburgerJungeJr
HamburgerJungeJr

Reputation: 41

Well after some more digging into the documentation I found a little sentence which states that Gitlab CE provides features marked as Core-Feature.

Upvotes: 1

eephillip
eephillip

Reputation: 1328

If you click the versions history ... from multi_project_pipelines it reveals.

Made available in all tiers in GitLab 12.8.

Multi-project pipeline visualizations as of 13.10-pre is marked as premium however in my ee version the visualizations for down/upstream links are functional.

So reference Triggering a downstream pipeline using a bridge job

Before GitLab 11.8, it was necessary to implement a pipeline job that was responsible for making the API request to trigger a pipeline in a different project.

In GitLab 11.8, GitLab provides a new CI/CD configuration syntax to make this task easier, and avoid needing GitLab Runner for triggering cross-project pipelines. The following illustrates configuring a bridge job:

rspec:
  stage: test
  script: bundle exec rspec

staging:
  variables:
    ENVIRONMENT: staging
  stage: deploy
  trigger: my/deployment

Upvotes: 0

Alex
Alex

Reputation: 422

We have 50+ Gitlab packages where this is needed. What we used to do was push a commit to a downstream package, wait for the CI to finish, then push another commit to the upstream package, wait for the CI to finish, etc. This was very time consuming.

The other thing you can do is manually trigger builds and you can manually determine the order.

If none of this works for you or you want a better way, I built a tool to help do this called Gitlab Pipes. I used it internally for many months and realized that people need something like this, so I did the work to make it public.

Basically it listens to Gitlab notifications and when it sees a commit to a package, it reads the .gitlab-pipes.yml file to determine that projects dependencies. It will be able to construct a dependency graph of your projects and build the consumer packages on downstream commits.

The documentation is here, it sort of tells you how it works. And then the primary app website is here.

Upvotes: 1

Rekovni
Rekovni

Reputation: 7344

The Multi-project pipelines is a paid for feature introduced in GitLab Premium 9.3, and can only be accessed using GitLab's Premium or Silver models.

A way to see this is to the right of the document title: hover icon

Upvotes: 1

Related Questions