GitLab

GitLab CI/CD: MR Preview Environments

Applies to
Gatewayruntime for API, AI, and MCP gateways
Hosting
Managed EdgeManaged DedicatedSelf-HostedDiffers
1 difference by hosting option
Self-Hosted

Add --self-hosted-endpoint with your management API hostname to each zuplo deploy and zuplo delete command so it targets your cluster. See zuplo deploy.

Deploy preview environments for merge requests and clean up when they close.

YAML.gitlab-ci.yml
image: node:24 stages: - deploy - test - cleanup deploy: stage: deploy script: - npm install - npx zuplo deploy --api-key "$ZUPLO_API_KEY" 2>&1 | tee ./DEPLOYMENT_STDOUT - echo "DEPLOYMENT_URL=$(grep -oP 'Deployed to \K(https://[^ ]+)' ./DEPLOYMENT_STDOUT)" >> deploy.env artifacts: reports: dotenv: deploy.env test: stage: test needs: - deploy script: - npm install - npx zuplo test --endpoint "$DEPLOYMENT_URL" cleanup: stage: cleanup needs: - test script: - npm install - npx zuplo delete --url "$DEPLOYMENT_URL" --api-key "$ZUPLO_API_KEY" --wait rules: - if: $CI_PIPELINE_SOURCE == "merge_request_event"

The cleanup job only runs for merge request pipelines, deleting the preview environment after tests pass.

Next Steps

Last modified on