Jenkins E2E tests

Run Monito browser tests from a Jenkins pipeline with an API key and your deployed URL. Untested Jenkinsfile example, credentials and limits.

CI/CD · Checked 2026-11-20

Add a stage after your deploy stage and wait for Monito's browser verdict. The Monito CLI path works today; our team has not run this Jenkinsfile in Jenkins.

How it works

  1. Your deploy stage finishes and writes the deployed URL to a file in the workspace of that Pipeline run.
  2. A later stage with Node.js available reads that file, authenticates with MONITO_TOKEN bound from a Jenkins credential, and runs the project's saved tests against that URL with --base-url.
  3. The CLI waits and exits nonzero for failed or errored tests, failing the stage. Inspect browser evidence in Monito's run report.

Set it up

Pro or Team to create the API key used as MONITO_TOKEN. Browser runs use your credits. Plan details

  1. Create a Monito API key on Pro or Team. Store it in Jenkins as a Secret text credential with ID monito-token. Bind it with withCredentials([string(credentialsId: 'monito-token', variable: 'MONITO_TOKEN')]) or with environment { MONITO_TOKEN = credentials('monito-token') }. Set MONITO_PROJECT_ID to your project ID as a plain environment value.
  2. The agent needs Node.js and npx. The example uses a docker agent, which needs the Docker Pipeline plugin on a node that can run Docker-based Pipelines. On 2026-11-20 the official Docker Hub library/node tag node:24 existed, and node:24, node:24.22, and node:24.22.3 shared one index digest. The NodeJS plugin can install Node.js on an agent and expose it with the nodejs step. Our team has not run either setup in Jenkins.
  3. Have the deploy stage write the deployed URL to deploy-url.txt before the Monito stage, in the same Declarative Pipeline and on the same agent. Keep the token out of that file.
  4. If a failed build should block a merge, that depends on the Git host. GitHub Branch Source sends commit status updates for builds, and a multibranch trait can disable those notifications. This Jenkinsfile does not post a pull request comment, and it does not publish a Monito status.
Jenkinsfile · groovy
pipeline {
  agent {
    docker { image 'node:24' }
  }
  environment {
    MONITO_TOKEN = credentials('monito-token')
    MONITO_PROJECT_ID = 'project_123'
  }
  stages {
    stage('Record the deployed URL') {
      steps {
        sh 'echo "$URL" > deploy-url.txt'
      }
    }
    stage('Run saved browser tests') {
      steps {
        sh '''
          DEPLOY_URL="$(cat deploy-url.txt)"
          test -n "$DEPLOY_URL" || { echo "DEPLOY_URL is empty"; exit 1; }
          npx -y @monitodev/cli@4 project run "$MONITO_PROJECT_ID" --wait --base-url "$DEPLOY_URL"
        '''
      }
    }
  }
}

Example our team has not run in Jenkins. The first stage stands in for your deployment and only writes the URL. Replace the echo with the URL your deploy command prints. The guard fails the stage if the URL is empty so the CLI cannot silently test the project's default environment. The test stage uses a single-quoted sh step so Groovy does not interpolate MONITO_TOKEN. The image is the official Docker Hub library/node tag node:24. On 2026-11-20 that tag, node:24.22, and node:24.22.3 shared one index digest.

Using GitLab CI instead?

Using GitLab CI instead? The same CLI command runs after a review deploy when the URL arrives through a dotenv artifact. Our team has not run that YAML in GitLab.

Using CircleCI instead?

Using CircleCI instead? Add a job that reads the deployed URL from a workspace and runs the same CLI command. Our team has not run that config in CircleCI.

Using Bitbucket Pipelines instead?

Using Bitbucket Pipelines instead? Add a step that reads the deployed URL from an artifact and runs the same CLI command. Our team has not run that config in Bitbucket Pipelines.

Jenkins sources

