gitlab-ci.yml作业:build-production配置键不能与`rules`一起使用:仅
在 CI Lint 中测试 gitlab-ci.yml 时出现语法错误。有人可以建议解决这个问题吗?
build-production:
stage: build
only:
- master
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [""]
script:
- mkdir -p /kaniko/.docker
- echo "{"auths":{"$CI_REGISTRY":{"username":"$CI_REGISTRY_USER","password":"$CI_REGISTRY_PASSWORD"}}}" > /kaniko/.docker/config.json
- /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
rules:
- if: $CI_COMMIT_TAG
Status: syntax is incorrect
jobs:build-production config key may not be used with `rules`: only
回答
文档很清楚:
rules替换only/except并且它们不能在同一个作业中一起使用。如果您将一个作业配置为使用这两个关键字,则 linter 返回一个键可能不会使用规则错误。
我建议rules:用于您的两种情况:
rules:
- if: '$CI_COMMIT_REF_NAME == "master" && $CI_COMMIT_TAG'
THE END
二维码