Velvet Star Monitor

Standout celebrity highlights with iconic style.

news

"No Stages/Jobs jobs for this pipeline" for branch pipeline

Writer Matthew Martinez

Given the following .gitlab-ci.yml:

---
stages: - .pre - test - build
compile-build-pipeline: stage: .pre script: [...] artifacts: paths: [".artifacts/build.yaml"]
lint-source: stage: .pre script: [...]
run-tests: stage: test rules: - if: '$CI_COMMIT_BRANCH == "$CI_DEFAULT_BRANCH"' trigger: strategy: depend include: artifact: .artifacts/tests.yaml job: "compile-test-pipeline" needs: ["compile-test-pipeline"]
build-things: stage: test rules: - if: '$CI_COMMIT_BRANCH == "$CI_DEFAULT_BRANCH"' trigger: strategy: depend include: artifact: .artifacts/build.yaml job: "compile-build-pipeline" needs: ["compile-build-pipeline"]
...

The configuration should always run (any branch, any source). Tests and build jobs should be run only on the default branch.

However, no jobs are run for merge requests, and manually triggering the pipeline on branches other than the default one give the error No Jobs/Stages for this Pipeline.

I've tried explicitly setting an always run rule using rules: [{if: '$CI_PIPELINE_SOURCE'}] to the jobs in the .pre stage, but no dice.

What am I doing wrong?

2 Answers

As per the docs:

You must have a job in at least one stage other than .pre or .post.

In the above configuration, no jobs other than the ones in .pre are added on merge request events, hence no jobs are added at all.

2

I'm glad you added this info into the question: However, no jobs are run for merge requests

CI_COMMIT_BRANCH is not available in MR-based events. Here is an fragment from official docs:

The commit branch name. Available in branch pipelines, including pipelines for the default branch.
**Not available in merge request pipelines or tag pipelines.**

When working with MR and willing to check against branch name, you might want to use:CI_MERGE_REQUEST_SOURCE_BRANCH_NAME or CI_MERGE_REQUEST_TARGET_BRANCH_NAME

List of envs here

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.