continuous-integration - 不同阶段的 Gitlab CI 执行时间
问题描述
我敢打赌这只是我缺少的一些愚蠢的事情,但是我应该如何创建我的 gitlab-ci.yml 文件并安排每个晚上执行几个阶段(每晚测试)和一个阶段在周末执行一次(每周测试集)?
目前我有这样的设置:我想每晚执行的所有阶段都是相似的,只是名称改变了。
stage1:
stage: stage1
only:
- schedules
script:
- my execute script
allow_failure: true
artifacts:
when: always
paths:
- stuff here
reports:
junit: filename here
我还有一个每晚执行的时间表,它会在晚上 18:00 触发执行。
然后我有我想在星期六上午 10 点每周执行一次的阶段:
stagex:
stage: stagex
only:
- schedules
- cron 0 10 * * 6
script:
- my execute script
allow_failure: true
artifacts:
when: always
paths:
- stuff here
reports:
junit: filename here
上周六没有开火。UI 端没有单独的时间表。我应该在那里吗?有关如何使其工作的任何指示?
此外,我想要的是能够从一个按钮执行阶段 x(每周),因此需要时间表。如果 gitlab 通过其他方式启动它,它可以保持不活动状态。我尝试将变量设置为阶段并将其放在 UI 端,但我没有让它以这种方式工作。
肯定有一些我想念的东西......
解决方案
如果我理解你的目标,你想
- 仅在计划时(每天)执行 stage1
- 仅在计划(每周)或手动管道运行时执行 stagex。
以下应该做到这一点。您将需要设置每日和每周的时间表。对于每周计划,您需要将 SCHEDULED_JOB 定义为“stagex”;设置好时间表后,您可以按播放键手动运行作业。
variables:
SCHEDULED_JOB: "stage1"
stage1:
stage: stage1
rules:
- if: '$CI_PIPELINE_SOURCE == "schedule" && $SCHEDULED_JOB == $CI_JOB_NAME'
script:
- my execute script
allow_failure: true
artifacts:
when: always
paths:
- stuff here
reports:
junit: filename here
stagex:
stage: stagex
- if: '$CI_PIPELINE_SOURCE == "schedule" && '$SCHEDULED_JOB == $CI_JOB_NAME'
script:
- my execute script
allow_failure: true
artifacts:
when: always
paths:
- stuff here
reports:
junit: filename here
推荐阅读
- c# - MVVM 绑定 ComboBox 的 SelectedIndex,Combobox 使用了 ControlTemplate,绑定不起作用
- delphi - 错误 [dcc32 致命错误] F2084 内部错误:AV06028036(05FB0000)-R2CD489B0-0
- powershell - Windows Defender 不断阻止 PowerShell 导入模块
- python - 使用两个列表但使用函数的中位数
- html - css - 为什么打印中的 div 边距顶部模糊
- command-line-arguments - 通过 main 函数解析命令行参数
- python - 使用openpyxl将数据从列表附加到excel
- c++ - 尾随返回类型
- catboost - Catboost calc_feature_statistics 不绘图
- python - 我如何在 KivyMD 中制作多行标签?