简体   繁体   English

Gitlabci 管道失败:gitlab-ci.yml 中规则中的语法错误

[英]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.

相关问题 在Gitlab中配置.gitlab-ci.yml文件以测试python代码 - Configuring .gitlab-ci.yml file in Gitlab to test python Codes gitlab-ci.yml:“脚本:-pytest”命令无法识别 - gitlab-ci.yml: 'script: -pytest' command is not recognized gitlab-ci.yml python -c'多行cmd'失败 - gitlab-ci.yml python -c 'multiple line cmd' failed 使用 pyyaml 的 Load.gitlab-ci.yml 失败,无法确定构造函数 - Load .gitlab-ci.yml with pyyaml fails with could not determine constructor 如何在 gitlab-ci.yml 中将 postgis 扩展添加到 postgresql 数据库 - How to add postgis extension to postgresql database in gitlab-ci.yml 我的 first.gitlab-ci.yml 文件:如何在 CI/CD 中运行现有文件 - My first .gitlab-ci.yml file: How to run existing files in CI/CD 如何在 Gitlab 中为简单的 hello world 程序配置 gitlab-ci.yml - How do I configure gitlab-ci.yml for a simple hello world program in Gitlab Gitlab Flask Page: Problems with installing python GDAL package for Frozen Flask Application with.gitlab-ci.yml file - Gitlab Flask Page: Problems with installing python GDAL package for Frozen Flask Application with .gitlab-ci.yml file 如何避免在.gitlab-ci.yml的每个阶段之前安装requirements.txt? - How to avoid installing requirements.txt before every stage in .gitlab-ci.yml? 如何解析我有权访问的所有存储库中的所有.gitlab-ci.yml 文件? - How to parse all the .gitlab-ci.yml files from all the repositories that i have access to?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM