Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Schedule or trigger jobs in gitlab-ci

Tags:

gitlab-ci

I want to run a heavy test only once per day in Gitlab-ci. Is it possible schedule a job? Or is it possible to set it to manual and trigger it using the API?

like image 296
Jesse van Bekkum Avatar asked Jan 29 '26 23:01

Jesse van Bekkum


2 Answers

It's possible to schedule a pipeline since GitLab 9.1, see: https://docs.gitlab.com/ce/user/project/pipelines/schedules.html

Currently (i.e. with version 9.2) it can be configured as follows:

  1. Navigate to your project's Pipelines ➔ Schedules and click the New Schedule button.
  2. Fill in the form
  3. Hit Save pipeline schedule for the changes to take effect.
like image 65
DerMiggel Avatar answered Feb 01 '26 02:02

DerMiggel


It's a patch up job, but you could use triggers with a if statement :

test_app:
  stage: test
  script:
  - if [ -n "${DO_TESTS}" ]; then make test; fi

And define the variable in the cron that make the call :

curl --request POST \
  --form token=TOKEN \
  --form ref=master \
  --form "variables[DO_TESTS]=true" \
  https://gitlab.example.com/api/v3/projects/9/trigger/builds

See the doc : https://docs.gitlab.com/ce/ci/triggers/README.html

like image 21
Shengis Avatar answered Feb 01 '26 02:02

Shengis



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!