I'm looking for a way on how to trigger periodical Jenkins jobs using gitlab (14.2.3-ee) webhooks.
As of now the Jenkins Gitlab integration is working using Push or TagPush events. But how can I schedule periodical build events?
I have seen the option for CI Schedules in gitlab, but this will only execute the gitlab pipeline. How can I trigger the Jenkins pipeline for such events?
CodePudding user response:
You can create a simple scheduled gitlab pipeline to call webhook.
A simple job like this should be sufficient :
# Exec pipeline only on scheduled pipeline
workflows:
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
trigger-jenkins:
stage: build
image: curlimages/curl:7.81.0
script:
- curl ${JENKINS_WEBHOOK_URL}
You have to put this code in a .gitlab-ci.yml
file and scheduled pipelines in CI/CD -> Schedules menu in Gitlab project UI.