For the complete documentation index, see llms.txt. This page is also available as Markdown.

Triggering explorations from any CI

Call the Antidote Platform API directly from CircleCI, GitLab CI, Jenkins, Buildkite or any other pipeline.

Antidote's GitHub Actions are thin wrappers around our Platform API. If your pipelines run somewhere else, CircleCI, Jenkins, GitLab CI, or Buildkite, you can make the same API calls directly with curl. This page walks through the complete flow, with CircleCI as the worked example.

Using GitHub Actions? Use the Antidote preview or environment actions instead. They implement everything on this page for you.

What you will set up:

  • Exchange your Antidote API key for a short-lived access token.

  • Preview flow. Register a per-PR build and start an exploration against its preview deployment.

  • Environment flow. Start an exploration and test-case run against a long-lived environment target.

  • Get results posted back to your GitHub pull requests via the Antidote GitHub App.

  • Optionally, block your pipeline until the exploration finishes.

Status. This API surface is the same one our published actions use. Like the actions, it is pre-release. Operation and field names are stable in practice but may evolve before 1.0.

Endpoints

What
URL

Token endpoint

https://auth.duku.ai/realms/duku/protocol/openid-connect/token

Platform API (GraphQL)

https://platform.duku.ai/graphql

All Platform API operations are GraphQL: POST a JSON body of the form {"query": "...", "variables": {...}} with an Authorization: Bearer <token> header.

Prerequisites

  • An Antidote API key. Generate one in Viewport → Settings → API Keys. The key is shown once. Store it as a secret in your CI. In CircleCI, put it in a context as DUKU_API_KEY.

  • Preview flow: your product ID (Viewport → Products).

  • Environment flow: a pre-created environment target ID (created in Viewport).

  • The product needs a base URL. Without one, and without a per-run url, startExploration returns BAD_USER_INPUT.

  • curl and jq in your job image. CircleCI's cimg/base image includes both.

  • For PR comments: the Antidote GitHub App installed on your repository (next section).

Tip. You can list your products over the API with query { subjects { id name } }. Products are called "subjects" in the API schema.

Install the Antidote GitHub App

For compatibility, GitHub lists the Antidote GitHub App as Duku AI GitHub App.

When you pass a repository, a pull-request number and serverManagedComment: true with an exploration, Antidote posts a sticky comment on that PR. It first posts "exploration in progress", then updates it with results. Without serverManagedComment: true, only the results comment is posted. Those comments are posted by the Antidote GitHub App, so you never need to handle a GitHub token in your CI job.

  1. Click Install (or Configure if your organisation already has it) and choose the GitHub organisation that owns your repositories. If you are not an organisation owner, GitHub forwards the request to one for approval.

  2. Choose Only select repositories and pick repositories whose pull requests should receive Antidote comments. You can also choose All repositories.

  3. Accept the requested permissions. Pull-request comments and check runs need read and write access.

  4. Link the installation to your Antidote organisation: an org admin opens Settings → Integrations, selects + Connect under Source control & CI/CD, chooses GitHub, then selects Link existing install. Install on GitHub completes steps 1 to 5. Until the installation is linked, Antidote posts no PR comments or check runs to its repositories.

If the App is not installed and linked, explorations still run normally. You will not get PR comments or check runs. Results remain available in Viewport.

Step 1 - Exchange your API key for an access token

See API Keys for how keys work and how to exchange one for an access token. In short: the key is a base64-encoded clientId:clientSecret pair; decode it, split on the first :, and use the standard OAuth2 client-credentials grant to get a short-lived access token.

Save the following helpers to scripts/duku-lib.sh in your repository. The rest of this page builds on them:

Important. Access tokens are short-lived (about 5 minutes). Don't fetch one token at the top of a long job and reuse it - duku_gql above fetches a fresh token per call, which is the simplest safe pattern.

Important. Most GraphQL errors come back with HTTP status 200, so a bare curl -f will not catch them. Always check the response for an errors array, as duku_gql does. A variable with the wrong type or enum value returns HTTP 400 instead.

A word on hygiene: treat the API key and access tokens as secrets. Avoid set -x in steps that call these helpers. Never echo the token.

Avoid sending passwords in the request body. Instead of passing raw login credentials inline, create a credential set once in Viewport and pass its ID or name as credentialSetId on startExploration or runAllTestCases. Antidote decrypts it server-side, so the secret never travels through your CI logs or the GraphQL request.

