2

Example:

I have 3 different pipelines (projects) in GitLab. Each pipeline has multiple jobs, each targeting a different remote VM and set a different GitLab CI environment. The jobs are all manually triggered (currently). What I am trying to achieve is a linking (multi-project) pipeline that runs like this: Once I trigger job "X" in the pipeline #1, upon succeeding, that will trigger ONLY job "X" in the pipeline #2 which then again, upon success, will trigger ONLY job "X" in pipeline #3.

By job "X" I mean a job that runs on a certain remote VM, I don't want the entire pipeline to run since I don't want to change all targets. All examples I found only work at a pipeline level, not at the job level. What am I missing?

PS: I'm new to the GitLab CI scene so please forgive my lack of understanding in case there's an easy solution that I've missed.

Raul Butuc
  • 319
  • 1
  • 12

1 Answers1

1

It's possible yes. If I take your example, in job "X" from pipeline 1, you can trigger a pipeline from another project using Gitlab API :

script:
  - "curl --request POST --form token=TOKEN --form ref=master https://gitlab.example.com/api/v4/projects/9/trigger/pipeline"

To ensure triggering only job "X" from pipeline 2, add use only keyword with api condition :

job_X:
  only:
    - api
Nicolas Pepinster
  • 5,413
  • 2
  • 30
  • 48
  • Thanks! Been struggling with this for quite a while now :) – Raul Butuc Jun 02 '20 at 08:42
  • Quick question, where does the value of "TOKEN" come from? – Raul Butuc Jun 02 '20 at 09:08
  • 1
    it's a [personal access token](https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html) you can generate in your user settings – Nicolas Pepinster Jun 02 '20 at 09:27
  • I was not able to trigger a pipeline with a pesonal token. I was getting 404 and this is apparently documented [here](https://docs.gitlab.com/ee/ci/triggers/#404-not-found-when-triggering-a-pipeline). TOKEN must be a trigger token – ddsultan May 05 '21 at 18:41