I've pasted the example for rules in my gitlab-ci.yaml (from https://docs.gitlab.com/ee/ci/yaml/#rules):
job:
script: "echo Hello, Rules!"
rules:
- if: '$CI_MERGE_REQUEST_TARGET_BRANCH == "master"'
when: always
- if: '$VAR =~ /pattern/'
when: manual
- when: on_success
But I get
Error: jobs:job config contains unknown keys: rules
Am I missing something?
These are scripts that you choose to be run before the job is executed or after the job is executed. These can also be defined at the top level of the YAML file (where jobs are defined) and they'll apply to all jobs in the . gitlab-ci. yml file.
GitLab CI uses a YAML file ( . gitlab-ci. yml ) for project configuration. This file is placed in the root of the repository and defines the project's Pipelines, Jobs, and Environments. The YAML file defines a set of jobs with constraints for when they should be run.
From version 7.12, GitLab CI uses a YAML file ( . gitlab-ci. yml ) for the project configuration. It is placed in the root of your repository and contains definitions of how your project should be built.
Here is the definition from GitLab documentation: extends defines entry names that a job that uses extends inherits from. It's an alternative to using YAML anchors and is a little more flexible and readable. So, when is it useful? It is useful when you want to be DRY and keep your setup cleanly.
This feature is currently only available on gitlab.com.
Check the version of the instance you use and select the corresponding gitlab docs (in the header bar of the gitlab docs pages) eg https://docs.gitlab.com/12.2/ee/ci/yaml/README.html.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With