GitLab CI
Start a Hecaton workspace from a trusted merge request pipeline and read its result in the job.
Configure the project
- Register the repository as a Hecaton project. Create a CI token limited to that project.
- Under Settings → CI/CD → Variables, add
HECATON_TOKENas a masked and protected variable. AddHECATON_PROJECT_IDandHECATON_CLI_VERSIONwith the project ID and a published CLI version. - Allow protected resources in merge request pipelines. The source and target branches must both be protected and belong to the same project. The person triggering the pipeline needs permission to push or merge into the target branch. Run the job only with trusted pipeline configuration. GitLab merge request pipelines.
Add the job
Add the following to .gitlab-ci.yml.
hecaton:
image: node:24
timeout: 20m
variables:
GIT_STRATEGY: none
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_SOURCE_PROJECT_ID == $CI_PROJECT_ID && $CI_MERGE_REQUEST_TARGET_PROJECT_ID == $CI_PROJECT_ID && $CI_MERGE_REQUEST_SOURCE_BRANCH_PROTECTED == "true" && $CI_MERGE_REQUEST_TARGET_BRANCH_PROTECTED == "true"'
script:
- ': "${HECATON_TOKEN:?}"'
- npm install --global --ignore-scripts "@hecaton-io/cli@${HECATON_CLI_VERSION:?}"
- |
if printf '%s\n' '{"resultContract":{"fields":{"summary":{"type":"string"}}}}' |
hecaton workspace create --body-file - --project "${HECATON_PROJECT_ID:?}" --branch "${CI_MERGE_REQUEST_SOURCE_BRANCH_NAME:?}" \
--prompt "Review this branch and publish a summary. Do not edit the code." \
--idempotency-key "gitlab-${CI_PROJECT_ID}-${CI_PIPELINE_ID}" \
--wait --timeout 900 --json > hecaton.jsonl; then
head -n 1 hecaton.jsonl
tail -n 1 hecaton.jsonl
else
status=$?
head -n 1 hecaton.jsonl
tail -n 1 hecaton.jsonl
exit "$status"
fiRead the result
The first line identifies the workspace after admission. The last line contains its result or the CLI error. Use the workspace ID to continue in Hecaton if the job exits with a pending question or times out. Retrying a job in the same pipeline reuses the idempotency key.