Gitlab CI 不同阶段的执行时序
Gitlab CI execution timing for different stages
我敢打赌这只是我遗漏的一些愚蠢的事情,但我应该如何创建我的 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 端,但我没有让它以这种方式工作。
我确实缺少一些东西...
如果我理解你的目标,你想
- 仅在计划时(每天)执行阶段 1
- 仅在计划(每周)或手动管道时执行 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
我敢打赌这只是我遗漏的一些愚蠢的事情,但我应该如何创建我的 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 端,但我没有让它以这种方式工作。
我确实缺少一些东西...
如果我理解你的目标,你想
- 仅在计划时(每天)执行阶段 1
- 仅在计划(每周)或手动管道时执行 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