限制gitlab ci中的阶段分叉项目(使用auto devops)

限制gitlab ci中的阶段分叉项目(使用auto devops),gitlab,gitlab-ci,git-fork,Gitlab,Gitlab Ci,Git Fork,需要限制像只部署到主项目这样的阶段。然而,构建和测试需要可用于所有分叉项目 我已将阶段限制为:仅在“master”上部署。然而,这限制了构建不仅在功能主控上执行,而且在“分叉”主控项目中执行 variables: MAVEN_CLI_OPTS: "--batch-mode --errors --fail-at-end --show-version" MAVEN_OPTS: "-Djava.awt.headless=true -Dmaven.repo.local=./.m2/reposi

需要限制像只部署到主项目这样的阶段。然而,构建和测试需要可用于所有分叉项目

我已将阶段限制为:仅在“master”上部署。然而,这限制了构建不仅在功能主控上执行,而且在“分叉”主控项目中执行


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上有一个开源项目。每个人都参与这个项目;但是,分叉项目不应部署人工制品。

您可以使用
@
语法(仅
键的值(,向下滚动)来解决此问题

鉴于您的组和项目被称为
mygroup
myproject
,它看起来是这样的:

deploy_prod:
  stage: deploy
  script:
    - echo "Deploy to prod"
  only:
    - master@gitlab-org/gitlab-ce
  when:
    manual