Reputation: 23
I bet this is just some stupid thing I am missing, but how should I create my gitlab-ci.yml file and schedules to have several stages to execute every night (nightly testing) and one stage to execute once over weekend (weekly test set)?
Currently I have the setup like: All the stages I want to have executed every night are similar, only names change ofc.
stage1:
stage: stage1
only:
- schedules
script:
- my execute script
allow_failure: true
artifacts:
when: always
paths:
- stuff here
reports:
junit: filename here
I also have a schedule for the nightly execution which triggers the execution just fine at 18:00 pm.
Then I have the stage I want to execute once per week on saturday at 10 am:
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
This did not fire last saturday. There are no separate schedule on the UI side. Should I have it there? Any pointers on how to get it work?
Also what I would like to have is to able to execute the stage x (the weekly) from a button, so schedule would be required to that. That can be left inactive ofc if gitlab starts it by other means. I tried this with setting variables to the stages and having those in the UI side but I did not get it to work this way.
There is something that I am missing for sure...
Upvotes: 0
Views: 1105
Reputation: 1196
If I understood your goal, you want to
The following should accomplish such. You will need to have the daily and weekly schedules set. For the weekly schedule you will need to define SCHEDULED_JOB as "stagex"; once the schedule is set you can press play on it so manually run the job.
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
Upvotes: 1