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:
IaC Workflow
Use makandra-gitlab-infra to create the pipeline
- Setup the project as described in the README.md
- Check out the README.md for scheduled pipelines for instructions how to create or remove one
Warning
This is the legacy workflow we no longer want to use, since tokens are hard to rotate and will randomly expire.
Preparation
- 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"