The owner of a scheduled CI/CD pipeline in GitLab will always be notified if the pipeline fails.
Follow these steps if you don't want this:
- Create a
Project Access Token
withapi
scope and maintainer role - Create the scheduled pipeline with that token:
curl --request POST --header "PRIVATE-TOKEN: ${TOKEN}" \ --form description="Daily pipeline check" \ --form ref="main" \ --form cron="0 10 * * *" \ --form cron_timezone="UTC" \ --form active="true" \ "https://${GITLAB_URL}/api/v4/projects/${PROJECT_ID}/pipeline_schedules"
- Optional: Configure other notifications like Slack or Pipeline status emails with
Integrations
Add a CI/CD variable to the scheduled pipeline
Only the owner of a pipeline can add a CI/CD variable with the GUI. The following steps show how a variable can be added with the GitLab API:
- Find the PIPELINE_ID for the created scheduled pipeline:
curl --header "PRIVATE-TOKEN: ${TOKEN}" \
"https://${GITLAB_URL}/api/v4/projects/${PROJECT_ID}/pipeline_schedules" \
| jq
[
{
"id": 87,
"description": "Daily pipeline check",
...
}
]
- Add the variable (key and value) to the pipeline:
curl --request POST --header "PRIVATE-TOKEN: ${TOKEN}" \
--form "key=CI_SCHED_FREQ" \
--form "value=weekly" \
"https://${GITLAB_URL}/api/v4/projects/${PROJECT_ID}/pipeline_schedules/${PIPELINE_ID}/variables"
- Check the result:
curl --header "PRIVATE-TOKEN: ${TOKEN}" \
"https://${GITLAB_URL}/api/v4/projects/${PROJECT_ID}/pipeline_schedules/${PIPELINE_ID}" \
| jq
{
...
"variables": [
{
"variable_type": "env_var",
"key": "CI_SCHED_FREQ",
"value": "weekly",
"raw": false
}
]
}
- Use the variable like any other CI/CD variable:
...
rules:
- if: $CI_PIPELINE_SOURCE == "schedule" && $CI_SCHED_FREQ == "weekly"