需要限制诸如仅部署到主项目的阶段。但是,所有分叉项目都需要构建和测试。
我限制了阶段:仅部署到“主”上。但是,这限制了构建不能只在功能主文档上执行,而不能在“分叉”项目主文档上执行。
variables:
MAVEN_CLI_OPTS: "--batch-mode --errors --fail-at-end --show-version"
MAVEN_OPTS: "-Djava.awt.headless=true -Dmaven.repo.local=./.m2/repository"
cache:
paths:
- ./.m2/repository
# keep cache across branch
key: "$CI_BUILD_REF_NAME"
stages:
- build
- test
- deploy
build:
stage: build
cache:
key: edu-erp
paths:
- .m2/repository/
script:
- "mvn clean compile $MAVEN_CLI_OPTS"
artifacts:
paths:
- target/
test:
stage: test
cache:
key: edu-erp
script:
- "mvn test $MAVEN_CLI_OPTS"
deploy_review:
stage: deploy
script:
- echo "deploy_review"
only:
- branches
except:
- master
when:
manual
deploy_staging:
stage: deploy
script:
- echo "deploy_staging"
only:
- master
deploy_prod:
stage: deploy
script:
- echo "Deploy to prod"
only:
- master
when:
manual
该场景是gitlab上有一个开源项目。每个人都参与这个项目;但是分叉的项目不应部署人工制品。
答案 0 :(得分:1)
您可以使用@
键值中的only
语法解决此问题(reference,向下滚动)。
鉴于您的小组和项目名为mygroup
和myproject
,它看起来像这样:
deploy_prod:
stage: deploy
script:
- echo "Deploy to prod"
only:
- master@gitlab-org/gitlab-ce
when:
manual