Adapting the scripts to your CI

The helper scripts on this page use CircleCI environment variable names (CIRCLE_*) as examples. If you run a different CI, substitute your provider's equivalents. The GraphQL calls and each script stay exactly the same.

What it is
CircleCI (used in the scripts)
GitHub Actions
GitLab CI
Jenkins
Buildkite
Bitbucket

Repository (owner/repo)

$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME

$GITHUB_REPOSITORY

$CI_PROJECT_PATH

derive from $GIT_URL, or set manually

$BUILDKITE_ORGANIZATION_SLUG/$BUILDKITE_PIPELINE_SLUG

$BITBUCKET_REPO_FULL_NAME

Pull / merge request number

parsed from $CIRCLE_PULL_REQUEST (or $CIRCLE_PR_NUMBER)

github.event.pull_request.number

$CI_MERGE_REQUEST_IID

$CHANGE_ID

$BUILDKITE_PULL_REQUEST

$BITBUCKET_PR_ID

Commit SHA

$CIRCLE_SHA1

$GITHUB_SHA

$CI_COMMIT_SHA

$GIT_COMMIT

$BUILDKITE_COMMIT

$BITBUCKET_COMMIT

Branch name

$CIRCLE_BRANCH

$GITHUB_HEAD_REF (PRs) / $GITHUB_REF_NAME

$CI_COMMIT_REF_NAME

$BRANCH_NAME

$BUILDKITE_BRANCH

$BITBUCKET_BRANCH

Build number

$CIRCLE_BUILD_NUM

$GITHUB_RUN_NUMBER

$CI_PIPELINE_IID

$BUILD_NUMBER

$BUILDKITE_BUILD_NUMBER

$BITBUCKET_BUILD_NUMBER

Build / job URL

$CIRCLE_BUILD_URL

$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID

$CI_JOB_URL

$BUILD_URL

$BUILDKITE_BUILD_URL

construct from $BITBUCKET_GIT_HTTP_ORIGIN

Flow A - preview deployments

Before the first run, an org admin adds Preview deployments in Product settings → Environments (Add environment, Type: Preview deployments). Until it exists, registering a preview build fails with FORBIDDEN.

Run two API calls per pipeline after your preview deploy step:

  1. upsertSimulationTarget registers the build as a target under your product. The buildKey deduplicates reruns. Every pipeline on the same PR updates the same target instead of creating a new one. If you also send commitSha, give each commit its own buildKey by appending :sha=<commit sha>. Otherwise, the second commit returns CONFLICT.

  2. startExploration starts the exploration against the preview URL. Passing githubRepository, githubPrNumber, and serverManagedComment: true makes Antidote post and maintain the PR comment for you.

Unlike the GitHub Action - which discovers the preview URL from the GitHub Deployments, Checks, and Statuses APIs - your CI job supplies the preview URL directly. Your deploy step already knows it: vercel deploy prints it, netlify deploy --json returns it as deploy_url, or you may construct it from the PR number.

Add waitForTargetSeconds (for example 300) if the preview may not be serving yet when this step runs. The exploration starts once the URL responds.

The exploration runs asynchronously - the script exits in seconds and results appear in Viewport and on the PR comment when the run finishes (typically 5 to 40 minutes).

If one pull request triggers explorations for several products, each product gets its own PR comment.

Vercel Deployment Protection. If your previews are protected, pass the bypass secret when registering the build. Add --arg bypass "$VERCEL_AUTOMATION_BYPASS_SECRET" to the first jq call and metadata: {vercelAutomationBypassSecret: $bypass} to its input object.

Not on a PR? For pushes without a pull request, use buildKey: "github:repo=${REPO}:sha=${CIRCLE_SHA1}" and omit githubRepository, githubPrNumber, and serverManagedComment - there is no PR to comment on. Keep triggerSource: "CI" so the preview url is still honoured.

Keep the github:repo=... buildKey convention shown above even though you're not on GitHub Actions. If you also send commitSha, use github:repo=<owner/repo>:pr=<number>:sha=<commit sha> - the same key the Duku GitHub Actions use - so if you ever run both, they land on the same release.

For the full list of input fields on upsertSimulationTarget and startExploration, see the GraphQL API reference.

Flow B - environment deployments

For a staging environment, prod canary, or any pre-created environment target: skip target registration and start the run directly, then trigger the target's test cases.

