我试图从AutoDevOps的gitlab管道中排除特定分支production
,但是我看不出能够找出正确的语法。这是我所拥有的:
build:
stage: build
image: docker:19.03.1
variables:
DOCKER_TLS_CERTDIR: ""
services:
- docker:19.03.8-dind
before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
script:
- |
if [[ -z "$CI_COMMIT_TAG" ]]; then
export CI_APPLICATION_REPOSITORY=${CI_APPLICATION_REPOSITORY:-$CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG}
export CI_APPLICATION_TAG=${CI_APPLICATION_TAG:-$CI_COMMIT_SHA}
else
export CI_APPLICATION_REPOSITORY=${CI_APPLICATION_REPOSITORY:-$CI_REGISTRY_IMAGE}
export CI_APPLICATION_TAG=${CI_APPLICATION_TAG:-$CI_COMMIT_TAG}
fi
# make and git needed to run makefiles
- apk add --update make
- apk add --update git
- make ci-build
- make ensure_project publish_artifact
rules:
# don't build on production - that is just a marker branch in git
- if: '$CI_COMMIT_BRANCH != "production"'
- if: '$CI_COMMIT_TAG || $CI_COMMIT_BRANCH'
但是,管道仍在production
上运行。我在做什么错了?
答案 0 :(得分:3)
答案 1 :(得分:0)
我用这个解决了这个任务
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME =~ /^dev$/'