2017-05-18 06:55:29 -04:00
|
|
|
# Pipeline Schedules
|
|
|
|
|
|
|
|
> **Notes**:
|
2018-09-06 12:52:18 -04:00
|
|
|
> - This feature was introduced in 9.1 as [Trigger Schedule][ce-10533].
|
|
|
|
> - In 9.2, the feature was [renamed to Pipeline Schedule][ce-10853].
|
|
|
|
> - Cron notation is parsed by [Rufus-Scheduler](https://github.com/jmettraux/rufus-scheduler).
|
2017-05-18 06:55:29 -04:00
|
|
|
|
2017-11-24 18:03:48 -05:00
|
|
|
Pipeline schedules can be used to run a pipeline at specific intervals, for example every
|
2017-05-18 06:55:29 -04:00
|
|
|
month on the 22nd for a certain branch.
|
|
|
|
|
|
|
|
## Using Pipeline schedules
|
|
|
|
|
|
|
|
In order to schedule a pipeline:
|
|
|
|
|
2018-03-23 09:20:07 -04:00
|
|
|
1. Navigate to your project's **CI / CD ➔ Schedules** and click the
|
2017-05-18 06:55:29 -04:00
|
|
|
**New Schedule** button.
|
|
|
|
1. Fill in the form
|
|
|
|
1. Hit **Save pipeline schedule** for the changes to take effect.
|
|
|
|
|
|
|
|
![New Schedule Form](img/pipeline_schedules_new_form.png)
|
|
|
|
|
2018-09-06 12:52:18 -04:00
|
|
|
> **Attention:**
|
2017-05-18 06:55:29 -04:00
|
|
|
The pipelines won't be executed precisely, because schedules are handled by
|
|
|
|
Sidekiq, which runs according to its interval.
|
|
|
|
See [advanced admin configuration](#advanced-admin-configuration) for more
|
|
|
|
information.
|
|
|
|
|
|
|
|
In the **Schedules** index page you can see a list of the pipelines that are
|
|
|
|
scheduled to run. The next run is automatically calculated by the server GitLab
|
|
|
|
is installed on.
|
|
|
|
|
|
|
|
![Schedules list](img/pipeline_schedules_list.png)
|
|
|
|
|
2018-01-22 10:40:48 -05:00
|
|
|
### Running a scheduled pipeline manually
|
|
|
|
|
|
|
|
> [Introduced][ce-15700] in GitLab 10.4.
|
|
|
|
|
|
|
|
To trigger a pipeline schedule manually, click the "Play" button:
|
|
|
|
|
|
|
|
![Play Pipeline Schedule](img/pipeline_schedule_play.png)
|
|
|
|
|
|
|
|
This will schedule a background job to run the pipeline schedule. A flash
|
|
|
|
message will provide a link to the CI/CD Pipeline index page.
|
|
|
|
|
|
|
|
To help avoid abuse, users are rate limited to triggering a pipeline once per
|
|
|
|
minute.
|
|
|
|
|
2017-06-29 00:10:53 -04:00
|
|
|
### Making use of scheduled pipeline variables
|
|
|
|
|
|
|
|
> [Introduced][ce-12328] in GitLab 9.4.
|
|
|
|
|
|
|
|
You can pass any number of arbitrary variables and they will be available in
|
|
|
|
GitLab CI so that they can be used in your `.gitlab-ci.yml` file.
|
|
|
|
|
|
|
|
![Scheduled pipeline variables](img/pipeline_schedule_variables.png)
|
|
|
|
|
2017-06-12 03:16:38 -04:00
|
|
|
## Using only and except
|
|
|
|
|
|
|
|
To configure that a job can be executed only when the pipeline has been
|
|
|
|
scheduled (or the opposite), you can use
|
2017-11-19 06:25:28 -05:00
|
|
|
[only and except](../../../ci/yaml/README.md#only-and-except-simplified) configuration keywords.
|
2017-06-12 03:16:38 -04:00
|
|
|
|
|
|
|
```
|
|
|
|
job:on-schedule:
|
|
|
|
only:
|
|
|
|
- schedules
|
|
|
|
script:
|
|
|
|
- make world
|
|
|
|
|
|
|
|
job:
|
|
|
|
except:
|
|
|
|
- schedules
|
|
|
|
script:
|
|
|
|
- make build
|
|
|
|
```
|
|
|
|
|
2017-05-18 06:55:29 -04:00
|
|
|
## Taking ownership
|
|
|
|
|
|
|
|
Pipelines are executed as a user, who owns a schedule. This influences what
|
|
|
|
projects and other resources the pipeline has access to. If a user does not own
|
|
|
|
a pipeline, you can take ownership by clicking the **Take ownership** button.
|
|
|
|
The next time a pipeline is scheduled, your credentials will be used.
|
|
|
|
|
|
|
|
![Schedules list](img/pipeline_schedules_ownership.png)
|
|
|
|
|
2018-11-30 02:32:30 -05:00
|
|
|
NOTE: **Note:**
|
|
|
|
If the owner of a pipeline schedule doesn't have the ability to create pipelines
|
|
|
|
on the target branch, the schedule will stop creating new pipelines. This can
|
|
|
|
happen if, for example, the owner is blocked or removed from the project, or
|
|
|
|
the target branch or tag is protected. In this case, someone with sufficient
|
|
|
|
privileges must take ownership of the schedule.
|
2017-05-18 06:55:29 -04:00
|
|
|
|
|
|
|
## Advanced admin configuration
|
|
|
|
|
|
|
|
The pipelines won't be executed precisely, because schedules are handled by
|
|
|
|
Sidekiq, which runs according to its interval. For example, if you set a
|
|
|
|
schedule to create a pipeline every minute (`* * * * *`) and the Sidekiq worker
|
|
|
|
runs on 00:00 and 12:00 every day (`0 */12 * * *`), only 2 pipelines will be
|
|
|
|
created per day. To change the Sidekiq worker's frequency, you have to edit the
|
2017-06-01 02:49:32 -04:00
|
|
|
`pipeline_schedule_worker_cron` value in your `gitlab.rb` and restart GitLab.
|
2017-05-18 06:55:29 -04:00
|
|
|
For GitLab.com, you can check the [dedicated settings page][settings]. If you
|
|
|
|
don't have admin access to the server, ask your administrator.
|
|
|
|
|
|
|
|
[ce-10533]: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/10533
|
|
|
|
[ce-10853]: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/10853
|
2017-06-29 00:10:53 -04:00
|
|
|
[ce-12328]: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/12328
|
2018-01-22 10:40:48 -05:00
|
|
|
[ce-15700]: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/15700
|
2017-05-18 06:55:29 -04:00
|
|
|
[settings]: https://about.gitlab.com/gitlab-com/settings/#cron-jobs
|