代码之家  ›  专栏  ›  技术社区  ›  Tyvain

具有代码质量的Gitlab ci:此Gitlab ci配置无效

  •  1
  • Tyvain  · 技术社区  · 6 年前

    image: maven:latest
    
    stages:
      - code_quality
      - build
    
    code_quality:
      image: docker:stable
      variables:
        DOCKER_DRIVER: overlay2
      allow_failure: true
      services:
        - docker:stable-dind
      script:
        - export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
        - docker run
            --env SOURCE_CODE="$PWD"
            --volume "$PWD":/code
            --volume /var/run/docker.sock:/var/run/docker.sock
            "registry.gitlab.com/gitlab-org/security-products/codequality:$SP_VERSION" /code
      artifacts:
        paths: [gl-code-quality-report.json]
    
    build:
      stage: build
      script:
        - mvn compile
    

    https://gitlab.com/tyvain/mvn-ci-test/blob/master/.gitlab-ci.yml

    在代码质量方面,我无法使用官方gitlab示例: https://docs.gitlab.com/ee/ci/examples/code_quality.html

    错误是:“此GitLab CI配置无效:code\u quality job:stage参数应为code\u quality,build”

    2 回复  |  直到 6 年前
        1
  •  2
  •   S.K.    6 年前

    code_quality 阶段缺少 stage 参数。包括以下内容:

    code_quality:
      stage: code_quality
      image: docker:stable
      ...
    
        2
  •  1
  •   Thomas Martin Michael Laffargue    5 年前

    值得注意的是如果你有 .gitlab-cy.yml stages 零件应添加到主文件中。

    例子:

    stages:
      - build
      - test
      - analysis
    
    include:
      - local: '/FRONTEND/.gitlab-ci.yml'
      - local: '/SERVER/.gitlab-ci.yml'
    

    因为如果你把 阶段 job: stage parameter should be .