Setup¶
Webhook Server¶
Using scm-engine as a webhook server allows for richer feature set compared to GitLab CI pipeline mode
- Real-time reactions to changes.
- Reacting to comments.
- Access to webhook event data in scripts via
webhook_event.*(see server docs for more information). - A single
scm-engineinstance (and single token) for your GitLab project, group, or instance depending on where you configure the webhook. - Each Project still have their own
.scm-engine.ymlfile, it's downloaded via the API when the server is processing a webhook event. - A single "bot" identity across your projects.
- Turn key once configured; if a project want to use
scm-enginethey just need to create the.scm-engine.ymlfile in their project. - No intuitive access to
evaluationlogs within GitLab (you can see them in the server logs or in the webhook failure log).
Setup:
- Deploy
scm-enginewithin your infrastructure in an environment that can communicate egress/ingress with GitLab. (seeserver) - Configure your
webhookat Project, Group, or Server level to hit the/gitlabendpoint on thescm-engineserver endpoint. (seeserver)
GitLab-CI pipeline¶
Using scm-engine within a GitLab CI pipeline is straight forward - every time a CI pipeline runs, scm-engine will evaluate the Merge Request.
- Simple & quick installation.
- Limited access token permissions.
- Easy access to
evaluationlogs within the GitLab CI job. - Can't react to comments; only works within a CI pipeline.
- Higher latency for reacting to changes depending on how fast CI jobs run (and where in the pipeline it runs).
Setup:
- Add a
.scm-engine.ymlfile in the root of your project. - Create a CI/CD Variable
- Name must be
SCM_ENGINE_TOKEN - Value must a Project Access Token
- Must have
apiscope. - Must have
developerormaintainerrole access so it can edit Merge Requests.
- Must have
Maskshould be checked.Protectedshould NOT be checked.Expand variable referenceshould NOT be checked.
- Name must be
-
Setup a CI job using the
scm-engineDocker image that will run when a pipeline is created from a Merge Request Event.scm-engine::evaluate::on-merge-request-event: image: ghcr.io/jippi/scm-engine:latest rules: - if: $CI_PIPELINE_SOURCE == 'merge_request_event' script: - scm-engine evaluate scm-engine::evaluate::on-schedule: image: ghcr.io/jippi/scm-engine:latest rules: - if: $CI_PIPELINE_SOURCE == "schedule" script: - scm-engine evaluate all -
Done! Every Merge Request change should now re-run scm-engine and apply your label rules