[英]Gitlabci pipline failes with: syntax error in rules in gitlab-ci.yml
In the below gitlab-ci.yml I am getting a syntax error when I start a pipeline.在下面的 gitlab-ci.yml 中,当我启动管道时出现语法错误。 The rules are the same in other branches and the validation and other pipeline jobs run fine.其他分支的规则相同,验证和其他管道作业运行良好。
Syntax is incorrect.语法不正确。 CI configuration validated, including all configuration added with the includes keyword.已验证 CI 配置,包括使用 includes 关键字添加的所有配置。 More information jobs:foo-bar-validation:rules:rule if invalid expression syntax更多信息 jobs:foo-bar-validation:rules:rule if invalid expression syntax
stages:
- validation
- sonar
- release
- environments
- infrastructure-shared
- build
- infrastructure-by-environment
- deploy
- destroy
variables:
DOCKER_PYTHON_IMAGE: "${CI_REGISTRY}/foo/bar/python-3.6:2.1.3"
TERRAFORM_IMAGE: "${CI_REGISTRY}/foo/docker_images/terraform_1.0.1_common_utils:1.1.1"
SEMANTIC_RELEASE_IMAGE: "$CI_REGISTRY/foo/docker_images/semantic-release_17.4.4"
SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar"
GIT_DEPTH: 0
include:
# CI templates
- local: templates/gitlab/index.yml
# Sections
- local: foo/.gitlab-ci.yml
- local: bar/.gitlab-ci.yml
release:
stage: release
image: $SEMANTIC_RELEASE_IMAGE
tags:
- kubernetes
script:
- git fetch --all --tags
- semantic-release
rules:
- if: $CI_COMMIT_BRANCH =~ /(develop|master)/ && $CI_PIPELINE_SOURCE == "push"
- if: $CI_COMMIT_BRANCH =~ /(develop|master)/ && $CI_PIPELINE_SOURCE == "web"
- if: $CI_COMMIT_TAG
when: never
# ========================================================
# Sonar
# ========================================================
sonar-analysis:
stage: sonar
image:
name: sonarsource/sonar-scanner-cli:latest
entrypoint: [""]
cache:
key: "${CI_JOB_NAME}"
paths:
- .sonar/cache
script:
- sonar-scanner -Dsonar.organization=foo-sonar -Dsonar.python.coverage.reportPaths=coverage.xml -Dsonar.branch.name=${CI_COMMIT_BRANCH}
tags:
- kubernetes
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
when: never
- if: $CI_PIPELINE_SOURCE == "push" || $CI_PIPELINE_SOURCE == "merge_request_event" || $CI_PIPELINE_SOURCE == "web"
changes:
- microservices/foo/foo/**/*
- if: $CI_COMMIT_TAG
when: never
dependencies:
- foo-bar-validation
environment-variables-files:
stage: environments
image: $TERRAFORM_IMAGE
environment:
name: $CI_COMMIT_BRANCH/prepare
action: prepare
tags:
- kubernetes
script:
# TODO: move to terraform base image
- apk add coreutils
- bash scripts/generate_envs.sh
rules:
- if: $CI_COMMIT_BRANCH =~ /(master|develop)/ && $CI_PIPELINE_SOURCE == "push"
- if: $CI_COMMIT_BRANCH =~ /(master|develop)/ && $CI_PIPELINE_SOURCE == "web"
- if: $CI_COMMIT_TAG
when: never
artifacts:
name: 'env-variables-$CI_COMMIT_REF_NAME'
expire_in: 5h
paths:
- .env
I found the answer by comparing one of the dependent files to another branch and resolved the syntax issue.我通过将一个依赖文件与另一个分支进行比较找到了答案,并解决了语法问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.