The Jenkins behavior on this page was checked against the following documentation on 2026-11-20. node:24 was an official Docker Hub library/node tag that day, and node:24.22 and node:24.22.3 shared its index digest. The benchmark reports below do not validate this Jenkinsfile. Our team has not run it in Jenkins.

Example result

Example result: field names from the CLI, values illustrative

Selected fields from project run --wait --json. Each runs entry has its own id, status and sessionId. Add --json to read the full result. Open /session/<sessionId> on Monito, or follow the run report from the dashboard or GitHub summary to inspect browser evidence.

Illustrative result · JSON
{
  "runs": [
    {
      "id": "run_example",
      "scenarioId": "scenario_example",
      "status": "failed",
      "sessionId": "session_example"
    }
  ]
}

Limits to account for

Bound secrets are replaced with **** in the build log when they are printed. The credentials-binding step says that masking can be circumvented, and that anyone permitted to configure the job or define Pipeline steps is trusted to use credentials in scope. The Jenkinsfile guide says displaying a credential variable returns ****, which only reduces accidental exposure. Code running in the build can still read the value. A string binding is an environment variable, and the step warns that another build on the same node can read it, for example with ps e on Linux. Mangled secrets are masked on a best-effort basis for Bourne shell, Bash, Almquist shell, and Windows batch.

A double-quoted sh step is a Groovy GString. Groovy expands a bound secret before the command reaches the agent, and the credentials-binding guide says that can disclose it in a process listing. Use a single-quoted sh step, as this Jenkinsfile does, so the shell expands MONITO_TOKEN from the environment.

Discover pull requests from forks has a Trust policy that chooses which Jenkinsfile runs. Nobody treats every fork pull request as untrusted, so Jenkins loads a trusted file such as the Jenkinsfile from the target branch on the origin repository, not from the pull request branch on the fork. Collaborators trusts pull requests from collaborators and treats other fork pull requests as untrusted. If the scan credential cannot list collaborators, that policy falls back to Nobody. The help text says every collaborator is trusted, including a team member with only read permission. Everyone treats every fork pull request as trusted, and the help text says that option can be dangerous on a public GitHub repository. From users with Admin or Write permission is the recommended policy: a fork is trusted only when its owner has Admin or Write on the origin repository. On GitHub Enterprise Server before 2.12 that policy is the same as Nobody. Trust does not, by itself, stop a fork from changing other files. The securing multibranch guide says that if the Jenkinsfile binds a credential around an sh step that runs tests from the repository, a fork pull request can change those tests and read the credential without editing the Jenkinsfile.

stash saves files for later use on any node or workspace in the same Pipeline run, and unstash restores them into the current workspace. The multiple-agents example stashes files on one agent and unstashes them on another. A top-level docker agent runs every stage in the same container deployment unless newContainerPerStage is set. A stage with its own docker agent gets a new workspace unless reuseNode is true, which mounts the current workspace from the top-level agent on the same node. This example writes deploy-url.txt and reads it on the pipeline docker agent, so it does not stash the file. A Monito stage on another agent needs stash and unstash.

A base-URL override preserves scenario paths and saved-login origin restrictions. It does not authorize credentials on a new preview origin.

Comparable benchmark runs

Our team published these runs in the reliability benchmark. They show comparable browser journeys, not executions of the configuration or illustrative result above. Run your own scenario before relying on this integration.

Benchmark method and limits

Questions

Is there a Monito Jenkins plugin?

No. Monito does not publish a Jenkins plugin. This page runs the Monito CLI with npx from a pipeline stage.

Does this work with freestyle jobs?

An Execute shell build step can run the same command. Our team has not run that step. The example on this page is a Declarative Pipeline.

Which plan do I need?

Pro or Team. Creating the API key used as MONITO_TOKEN requires Pro ($79/mo) or Team ($199/mo). Browser runs use credits.

Can it test preview deployments?

Yes. Pass the deployed URL with --base-url. The override preserves scenario paths and saved-login origin restrictions. It does not authorize credentials on a new preview origin.

Read the full guide