gitlab-ci.yml jobs:build-production config key may not be used with `rules`: only
gitlab-ci.yml jobs:build-production config key may not be used with `rules`: only
我在 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
Documentation 很清楚:
rules
replaces only
/except
and they can’t be used together in the same job. If you configure one job to use both keywords, the linter returns a key may not be used with rules error.
我建议对您的两种情况使用 rules:
:
rules:
- if: '$CI_COMMIT_REF_NAME == "master" && $CI_COMMIT_TAG'
这是不正确的,除非您创建标签 master
。
参见:https://gitlab.sron.nl/help/ci/variables/predefined_variables.md
CI_COMMIT_REF_NAME
The branch or tag name for which project is built.
此处描述了一种解决方法:
我在 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
Documentation 很清楚:
rules
replacesonly
/except
and they can’t be used together in the same job. If you configure one job to use both keywords, the linter returns a key may not be used with rules error.
我建议对您的两种情况使用 rules:
:
rules:
- if: '$CI_COMMIT_REF_NAME == "master" && $CI_COMMIT_TAG'
这是不正确的,除非您创建标签 master
。
参见:https://gitlab.sron.nl/help/ci/variables/predefined_variables.md
CI_COMMIT_REF_NAME
The branch or tag name for which project is built.
此处描述了一种解决方法: