Ple*_*ase 11 pipeline gitlab gitlab-ci
我有一个包含 3 个阶段的管道:build、deploy-test和deploy-prod。我希望阶段具有以下行为:
build deploy-test在其他分支上时自动运行master或在其他分支上手动运行deploy-prod上可用master我的管道配置似乎可以实现这一点,但在尝试将分支合并到主分支时遇到问题。我不想deploy-test在合并之前在每个分支上执行阶段。现在我需要这样做,因为合并按钮被禁用并显示一条消息Pipeline blocked. The pipeline for this merge request requires a manual action to proceed。项目中的设置Pipelines must succeed已禁用。
我尝试添加额外的规则以防止deploy-test阶段在合并请求中运行,但它没有改变任何内容:
rules:
- if: '$CI_MERGE_REQUEST_ID'
when: never
- if: '$CI_COMMIT_BRANCH == "master"'
when: on_success
- when: manual
Run Code Online (Sandbox Code Playgroud)
全管道配置:
stages:
- build
- deploy-test
- deploy-prod
build:
stage: build
script:
- echo "build"
deploy-test:
stage: deploy-test
script:
- echo "deploy-test"
rules:
- if: '$CI_COMMIT_BRANCH == "master"'
when: on_success
- when: manual
deploy-prod:
stage: deploy-prod
script:
- echo "deploy-prod"
only:
- master
Run Code Online (Sandbox Code Playgroud)
我让它工作的唯一方法就是\xe2\x98\x91\xef\xb8\x8f Skipped pipelines are considered successful设置Setttings > General > Merge requests > Merge Checks
并将手动步骤标记为“allow_failure”
\nupload:\n stage: \'upload\'\n rules:\n # Only allow uploads for a pipeline source whitelisted here.\n # See: https://docs.gitlab.com/ee/ci/jobs/job_control.html#common-if-clauses-for-rules\n - if: $CI_COMMIT_BRANCH\n when: \'manual\'\n allow_failure: true\nRun Code Online (Sandbox Code Playgroud)\n之后单击按钮Merge when Pipeline succeeds\xe2\x80\xa6\n
\xe2\x80\xa6 将合并 MR,无需任何手动交互:
\n\n我已经使用以下内容打开了从分支“mybranch”到“master”的合并请求.gitlab-ci.yml:
image: alpine
stages:
- build
- deploy-test
- deploy-prod
build:
stage: build
script:
- echo "build"
# run deploy-test automatically when on master or manually when on other branches
# Don't run on merge requests
deploy-test:
stage: deploy-test
script:
- echo "deploy-test"
rules:
- if: $CI_MERGE_REQUEST_ID
when: never
- if: '$CI_COMMIT_BRANCH == "master"'
when: on_success
- when: manual
# run deploy-prod manually, only available on master branch
deploy-prod:
stage: deploy-prod
script:
- echo "deploy-prod"
rules:
- if: '$CI_COMMIT_BRANCH == "master"'
when: manual
Run Code Online (Sandbox Code Playgroud)
笔记:
only已被弃用,所以我将其替换为if当我将更改推送到分支“mybranch”时,GitLab 执行了以下操作:
| 归档时间: |
|
| 查看次数: |
5819 次 |
| 最近记录: |