I'd like to deploy my project once per day, but only if there have been changes. There is a specific hour each that I am able to deploy during and I am comfortable with using a scheduled pipeline to trigger and deploy.
However, there aren't always changes that require deployment. Ideally, if there have been no changes to the code base since the last deployment, the pipeline wouldn't run that day.
Is there any way to achieve this behaviour?
Run jobs for scheduled pipelines To configure a job to be executed only when the pipeline has been scheduled, use the rules keyword.
You can set a global timeout in "Project settings -> CI/CD Pipelines -> Timeout" or "Project settings -> Builds -> Timeout" in older versions. The job-level timeout can exceed the project-level timeout but can't exceed the Runner-specific timeout.
This is similar to a 4 years old feature request gitlab-org/gitlab-foss
issue 19813
GitLab CI only execute when a certain folder has changed
I have quite a large project, and I'm using GitLab CI with Pages to deploy it, however, when I change anything in the repo, it runs CI.
I don't want this to happen, I want it to run only if the
src
folder changes.
Is this possible?
The recent (July 2020) conclusion is to use only:changes
/except:changes
Using the
changes
keyword withonly
orexcept
makes it possible to define if a job should be created based on files modified by a Git push event.
Example:
I wanted this feature especially for
package.json
andpackage-lock.json
because I can runnpm install
only if there is changes.
only:
changes:
- package.json
- package-lock.json
Warning, as noted by Matthijs Bierman in the comments, and as documented here:
Note that
only: changes
does not work withwhen: scheduled
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With