Reputation: 263
I have a simple gitlab-yaml file that I thought would run a job when only scheduled. However, it is getting fire on a push event as well. Can anyone please tell me the correct way in which to specify that a job is only run when scheduled. This is my gitlab-yaml file
job:on-schedule:
only:
- schedules
- branches
script:
- /usr/local/bin/phpunit -c phpunit_config.xml
Thanks
Upvotes: 0
Views: 468
Reputation: 6363
According to the GitLab documentation, branches
means "When a branch is pushed".
https://docs.gitlab.com/ce/ci/yaml/README.html#only-and-except-simplified
So including branches
in your only:
section causes the pipeline job to also run on pushes to any branch.
You can either remove the branches
entry, or if you wanted to restrict to pushes for a specific branch you could extend the branch entry to include project and branch name (branches@<project>/<branch>
).
My suggestion is to reduce your YML to:
job:on-schedule:
only:
- schedules
script:
- /usr/local/bin/phpunit -c phpunit_config.xml
Upvotes: 1