Gitlab 从多项目管道运行手动作业

Gitlab 从多项目管道运行手动作业,gitlab,gitlab-ci,gitlab-ce,Gitlab,Gitlab Ci,Gitlab Ce,我有一个只包含手动作业的管道。是否可以从多项目管道中触发此管道并告诉它仅运行某些特定作业?就像模拟手动触发器一样 例如: 我的.gitlab ci.yml(在myProject/Foo中)文件如下所示: ... deploy_to_Production: <<: *job_deploy_definition stage: deploy when: manual variables: ENV: "Prod" only: refs:

我有一个只包含手动作业的管道。是否可以从多项目管道中触发此管道并告诉它仅运行某些特定作业?就像模拟手动触发器一样

例如:

我的
.gitlab ci.yml
(在myProject/Foo中)文件如下所示:

...

deploy_to_Production:
 <<: *job_deploy_definition
 stage: deploy
 when: manual
 variables:
    ENV: "Prod"
 only:
   refs:
     - tags

deploy_to_Integration:
 <<: *job_deploy_definition
 stage: deploy
 when: manual
 variables:
    ENV: "Int"

如果只希望从该管道触发
deploy\u to\u Production
,则可以将作业稍微拆分并使用

触发管道:

production_deploy:
  stage: deploy
  variables:
    DEPLOY_TO_PROD: true
  trigger:
    project: myProject/Foo
    #strategy: depend
integration_deploy:
  stage: deploy
  variables:
    DEPLOY_TO_INTEGRATION: true
  trigger:
    project: myProject/Foo
    #strategy: depend
另一个触发管道:

production_deploy:
  stage: deploy
  variables:
    DEPLOY_TO_PROD: true
  trigger:
    project: myProject/Foo
    #strategy: depend
integration_deploy:
  stage: deploy
  variables:
    DEPLOY_TO_INTEGRATION: true
  trigger:
    project: myProject/Foo
    #strategy: depend
myProject/Foo:

.deploy_to_Production:template:
 <<: *job_deploy_definition
 stage: deploy
 variables:
    ENV: "Prod"

deploy_to_Production:manual:
 extends: .deploy_to_Production:template
 rules:
   - if: $CI_COMMIT_TAG
     when: manual

deploy_to_Production:triggered:
 extends: .deploy_to_Production:template
 rules:
   - if: '$DEPLOY_TO_PROD == "true" && $CI_JOB_TRIGGERED == "true"'

.deploy_to_Integration:template:
 <<: *job_deploy_definition
 stage: deploy
 variables:
    ENV: "Int"

deploy_to_Integration:manual:
 extends: .deploy_to_Integration:template
 when: manual

deploy_to_Integration:triggered:
 extends: .deploy_to_Integration:template
 rules:
   - if: '$DEPLOY_TO_INTEGRATION == "true" && $CI_JOB_TRIGGERED == "true"'

.deploy\u to\u生产:模板:

如果只希望从该管道触发
deploy\u to\u Production
,则可以将作业稍微拆分并使用

触发管道:

production_deploy:
  stage: deploy
  variables:
    DEPLOY_TO_PROD: true
  trigger:
    project: myProject/Foo
    #strategy: depend
integration_deploy:
  stage: deploy
  variables:
    DEPLOY_TO_INTEGRATION: true
  trigger:
    project: myProject/Foo
    #strategy: depend
另一个触发管道:

production_deploy:
  stage: deploy
  variables:
    DEPLOY_TO_PROD: true
  trigger:
    project: myProject/Foo
    #strategy: depend
integration_deploy:
  stage: deploy
  variables:
    DEPLOY_TO_INTEGRATION: true
  trigger:
    project: myProject/Foo
    #strategy: depend
myProject/Foo:

.deploy_to_Production:template:
 <<: *job_deploy_definition
 stage: deploy
 variables:
    ENV: "Prod"

deploy_to_Production:manual:
 extends: .deploy_to_Production:template
 rules:
   - if: $CI_COMMIT_TAG
     when: manual

deploy_to_Production:triggered:
 extends: .deploy_to_Production:template
 rules:
   - if: '$DEPLOY_TO_PROD == "true" && $CI_JOB_TRIGGERED == "true"'

.deploy_to_Integration:template:
 <<: *job_deploy_definition
 stage: deploy
 variables:
    ENV: "Int"

deploy_to_Integration:manual:
 extends: .deploy_to_Integration:template
 when: manual

deploy_to_Integration:triggered:
 extends: .deploy_to_Integration:template
 rules:
   - if: '$DEPLOY_TO_INTEGRATION == "true" && $CI_JOB_TRIGGERED == "true"'

.deploy\u to\u生产:模板:

谢谢,但这实际上不适合我的用例,因为我需要触发的不仅仅是
deploy\u to\u Production
,这只是个例子。也许你应该使用。我再次更新了我的答案,给出了一个稍微不同的例子,可能对你有用。但是,您可能希望使用完整的用例更新您的问题。这在大多数情况下都很好,但如果在同一作业中同时使用关键字“when”和“rules”,则会遇到此错误:
作业:部署到生产:手动配置键不能与“rules”一起使用:when
。有什么解决方法吗?啊,更新的答案-认为您需要将
when:manual
移动到
rules:if:
语句中。请参阅以获取更多信息谢谢,但这实际上不适合我的用例,因为我需要触发的不仅仅是
deploy_to_Production
,这只是示例。也许你应该使用。我再次更新了我的答案,给出了一个稍微不同的例子,可能对你有用。但是,您可能希望使用完整的用例更新您的问题。这在大多数情况下都很好,但如果在同一作业中同时使用关键字“when”和“rules”,则会遇到此错误:
作业:部署到生产:手动配置键不能与“rules”一起使用:when
。有什么解决方法吗?啊,更新的答案-认为您需要将
when:manual
移动到
rules:if:
语句中。有关更多信息,请参阅