GitLab doesn’t run run jobs defined in my included files.
We are trying to set up global rules for all our projects and I can’t seem to get the jobs inside the included .yml to execute. I only get the single job inside my .gitlab-ci.yml file to execute.
Here is the .gitlab-ci.yml file:
include:
# A local configuration file is required for the default-ci.yml to work.
# The local include must always precede the bri000-cicd include
- local: 'ci-variables.yml'
# Include from the bri000-cicd repository
- project: 'briowireless/bri/bri000/bri000-cicd'
# The ref below can be a branch name, a tag or a commit SHA-1.
ref: bugfix/default-branch
file: 'default-ci.yml'
# All checks are part of the default-ci.yml file. Only the build stages are required.
stages:
# Do not remove the prep and check stages as they are needed for the included default Brio rules
- prep
- check
- build
default:
before_script:
# Fetch the submodules manually since it can't be done with the submodule strategy
- git submodule sync --recursive
- git submodule update --init --recursive
build-code:
stage: build
script:
- echo "Building application"
Here is my included file:
workflow:
rules:
# Workflow rules are assessed in sequential order (ie. GitLab checks the rules starting from the top until a rule is true)
# The rules allow pipelines to run in multiple conditions:
# We always run pipelines for merge requests
# We never run pipelines for branches that have an open merge request (removes duplicates)
# We can start pipelines manually if the branch name starts with 'wip/' (regardless of MR or not)
# We always run pipelines for all other branches that do not fall in the conditions above
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
- if: $CI_COMMIT_BRANCH == 'initial'
when: never
- if: $CI_COMMIT_BRANCH =~ '/wip\/.*/'
# Allows wip branch pipelines to not be run (prevents unwanted errors)
when: never
- if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS
when: never
- if: $CI_COMMIT_BRANCH
stages:
- prep
- check
variables:
COMMIT_SHA: $CI_COMMIT_SHA
# This is required because the submodules are handled by the GitLab runners.
# The GitLab runners don't work with ssh clones, therefore, we must fetch
# the submodules in the recipes themselves.
# See the link below for more info:
# https://gitlab.com/gitlab-org/gitlab-runner/-/issues/2075
GIT_SUBMODULE_STRATEGY: none
# Get docker image which contains all required tools for quality checks
image: <path to our registry image>
prepare files:
stage: prep
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
variables:
# Override the default value
COMMIT_SHA: $CI_MERGE_REQUEST_TARGET_BRANCH_SHA
script:
# Generate list of files (this will be used by the other CI checks)
# Do some stuff with the $COMMIT_SHA variable
artifacts:
paths:
- ci.txt
tags:
- lint
ciformat:
stage: check
rules:
- if: $ENABLE_CLANGFORMAT != "YES"
when: never
needs:
- job: "prepare files"
script:
- echo "Check clang-format"
- FILES="$(cat ci.txt)"
- clang-format-13 -i -style=file $FILES -n -Werror --ferror-limit=1
tags:
- lint
cidoc:
stage: check
rules:
- if: $ENABLE_DOXYGEN != "YES"
when: never
needs:
- job: "prepare files"
script:
- echo "Check doxygen"
- mkdir -p ci/doxyten
- touch ci/doxygen/warnings.log
- chmod +x ci/scripts/run_doxygen.sh
- ci/scripts/run_doxygen.sh -i ci.txt
artifacts:
paths:
- ci/doxygen/warnings.log
- ci/doxygen/html
tags:
- lint
What am I missing?
Thanks for the help
Michel