0

CI Setup

i am trying to configure a yml in this format but i got some issues like :(): mapping values are not allowed in this context at line 8 column 8.

    include:
      - template: SAST.gitlab-ci.yml

    variables:
      SAST_GOSEC_LEVEL: 2

    spotbugs-sast:
     stage: QA
      rules:
         if: $CI_COMMIT_BRANCH == "master"
         if: $CI_MERGE_REQUEST_ID


ERROR: (<unknown>): mapping values are not allowed in this context at line 8 column 8.

Ahura
  • 21
  • 3

1 Answers1

0

Two issues:

  • rules must be at the same indentation as stage. If it is more indented, it counts as part of the value started with QA, which leads to this error since YAML does not allow multi-line scalars to be a key of a mapping (indicated by : after rules).
  • rules must be a sequence.

So the fixed YAML is:

include:
  - template: SAST.gitlab-ci.yml

variables:
  SAST_GOSEC_LEVEL: 2

spotbugs-sast:
  stage: QA
  rules:
    - if: $CI_COMMIT_BRANCH == "master"
    - if: $CI_MERGE_REQUEST_ID
flyx
  • 35,506
  • 7
  • 89
  • 126