不同阶段的Gitlab CI执行时间



我敢打赌这只是我缺少的一些愚蠢的东西,但我应该如何创建我的gitlab-ci.yml文件和时间表,以便每晚执行几个阶段(夜间测试(,周末执行一次阶段(每周测试集(?

目前我的设置如下:我想每晚执行的所有阶段都是相似的,只是名字变了ofc。

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";;一旦设置好时间表,你就可以在上面按play,所以手动运行作业。

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

最新更新