模板文件在Gitlab CI/CD中不是有效位置



我修改了我的Gitlab CI/CD当前进程,使用codeclimate添加了一个关于代码质量的阶段。我已经尽可能地遵循Gitlab文档,但我在配置模板方面遇到了一个错误。

 .codeclimate.yml is not a valid location!

这是我的.gitlabci.yml文件的内容

include:
 - template: .codeclimate.yml
stages:
  - slack-start-prod
  - slack-start-staging
  - docker
  - test
  - code-quality
  - deploy-staging
  - deploy-prod
  - slack-end-prod
  - slack-end-staging
  - slack-failure
//////////////////////////////////////////////////////////
#------------------------------------------
# run tests on builded docker image
#------------------------------------------
test:
  stage: test
  image:
    name: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA
  services:
    - name: mysql:5.7
      alias: mysql
    - name: redis:6
      alias: redis
  variables:
    MYSQL_DATABASE: xx
    MYSQL_ROOT_PASSWORD: xx
    MYSQL_USERNAME: xx
    MYSQL_HOST: xx
  artifacts:
    reports:
      junit: phpunit-report.xml
    expire_in: 10 minutes
    when: always
  before_script:
    - until $(nc -z -v -w1 mysql 3306);do echo Waiting for mysql to be ready... && sleep 5s;done
  script:
    - cp .env.test.example /var/www/html/.env
    - echo 'ok' | mysql --user="$MYSQL_USERNAME" --password="$MYSQL_ROOT_PASSWORD" --host="$MYSQL_HOST" --execute="CREATE DATABASE xx"
    - cd /var/www/html
    - php artisan migrate --force
    - php -dxdebug.mode=coverage vendor/bin/phpunit --configuration phpunit.xml --log-junit phpunit-report.xml --coverage-text --colors=never
    - cp phpunit-report.xml $CI_PROJECT_DIR/
  tags:
    - kubernetes
#------------------------------------------
# run code quality
#------------------------------------------
code-quality:
  stage: test
  services:
    - name: codeclimate/codeclimate-phpcodesniffer
      alias: codeclimate-phpcodesniffer
    - name: codeclimate/codeclimate-duplication
      alias: codeclimate-duplication
  image:
    name: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA
  artifacts:
    paths: [gl-code-quality-report.json]
    reports:
      codequality: gl-code-quality-report.json
  script:
    - codeclimate analyze
    - cp gl-code-quality-report.json $CI_PROJECT_DIR/
  variables:
    REPORT_FORMAT: html
  tags:
    - kubernetes
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

.codeclimate.yml模板是您项目中的本地文件吗?如果是,请使用local关键字指定本地yaml文件。

include:
  - local: .codeclimate.yml

include:
  - local: '.codeclimate.yml'

编辑:阅读Gitlab文档后,这应该不会那么复杂,因为codeclimate插件已经集成在所有层中。

include:
  - template: Code-Quality.gitlab-ci.yml
code_quality:
  artifacts:
    paths: [gl-code-quality-report.json]

最新更新