简体   繁体   中英

Gitlab web manual vs branch manual

I'm trying to set up a manual job to deploy in production and I'd like to understand the 2nd rule:

deploy_prod:
    stage: deploy_prod
    rules:
        - if: $CI_PIPELINE_SOURCE == 'web'
          when: manual
        - if: $CI_PIPELINE_SOURCE == 'push' && $CI_COMMIT_BRANCH == 'master'
          when: manual
    script: echo 1

the first rule allows me to deploy in production by click run pipeline on branch master, which will create a "blocked" pipeline requiring me to click the play button to run.

  • Is it possible to have that "blocked" pipeline created without having me to click run pipeline (I mean in the list of pipeline, I still want to need to click the play button to run it but that's one less step)

  • Concerning the second rule, I understand that if I remove when: manual any push (commit, merged branch) to master would trigger the job immediately, so what should be the behaviour when using when: manual ?

Thanks in advance for your help

To have the first rule run automatically without having to manually start it, you can either change when: manual to when: always and it will always run, or you can remove the first rule altogether. This works since you don't have a default rule set (ie, an "else" clause). The way your rules are right now, every pipeline source except for web and push will run automatically, so removing either of the rules will mean they job always runs automatically no matter the source. However, if you don't want the job to run for triggers , schedules , or merge_requests , but want web to run automatically, you must use when: always .

For your second rule, it might be best to clarify what you're asking in a separate question, but really the behavior is up to you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM