0

I'm trying to develop a common gitlab pipeline that uses a matrix to trigger another pipeline but I want to add a variable in the path. What I wrote till now is:

variables:
  PROJECT_NAME: name
  PROJECT_HELM: helmpipe
  DEV_CUSTOMERS: cust1 cust2


deploy:dev:
  stage: deploy
  variables:
    UPSTREAM_CI_COMMIT_SHORT_SHA: $CI_COMMIT_SHORT_SHA
    UPSTREAM_CI_COMMIT_BRANCH: $CI_COMMIT_BRANCH
    UPSTREAM_CI_COMMIT_TAG: $CI_COMMIT_TAG
    IMAGE_NAME: ${PROJECT_NAME}
    CUSTOMER: $CUSTOMER
  trigger: my/project/$PROJECT_HELM
  parallel:
    matrix:
      - CUSTOMER: $DEV_CUSTOMERS
  only:
    - DEV

But gitlab returns error saying that the triggered project can not be found. It seems that the variable $PROJECT_HELM is not converted to its real value in trigger path. How can I do it?

Thanks

Giamma
  • 808
  • 2
  • 10
  • 21

1 Answers1

0

Below is the working example where the variable ENV is used to trigger the sit pipeline. My pipeline file is in pipeline folder at root level. And the file name is sit-pipeline.yaml

stages:          
  - build

variables:
  ENV: sit

sit-pipeline:
  stage: build
  trigger:
    include:
      - local: pipeline/${ENV}-pipeline.yaml

There could be 2 issues

  1. Either you need to use ${var} syntax instead of $var syntax trigger: my/project/${PROJECT_HELM}
  2. Or PROJECT_HELM variable should resolve to a yaml file defining the pipeline. Your variable is assigned to helmpipe so I think you are missing .yaml extension
Sanjay Bharwani
  • 3,317
  • 34
  • 31
  • I've tried: trigger: 'my/project/${PROJECT_HELM}' and trigger: 'my/platform/${PROJECT_HELM}/-/blob/master/.gitlab-ci.yml' but they don't work because the inner pipe is not found. Since my child pipe is in another project I tried: trigger: include: - remote: 'https://my.gitlab-com/my/project/${PROJECT_HELM}/.gitlab-ci.yml' This doesn't work because there is a timeout retrieving the child file (maybe auth problems?) Thanks – Giamma Sep 09 '22 at 08:27
  • Using variable in the include might not work as include will be evaluated first. What you can try is the wild card include https://docs.gitlab.com/ee/ci/yaml/includes.html – Sanjay Bharwani Sep 09 '22 at 08:37
  • I tried: trigger: include: - project: 'my/project/${PROJECT_HELM}' - ref: master - file: .gitlab-ci.yml But the master pipe doesn't start due to "Pipeline cannot be run. include config must specify the file where to fetch the config from" – Giamma Sep 09 '22 at 09:08