triggerSource: "CI" is optional here - Flow B runs against the product's base URL, so there is no override to authorise. It is still worth sending so the run is labelled as CI-triggered in your dashboards.

  • PR-gate mode: to run this against a fixed environment as a pull-request check and get the PR comment, add githubRepository, githubPrNumber, and serverManagedComment: true to the startExploration input, exactly as in the preview flow.

  • runAllTestCases plans the test runs synchronously and can take up to ~90 seconds to respond; the runs themselves then execute asynchronously.

Record a release after each deploy

When Releases are enabled for your organisation, add one call after each deploy step. recordManualRelease records the version as deployed to the environment and starts exploring it. Sending the same version for the same environment again records one release, but each call starts a new exploration - so a retried job explores again.

Find each environment's ID once:

Then, after the deploy:

Set VERSION to the name you release under, such as your git tag. To explore an environment without recording a new release, call startExploration with environmentId in place of targetId.

Gate your pipeline on the result

Both flows are async by design: they kick off the run and exit, and results arrive in Viewport and the PR comment.

See the result on the pull request. When you start the exploration with serverManagedComment: true and PR context - as Flow A does, and Flow B in PR-gate mode - Duku posts a GitHub check run with the result on the pull request. The check does not fail on issues, so to make a pipeline stop on the result, poll as below. See GitHub check runs.

To make the CI job itself pass or fail with the exploration - for a non-GitHub CI, or a step-level gate - poll the batch status instead. Add to scripts/duku-lib.sh:

Usage after either flow script:

  • Batch status is returned in upper case (PENDING, RUNNING, COMPLETED, FAILED). PENDING and RUNNING are in flight; COMPLETED and FAILED are terminal. Treat any other value as still in flight.

  • Explorations typically take 5 to 40 minutes - set the step timeout accordingly (the loop prints a line every 30 seconds, so CircleCI's no-output timeout won't trip).

  • Polling keeps a CircleCI executor occupied for the whole run. If you only need the results, skip the gate and let the PR comment and check run deliver them.

Putting it together in CircleCI

Store DUKU_API_KEY (and DUKU_PRODUCT_ID or DUKU_TARGET_ID) in a context named duku under Organization Settings → Contexts, then:

Note. CircleCI only populates CIRCLE_PULL_REQUEST / CIRCLE_PR_NUMBER when the pipeline is associated with a pull request. If those are empty on your PR pipelines, check Project Settings → Advanced → Only build pull requests, or pass the PR number into the script yourself.

Troubleshooting

CONFLICT - already pinned to deployment

You re-sent a buildKey with a different commitSha. Put the commit in the build key.

FORBIDDEN with reason VERSION_AXIS_NOT_ENABLED

Releases are switched on per organisation. Remove commitSha, label, lineage, parentCommitSha and environmentId from the upsert, or contact Duku to enable Releases.

FORBIDDEN - Add Preview deployments

Your product has no Preview deployments slot. An org admin adds it in Product settings → Environments.

Token request fails with HTTP 401 (invalid_client). The API key is malformed, revoked, or expired. Check that the secret contains the full base64 string from Viewport with no line breaks, or generate a new key in Viewport → Settings → API Keys.

Authentication required in a GraphQL error. The access token expired mid-job - tokens last about 5 minutes. Fetch a fresh token per call (the duku_gql helper does this) rather than reusing one.

url is required. The product has no base URL and the run sent no url. Set the product's base URL in Viewport, or pass url with triggerSource: "CI".

Not found when referencing a target or product. The ID is wrong, or it belongs to a different organisation - API keys only see resources in the organisation they were created in.

The preview url is ignored / the run uses the wrong URL. For an API-key caller, the per-run url is only honoured when you send triggerSource: "CI". Without it the run falls back to the product's configured base URL. Add triggerSource: "CI" to the startExploration input, as shown in Flow A.

The PR comment never appears. Verify the Duku AI GitHub App is installed on the repository and linked in Settings → Integrations, that githubRepository is exactly owner/repo, and that githubPrNumber is an integer. The results comment posts only when the run finishes - check its status in Viewport if you're unsure whether it's still running.

Duku's agents can't reach your preview. If your site sits behind a firewall, WAF, or bot protection, see Firewall & WAF Allowlisting. For protected Vercel previews, use the Deployment Protection bypass described above.

Need help? If anything on this page doesn't work for your setup, or you're integrating a CI provider with quirks we haven't covered, contact your Duku account team.

Last updated