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-engine
instance (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.yml
file, 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-engine
they just need to create the.scm-engine.yml
file in their project. - No intuitive access to
evaluation
logs within GitLab (you can see them in the server logs or in the webhook failure log).
Setup:
- Deploy
scm-engine
within your infrastructure in an environment that can communicate egress/ingress with GitLab. (seeserver
) - Configure your
webhook
at Project, Group, or Server level to hit the/gitlab
endpoint on thescm-engine
server 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
evaluation
logs 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.yml
file 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
api
scope. - Must have
developer
ormaintainer
role access so it can edit Merge Requests.
- Must have
Mask
should be checked.Protected
should NOT be checked.Expand variable reference
should NOT be checked.
- Name must be
-
Setup a CI job using the
scm-engine
Docker 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