I am trying to call a trigger on one GitLab project using a job on another.
Let’s call one A, and the other B. I want a job in A to trigger a job in B.
In A, this is what my .gitlab-ci.yml
looks like:
deploy:staging:
image: alpine
variables:
GIT_STRATEGY: none
script:
- apk add --no-cache curl
- curl -X POST -F "token=$CI_JOB_TOKEN" -F "ref=$CI_COMMIT_REF_NAME" https://gitlab.com/api/v4/projects/1234/trigger/pipeline
In B, this is what my .gitlab-ci.yml
looks like:
image: google/cloud-sdk
deploy:staging:
only:
- triggers
script:
- echo "$CI_ENVIRONMENT_SLUG"
However, when A runs, I get the following result from curl:
{"message":{"base":["Reference not found"]}}
When I hardcode the ref to master, I get this message:
{"message":{"base":["No stages / jobs for this pipeline."]}}
How can A be configured, so that the deploy:staging
job in B is triggered on master?
Thinking ahead, I would like to add more deployment targets, so it should only trigger the deploy:staging
job.
"No stages / jobs for this pipeline."
either.