GitLab CI offers very nice flexibility and multiple features. Because of that is not obvious how particular configurations should be achieved using GitLabCI yaml, scheduler, etc.
I am interested to setup a workflow, which I am presenting below in a simplified way.
I use only master branch, where I want my primary pipeline to kick in after every commit. This pipeline will build and test my package. I want to also have a scheduled nightly pipeline which publish website of my package. So it takes the most recent artifacts, generate documentation and publish that together to GitLab pages.
So, basically I want to have two different pipelines being run on the same branch. Primary is the regular one, and the secondary is the one run by scheduler.
In my real use case I want to have 2 scheduled nightly pipelines and one weekly pipeline, so including primary one (every commit), total 4 pipelines, still for the same branch.
Using only
/rules
doesn't really address that. There is a new workflow
command, which could in theory, be applied here, by branching
if scheduled then
include nightly.gitlab-ci.yml
else
include primary.gitlab-ci.yml
But I don't think it is possible.
What could be the most user friendly solution is to give scheduled pipelines an option to choose custom .gitlab-ci.yml
file rather than starting default one.
Any ideas how to achieve configuration I am looking for?
The only way I have in mind is to keep having another branch, clone of master, where I need to replace .gitlab-ci.yml
every evening. Which requires extra workstation to automate that.
If you have pipeline which launches after every commit then just add deploy stage to it which will only be executed for scheduled triggers. That way you will need only one CI configuration:
I understand your original question is if you can run deploy job on scheduled pipelines only but why not test it and build anew in such case? It is usually a good practice to test and build your artifacts just before deploy especially if it doesn't take too much time.