Overview

Add Continuous Testing tests to your Jenkins environment.

Datadog recommends discussing with your SRE and Infrastructure teams to determine a solution that models your existing Jenkins architecture and customizes an installation that fits your business requirements.

Setup

To use Docker in your Jenkins environment, see Using Docker with Pipeline.

Prerequisites

  • Node.js v10.24.1+
  • A global JSON configuration file uploaded to your Jenkins instance through the Config File Provider. You need this file to define the global properties for your Synthetics test setup.

You can store environment variables directly within the global configuration file or use credentials. For more information about test configurations, see Configure tests.

Run the @datadog/datadog-ci package

Install and run the Node.js and npm packages within your Jenkins environment with the Jenkins Node.js plugin.

For more information about the existing Datadog-Jenkins integration, see Set up Tracing on a Jenkins Pipeline.

Add a Node.js installation

Navigate to the global Jenkins Configuration panel and add a Node.js installation.

Node.js Installations in Jenkins

Install @datadog/datadog-ci globally for all relevant Node.js installations.

Tags

To run Continuous Testing tests with tags in a Jenkins Declarative pipeline:

pipeline {
   agent any
   stages {
       stage('Run e2e tests') {
           steps {
               withCredentials([string(credentialsId: 'datadog-api-key', variable: 'DATADOG_API_KEY'), string(credentialsId: 'datadog-app-key', variable: 'DATADOG_APP_KEY')]) {
                   nodejs(nodeJSInstallationName: 'Node 10.24.x') {
                       configFileProvider(
                           [configFile(fileId: 'config-file-id', variable: 'DATADOG_CI_CONFIG')]) {
                           sh 'datadog-ci synthetics run-tests -s "tag:e2e" --config $DATADOG_CI_CONFIG'
                       }
                   }
               }
           }
       }
   }

Custom test file

To run Continuous Testing tests with a custom test file in a Jenkins Declarative pipeline:

pipeline {
   agent any
   stages {
       stage('Run e2e tests') {
           steps {
               withCredentials([string(credentialsId: 'datadog-api-key', variable: 'DATADOG_API_KEY'), string(credentialsId: 'datadog-app-key', variable: 'DATADOG_APP_KEY')]) {
                   nodejs(nodeJSInstallationName: 'Node 10.24.x') {
                       configFileProvider(
                           [configFile(fileId: 'config-file-id', variable: 'DATADOG_CI_CONFIG'), configFile(fileId: 'test-file-id', variable: 'DATADOG_CI_TEST_FILE')]) {
                           sh 'datadog-ci synthetics run-tests -f $DATADOG_CI_TEST_FILE --config $DATADOG_CI_CONFIG'
                       }
                   }
               }
           }
       }
   }
}

You can expect the following output:

Example Test Run in Jenkins

Further reading