This page is not yet available in Spanish. We are working on its translation. If you have any questions or feedback about our current translation project, feel free to reach out to us!
CI Visibility is not available in the selected site () at this time.
Overview
Jenkins is an automation server with continuous integration and delivery features. With its plugin architecture, Jenkins can be customized to fit any CI/CD need and automates all aspects of project development, testing, and deployment.
Set up tracing in Jenkins to collect data across various stages of your pipeline executions, identify performance bottlenecks, resolve operational challenges, and refine your deployment processes.
Identify pipeline failure reasons from error messages.
The following Jenkins versions are supported:
Jenkins >= 2.346.1
This integration supports both Agentless and Agent-based installation.
Installing the Agent is required for infrastructure metrics correlation.
Install the Datadog Agent
Skip this step if you do not need infrastructure metrics correlation.
Install Datadog Agent on your Jenkins controller node and on your worker nodes by following the Agent installation instructions.
If the Jenkins controller and the Datadog Agent have been deployed to a Kubernetes cluster, Datadog recommends using the Admission Controller, which automatically sets the DD_AGENT_HOST environment variable in the Jenkins controller pod to communicate with the local Datadog Agent.
If you want to report the logs of your Jenkins jobs to Datadog, make sure that custom log collection over TCP is enabled and configured in the Agent.
If your Agent runs in a container, add the DD_DOGSTATSD_NON_LOCAL_TRAFFIC=true environment variable to it and make sure the following ports are accessible by the Jenkins controller:
Create or modify the configuration YAML by adding an entry for datadogGlobalConfiguration:
unclassified:datadogGlobalConfiguration:# Select the `Agentless` mode (HTTP).reportWith:"HTTP"# Update the endpoints if reporting to Datadog sites other that `datadoghq.com`targetApiURL:"https://api.datadoghq.com/api/"targetLogIntakeURL:"https://http-intake.logs.datadoghq.com/v1/input/"targetWebhookIntakeURL:"https://webhook-intake.datadoghq.com/api/v2/webhook/"# Configure your API keytargetCredentialsApiKey:"<your-api-key>"# (Optional) Configure your CI Instance nameciInstanceName:"jenkins"
unclassified:datadogGlobalConfiguration:# Select the `Agentless` mode (HTTP).reportWith:"HTTP"# Update the endpoints if reporting to Datadog sites other that `datadoghq.com`targetApiURL:"https://api.datadoghq.eu/api/"targetLogIntakeURL:"https://http-intake.logs.datadoghq.eu/v1/input/"targetWebhookIntakeURL:"https://webhook-intake.datadoghq.eu/api/v2/webhook/"# Configure your API keytargetCredentialsApiKey:"<your-api-key>"# (Optional) Configure your CI Instance nameciInstanceName:"jenkins"
unclassified:datadogGlobalConfiguration:# Select the `Agentless` mode (HTTP).reportWith:"HTTP"# Update the endpoints if reporting to Datadog sites other that `datadoghq.com`targetApiURL:"https://api.dd-gov.com/api/"targetLogIntakeURL:"https://http-intake.logs.dd-gov.com/v1/input/"targetWebhookIntakeURL:"https://webhook-intake.dd-gov.com/api/v2/webhook/"# Configure your API keytargetCredentialsApiKey:"<your-api-key>"# (Optional) Configure your CI Instance nameciInstanceName:"jenkins"
unclassified:datadogGlobalConfiguration:# Select the `Agentless` mode (HTTP).reportWith:"HTTP"# Update the endpoints if reporting to Datadog sites other that `datadoghq.com`targetApiURL:"https://api.us3.datadoghq.com/api/"targetLogIntakeURL:"https://http-intake.logs.us3.datadoghq.com/v1/input/"targetWebhookIntakeURL:"https://webhook-intake.us3.datadoghq.com/api/v2/webhook/"# Configure your API keytargetCredentialsApiKey:"<your-api-key>"# (Optional) Configure your CI Instance nameciInstanceName:"jenkins"
unclassified:datadogGlobalConfiguration:# Select the `Agentless` mode (HTTP).reportWith:"HTTP"# Update the endpoints if reporting to Datadog sites other that `datadoghq.com`targetApiURL:"https://api.us5.datadoghq.com/api/"targetLogIntakeURL:"https://http-intake.logs.us5.datadoghq.com/v1/input/"targetWebhookIntakeURL:"https://webhook-intake.us5.datadoghq.com/api/v2/webhook/"# Configure your API keytargetCredentialsApiKey:"<your-api-key>"# (Optional) Configure your CI Instance nameciInstanceName:"jenkins"
unclassified:datadogGlobalConfiguration:# Select the `Agentless` mode (HTTP).reportWith:"HTTP"# Update the endpoints if reporting to Datadog sites other that `datadoghq.com`targetApiURL:"https://api.ap1.datadoghq.com/api/"targetLogIntakeURL:"https://http-intake.logs.ap1.datadoghq.com/v1/input/"targetWebhookIntakeURL:"https://webhook-intake.ap1.datadoghq.com/api/v2/webhook/"# Configure your API keytargetCredentialsApiKey:"<your-api-key>"# (Optional) Configure your CI Instance nameciInstanceName:"jenkins"
In your Jenkins instance web interface, go to Manage Jenkins > Configuration as Code.
Apply or reload the configuration.
Check the configuration using the View Configuration button.
Create or modify the configuration YAML by adding an entry for datadogGlobalConfiguration:
unclassified:datadogGlobalConfiguration:# Select the `Datadog Agent` mode (DSD).reportWith:"DSD"# Configure the `Agent` hosttargetHost:"<your-agent-host>"# Configure the `Traces Collection` porttargetTraceCollectionPort:8126# Enable CI Visibility flagenableCiVisibility:true# (Optional) Configure your CI Instance nameciInstanceName:"jenkins"
In your Jenkins instance web interface, go to Manage Jenkins > Configuration as Code.
Apply or reload the configuration.
Check the configuration using the View Configuration button.
Configure with Groovy
In your Jenkins instance web interface, go to Manage Jenkins > Script Console.
Run the configuration script:
importjenkins.model.*importorg.datadog.jenkins.plugins.datadog.DatadogGlobalConfigurationdefj=Jenkins.getInstance()defd=j.getDescriptor("org.datadog.jenkins.plugins.datadog.DatadogGlobalConfiguration")// Select the Datadog Agent mode
d.setReportWith('HTTP')// Endpoint URLs correspond to your Datadog site
d.setTargetApiURL("https://api.datadoghq.com/api/")d.setTargetLogIntakeURL("https://http-intake.logs.datadoghq.com/v1/input/")d.setTargetWebhookIntakeURL("https://webhook-intake.datadoghq.com/api/v2/webhook/")// Configure your API key
d.setTargetApiKey("your-api-key")// Enable CI Visibility
d.setEnableCiVisibility(true)// (Optional) Configure your CI Instance name
d.setCiInstanceName("jenkins")// Save config
d.save()
importjenkins.model.*importorg.datadog.jenkins.plugins.datadog.DatadogGlobalConfigurationdefj=Jenkins.getInstance()defd=j.getDescriptor("org.datadog.jenkins.plugins.datadog.DatadogGlobalConfiguration")// Select the Datadog Agent mode
d.setReportWith('HTTP')// Endpoint URLs correspond to your Datadog site
d.setTargetApiURL("https://api.ap1.datadoghq.eu/api/")d.setTargetLogIntakeURL("https://http-intake.logs.ap1.datadoghq.eu/v1/input/")d.setTargetWebhookIntakeURL("https://webhook-intake.ap1.datadoghq.eu/api/v2/webhook/")// Configure your API key
d.setTargetApiKey("your-api-key")// Enable CI Visibility
d.setEnableCiVisibility(true)// (Optional) Configure your CI Instance name
d.setCiInstanceName("jenkins")// Save config
d.save()
importjenkins.model.*importorg.datadog.jenkins.plugins.datadog.DatadogGlobalConfigurationdefj=Jenkins.getInstance()defd=j.getDescriptor("org.datadog.jenkins.plugins.datadog.DatadogGlobalConfiguration")// Select the Datadog Agent mode
d.setReportWith('HTTP')// Endpoint URLs correspond to your Datadog site
d.setTargetApiURL("https://api.dd-gov.com/api/")d.setTargetLogIntakeURL("https://http-intake.logs.dd-gov.com/v1/input/")d.setTargetWebhookIntakeURL("https://webhook-intake.dd-gov.com/api/v2/webhook/")// Configure your API key
d.setTargetApiKey("your-api-key")// Enable CI Visibility
d.setEnableCiVisibility(true)// (Optional) Configure your CI Instance name
d.setCiInstanceName("jenkins")// Save config
d.save()
importjenkins.model.*importorg.datadog.jenkins.plugins.datadog.DatadogGlobalConfigurationdefj=Jenkins.getInstance()defd=j.getDescriptor("org.datadog.jenkins.plugins.datadog.DatadogGlobalConfiguration")// Select the Datadog Agent mode
d.setReportWith('HTTP')// Endpoint URLs correspond to your Datadog site
d.setTargetApiURL("https://api.us3.datadoghq.com/api/")d.setTargetLogIntakeURL("https://http-intake.logs.us3.datadoghq.com/v1/input/")d.setTargetWebhookIntakeURL("https://webhook-intake.us3.datadoghq.com/api/v2/webhook/")// Configure your API key
d.setTargetApiKey("your-api-key")// Enable CI Visibility
d.setEnableCiVisibility(true)// (Optional) Configure your CI Instance name
d.setCiInstanceName("jenkins")// Save config
d.save()
importjenkins.model.*importorg.datadog.jenkins.plugins.datadog.DatadogGlobalConfigurationdefj=Jenkins.getInstance()defd=j.getDescriptor("org.datadog.jenkins.plugins.datadog.DatadogGlobalConfiguration")// Select the Datadog Agent mode
d.setReportWith('HTTP')// Endpoint URLs correspond to your Datadog site
d.setTargetApiURL("https://api.us5.datadoghq.com/api/")d.setTargetLogIntakeURL("https://http-intake.logs.us5.datadoghq.com/v1/input/")d.setTargetWebhookIntakeURL("https://webhook-intake.us5.datadoghq.com/api/v2/webhook/")// Configure your API key
d.setTargetApiKey("your-api-key")// Enable CI Visibility
d.setEnableCiVisibility(true)// (Optional) Configure your CI Instance name
d.setCiInstanceName("jenkins")// Save config
d.save()
importjenkins.model.*importorg.datadog.jenkins.plugins.datadog.DatadogGlobalConfigurationdefj=Jenkins.getInstance()defd=j.getDescriptor("org.datadog.jenkins.plugins.datadog.DatadogGlobalConfiguration")// Select the Datadog Agent mode
d.setReportWith('HTTP')// Endpoint URLs correspond to your Datadog site
d.setTargetApiURL("https://api.ap1.datadoghq.com/api/")d.setTargetLogIntakeURL("https://http-intake.logs.ap1.datadoghq.com/v1/input/")d.setTargetWebhookIntakeURL("https://webhook-intake.ap1.datadoghq.com/api/v2/webhook/")// Configure your API key
d.setTargetApiKey("your-api-key")// Enable CI Visibility
d.setEnableCiVisibility(true)// (Optional) Configure your CI Instance name
d.setCiInstanceName("jenkins")// Save config
d.save()
In your Jenkins instance web interface, go to Manage Jenkins > Script Console.
Run the configuration script:
importjenkins.model.*importorg.datadog.jenkins.plugins.datadog.DatadogGlobalConfigurationdefj=Jenkins.getInstance()defd=j.getDescriptor("org.datadog.jenkins.plugins.datadog.DatadogGlobalConfiguration")// Select the Datadog Agent mode
d.setReportWith('DSD')// Configure the Agent host.
d.setTargetHost('<your-agent-host>')// Configure the Traces Collection port (default 8126)
d.setTargetTraceCollectionPort(8126)// Enable CI Visibility
d.setEnableCiVisibility(true)// (Optional) Configure your CI Instance name
d.setCiInstanceName("jenkins")// Save config
d.save()
Use environment variables
Set the following environment variables on your Jenkins instance machine:
# Select the Datadog Agent modeDATADOG_JENKINS_PLUGIN_REPORT_WITH=HTTP
# Endpoint URLs correspond to your Datadog siteDATADOG_JENKINS_PLUGIN_TARGET_API_URL="https://api.datadoghq.com/api/"DATADOG_JENKINS_PLUGIN_TARGET_LOG_INTAKE_URL="https://http-intake.logs.datadoghq.com/v1/input/"DATADOG_JENKINS_TARGET_WEBHOOK_INTAKE_URL="https://webhook-intake.datadoghq.com/api/v2/webhook/"# Configure your API keyDATADOG_JENKINS_PLUGIN_TARGET_API_KEY=your-api-key
# Enable CI VisibilityDATADOG_JENKINS_PLUGIN_ENABLE_CI_VISIBILITY=true# (Optional) Configure your CI Instance nameDATADOG_JENKINS_PLUGIN_CI_VISIBILITY_CI_INSTANCE_NAME=jenkins
# Select the Datadog Agent modeDATADOG_JENKINS_PLUGIN_REPORT_WITH=HTTP
# Endpoint URLs correspond to your Datadog siteDATADOG_JENKINS_PLUGIN_TARGET_API_URL="https://api.datadoghq.eu/api/"DATADOG_JENKINS_PLUGIN_TARGET_LOG_INTAKE_URL="https://http-intake.logs.datadoghq.eu/v1/input/"DATADOG_JENKINS_TARGET_WEBHOOK_INTAKE_URL="https://webhook-intake.datadoghq.eu/api/v2/webhook/"# Configure your API keyDATADOG_JENKINS_PLUGIN_TARGET_API_KEY=your-api-key
# Enable CI VisibilityDATADOG_JENKINS_PLUGIN_ENABLE_CI_VISIBILITY=true# (Optional) Configure your CI Instance nameDATADOG_JENKINS_PLUGIN_CI_VISIBILITY_CI_INSTANCE_NAME=jenkins
# Select the Datadog Agent modeDATADOG_JENKINS_PLUGIN_REPORT_WITH=HTTP
# Endpoint URLs correspond to your Datadog siteDATADOG_JENKINS_PLUGIN_TARGET_API_URL="https://api.dd-gov.com/api/"DATADOG_JENKINS_PLUGIN_TARGET_LOG_INTAKE_URL="https://http-intake.logs.dd-gov.com/v1/input/"DATADOG_JENKINS_TARGET_WEBHOOK_INTAKE_URL="https://webhook-intake.dd-gov.com/api/v2/webhook/"# Configure your API keyDATADOG_JENKINS_PLUGIN_TARGET_API_KEY=your-api-key
# Enable CI VisibilityDATADOG_JENKINS_PLUGIN_ENABLE_CI_VISIBILITY=true# (Optional) Configure your CI Instance nameDATADOG_JENKINS_PLUGIN_CI_VISIBILITY_CI_INSTANCE_NAME=jenkins
# Select the Datadog Agent modeDATADOG_JENKINS_PLUGIN_REPORT_WITH=HTTP
# Endpoint URLs correspond to your Datadog siteDATADOG_JENKINS_PLUGIN_TARGET_API_URL="https://api.us3.datadoghq.com/api/"DATADOG_JENKINS_PLUGIN_TARGET_LOG_INTAKE_URL="https://http-intake.logs.us3.datadoghq.com/v1/input/"DATADOG_JENKINS_TARGET_WEBHOOK_INTAKE_URL="https://webhook-intake.us3.datadoghq.com/api/v2/webhook/"# Configure your API keyDATADOG_JENKINS_PLUGIN_TARGET_API_KEY=your-api-key
# Enable CI VisibilityDATADOG_JENKINS_PLUGIN_ENABLE_CI_VISIBILITY=true# (Optional) Configure your CI Instance nameDATADOG_JENKINS_PLUGIN_CI_VISIBILITY_CI_INSTANCE_NAME=jenkins
# Select the Datadog Agent modeDATADOG_JENKINS_PLUGIN_REPORT_WITH=HTTP
# Endpoint URLs correspond to your Datadog siteDATADOG_JENKINS_PLUGIN_TARGET_API_URL="https://api.us5.datadoghq.com/api/"DATADOG_JENKINS_PLUGIN_TARGET_LOG_INTAKE_URL="https://http-intake.logs.us5.datadoghq.com/v1/input/"DATADOG_JENKINS_TARGET_WEBHOOK_INTAKE_URL="https://webhook-intake.us5.datadoghq.com/api/v2/webhook/"# Configure your API keyDATADOG_JENKINS_PLUGIN_TARGET_API_KEY=your-api-key
# Enable CI VisibilityDATADOG_JENKINS_PLUGIN_ENABLE_CI_VISIBILITY=true# (Optional) Configure your CI Instance nameDATADOG_JENKINS_PLUGIN_CI_VISIBILITY_CI_INSTANCE_NAME=jenkins
# Select the Datadog Agent modeDATADOG_JENKINS_PLUGIN_REPORT_WITH=HTTP
# Endpoint URLs correspond to your Datadog siteDATADOG_JENKINS_PLUGIN_TARGET_API_URL="https://api.ap1.datadoghq.com/api/"DATADOG_JENKINS_PLUGIN_TARGET_LOG_INTAKE_URL="https://http-intake.logs.ap1.datadoghq.com/v1/input/"DATADOG_JENKINS_TARGET_WEBHOOK_INTAKE_URL="https://webhook-intake.ap1.datadoghq.com/api/v2/webhook/"# Configure your API keyDATADOG_JENKINS_PLUGIN_TARGET_API_KEY=your-api-key
# Enable CI VisibilityDATADOG_JENKINS_PLUGIN_ENABLE_CI_VISIBILITY=true# (Optional) Configure your CI Instance nameDATADOG_JENKINS_PLUGIN_CI_VISIBILITY_CI_INSTANCE_NAME=jenkins
Restart your Jenkins instance.
Set the following environment variables on your Jenkins instance machine:
# Select the Datadog Agent modeDATADOG_JENKINS_PLUGIN_REPORT_WITH=DSD
# Configure the Agent hostDATADOG_JENKINS_PLUGIN_TARGET_HOST=your-agent-host
# Configure the Traces Collection port (default 8126)DATADOG_JENKINS_PLUGIN_TARGET_TRACE_COLLECTION_PORT=8126# Enable CI VisibilityDATADOG_JENKINS_PLUGIN_ENABLE_CI_VISIBILITY=true# (Optional) Configure your CI Instance nameDATADOG_JENKINS_PLUGIN_CI_VISIBILITY_CI_INSTANCE_NAME=jenkins
Restart your Jenkins instance.
Validate the configuration
To verify that CI Visibility is enabled, go to Jenkins Log and search for:
Set and export a new environment variable called DD_CI_HOSTNAME in every Jenkins worker with the worker hostname.
It must be the same hostname that the Datadog Agent is reporting in the infrastructure metrics for that worker.
You can use fixed values or other environment variables as valid values.
exportDD_CI_HOSTNAME=my-hostname
If you are using Kubernetes to manage your Jenkins instances, add the DD_CI_HOSTNAME environment variable to the pod that executes the Jenkins job. The value of this environment variable depends on what you are using in your Datadog Agent daemonset when reporting the infrastructure metrics.
This is only required for Jenkins workers. For the Jenkins controller, the infrastructure metric correlation does not require additional actions.
Note: Infrastructure metric correlation is supported since Jenkins Plugin v5.0.0 or later.
Collect job logs
This is an optional step that enables the collection of job logs. Both Agentless and Agent-based options are supported.
Enable with the Jenkins configuration UI
In the web interface of your Jenkins instance, go to Manage Jenkins > Configure System.
Go to the Datadog Plugin section, scrolling down the configuration screen.
Double check that Use the Datadog Agent to report to Datadog is selected and that Log Intake URL points to a URL in your current Datadog site.
Click on the Enable Log Collection checkbox to activate it.
Save your configuration.
In the web interface of your Jenkins instance, go to Manage Jenkins > Configure System.
Go to the Datadog Plugin section, scrolling down the configuration screen.
Double check that the Use the Datadog Agent to report to Datadog option is selected.
Configure the Log Collection port, as configured in the Datadog Agent.
Click on the Enable Log Collection checkbox to activate it.
Modify the configuration YAML for the entry datadogGlobalConfiguration to include the following:
unclassified:datadogGlobalConfiguration:# Configure the `Log Collection` port, as configured in the Datadog Agent,targetLogCollectionPort:10518# Enable Log collectioncollectBuildLogs:true
In your Jenkins instance web interface, go to Manage Jenkins > Configuration as Code.
Apply or reload the configuration.
Check the configuration using the View Configuration button.
Enable with Groovy
In your Jenkins instance web interface, go to Manage Jenkins > Script Console.
Update your configuration script to include the following:
importjenkins.model.*importorg.datadog.jenkins.plugins.datadog.DatadogGlobalConfigurationdefj=Jenkins.getInstance()defd=j.getDescriptor("org.datadog.jenkins.plugins.datadog.DatadogGlobalConfiguration")// Endpoint URLs correspond to your Datadog site
d.setTargetLogIntakeURL("https://http-intake.logs.datadoghq.com/v1/input/")// Enable log collection
d.setCollectBuildLogs(true)// Save config
d.save()
importjenkins.model.*importorg.datadog.jenkins.plugins.datadog.DatadogGlobalConfigurationdefj=Jenkins.getInstance()defd=j.getDescriptor("org.datadog.jenkins.plugins.datadog.DatadogGlobalConfiguration")// Endpoint URLs correspond to your Datadog site
d.setTargetLogIntakeURL("https://http-intake.logs.datadoghq.eu/v1/input/")// Enable log collection
d.setCollectBuildLogs(true)// Save config
d.save()
importjenkins.model.*importorg.datadog.jenkins.plugins.datadog.DatadogGlobalConfigurationdefj=Jenkins.getInstance()defd=j.getDescriptor("org.datadog.jenkins.plugins.datadog.DatadogGlobalConfiguration")// Endpoint URLs correspond to your Datadog site
d.setTargetLogIntakeURL("https://http-intake.logs.us3.datadoghq.com/v1/input/")// Enable log collection
d.setCollectBuildLogs(true)// Save config
d.save()
importjenkins.model.*importorg.datadog.jenkins.plugins.datadog.DatadogGlobalConfigurationdefj=Jenkins.getInstance()defd=j.getDescriptor("org.datadog.jenkins.plugins.datadog.DatadogGlobalConfiguration")// Endpoint URLs correspond to your Datadog site
d.setTargetLogIntakeURL("https://http-intake.logs.us5.datadoghq.com/v1/input/")// Enable log collection
d.setCollectBuildLogs(true)// Save config
d.save()
importjenkins.model.*importorg.datadog.jenkins.plugins.datadog.DatadogGlobalConfigurationdefj=Jenkins.getInstance()defd=j.getDescriptor("org.datadog.jenkins.plugins.datadog.DatadogGlobalConfiguration")// Endpoint URLs correspond to your Datadog site
d.setTargetLogIntakeURL("https://http-intake.logs.dd-gov.com/v1/input/")// Enable log collection
d.setCollectBuildLogs(true)// Save config
d.save()
importjenkins.model.*importorg.datadog.jenkins.plugins.datadog.DatadogGlobalConfigurationdefj=Jenkins.getInstance()defd=j.getDescriptor("org.datadog.jenkins.plugins.datadog.DatadogGlobalConfiguration")// Endpoint URLs correspond to your Datadog site
d.setTargetLogIntakeURL("https://http-intake.logs.ap1.datadoghq.com/v1/input/")// Enable log collection
d.setCollectBuildLogs(true)// Save config
d.save()
In your Jenkins instance web interface, go to Manage Jenkins > Script Console.
Update your configuration script to include the following:
importjenkins.model.*importorg.datadog.jenkins.plugins.datadog.DatadogGlobalConfigurationdefj=Jenkins.getInstance()defd=j.getDescriptor("org.datadog.jenkins.plugins.datadog.DatadogGlobalConfiguration")// Configure the Log Collection port, as configured in the Datadog Agent.
d.setTargetLogCollectionPort(10518)// Enable log collection
d.setCollectBuildLogs(true)// Save config
d.save()
Use environment variables
Add the following environment variables on your Jenkins instance machine:
# Endpoint URLs correspond to your Datadog siteDATADOG_JENKINS_PLUGIN_TARGET_LOG_INTAKE_URL="https://http-intake.logs.datadoghq.com/v1/input/"# Enable log collectionDATADOG_JENKINS_PLUGIN_COLLECT_BUILD_LOGS=true
# Endpoint URLs correspond to your Datadog siteDATADOG_JENKINS_PLUGIN_TARGET_LOG_INTAKE_URL="https://http-intake.logs.datadoghq.eu/v1/input/"# Enable log collectionDATADOG_JENKINS_PLUGIN_COLLECT_BUILD_LOGS=true
# Endpoint URLs correspond to your Datadog siteDATADOG_JENKINS_PLUGIN_TARGET_LOG_INTAKE_URL="https://http-intake.logs.us3.datadoghq.com/v1/input/"# Enable log collectionDATADOG_JENKINS_PLUGIN_COLLECT_BUILD_LOGS=true
# Endpoint URLs correspond to your Datadog siteDATADOG_JENKINS_PLUGIN_TARGET_LOG_INTAKE_URL="https://http-intake.logs.us5.datadoghq.com/v1/input/"# Enable log collectionDATADOG_JENKINS_PLUGIN_COLLECT_BUILD_LOGS=true
# Endpoint URLs correspond to your Datadog siteDATADOG_JENKINS_PLUGIN_TARGET_LOG_INTAKE_URL="https://http-intake.logs.dd-gov.com/v1/input/"# Enable log collectionDATADOG_JENKINS_PLUGIN_COLLECT_BUILD_LOGS=true
# Endpoint URLs correspond to your Datadog siteDATADOG_JENKINS_PLUGIN_TARGET_LOG_INTAKE_URL="https://http-intake.logs.ap1.datadoghq.com/v1/input/"# Enable log collectionDATADOG_JENKINS_PLUGIN_COLLECT_BUILD_LOGS=true
Restart your Jenkins instance.
Add the following environment variables on your Jenkins instance machine:
# Configure the Log Collection port, as configured in the previous step.DATADOG_JENKINS_PLUGIN_TARGET_LOG_COLLECTION_PORT=10518# Enable log collectionDATADOG_JENKINS_PLUGIN_COLLECT_BUILD_LOGS=true
Restart your Jenkins instance.
Logs are billed separately from CI Visibility. Log retention, exclusion, and indexes are configured in Log Management. Logs for Jenkins jobs can be identified by the source:jenkins tag.
Enable Test Optimization
This is an optional step that enables the collection of tests data using Test Optimization.
See the Test Optimization documentation for your language to make sure that the testing framework that you use is supported.
There are different ways to enable Test Optimization inside a Jenkins job or pipeline:
Using the Jenkins configuration UI.
Adding the datadog step inside the pipeline script.
Configuring the tracer manually.
For pipelines that spin up a Docker container to execute tests, you can only configure the tracer manually.
Enable with the Jenkins configuration UI
UI-based Test Optimization configuration is available in Datadog Jenkins plugin v5.6.0 or later.
This option is not suitable for pipelines that are configured entirely in Jenkinsfile (for example, Multibranch pipelines or pipelines from Organization Folder).
For these pipelines use declarative configuration with the datadog step (described in the next section).
To enable Test Optimization through the UI do the following:
In your Jenkins instance web interface, go to the job or pipeline that you want to instrument and choose the Configure option.
In the General configuration section, tick the Enable Datadog Test Optimization checkbox.
Enter the name of the service or library being tested into the Service Name input. You can choose any value that makes sense to you.
Choose the languages for which you want to enable tests instrumentation. Some of the languages do not support configuration through the UI. To configure Test Optimization for these languages, follow the manual configuration instructions.
This configuration option is available in Datadog Jenkins plugin v5.6.2 or later.
In declarative pipelines, add the step to a top-level options block like so:
pipeline{agentanyoptions{datadog(testVisibility:[enabled:true,serviceName:"my-service",// the name of service or library being tested
languages:["JAVA"],// languages that should be instrumented (available options are "JAVA", "JAVASCRIPT", "PYTHON", "DOTNET")
additionalVariables:["my-var":"value"]// additional tracer configuration settings (optional)
])}stages{stage('Example'){steps{echo"Hello world."}}}}
In a scripted pipeline, wrap the relevant section with the datadog step like so:
Some features of the Datadog Jenkins plugin need Git information associated with the Jenkins builds to work correctly.
The minimum required Git info for a build is repository URL, branch, commit SHA, and commit author email.
This information can be determined by the plugin automatically, propagated from SCM, provided manually with environment variables, or obtained by combining these approaches.
Propagate Git information from SCM
The Jenkins plugin is capable of automatically detecting Git information associated with a build or a pipeline.
However, depending on the Jenkins version and the pipeline details, there may be cases when automatic Git data detection is not possible.
In this case you can make the Git information available to the plugin by using the .each {k,v -> env.setProperty(k, v)} function after executing the checkout or git steps. For example:
If you’re using a declarative pipeline to configure your pipeline, propagate Git information using a script block as follows:
In case the plugin cannot detect Git information automatically and propagating Git data via SCM is not an option,
the necessary Git information can be set manually.
To do so, set the following environment variables.
Note: These variables are optional, but if they are set, they take precedence over the Git information set by other Jenkins plugins.
DD_GIT_REPOSITORY (Optional)
The repository URL of your service. Example: https://github.com/my-org/my-repo.git
DD_GIT_BRANCH (Optional)
The branch name. Example: main
DD_GIT_TAG (Optional)
The tag of the commit (if any). Example: 0.1.0
DD_GIT_COMMIT_SHA (Optional)
The commit expressed in the hex 40 chars length form. Example: faaca5c59512cdfba9402c6e67d81b4f5701d43c
DD_GIT_COMMIT_MESSAGE (Optional)
The commit message. Example: Initial commit message
DD_GIT_COMMIT_AUTHOR_NAME (Optional)
The name of the author of the commit. Example: John Smith
DD_GIT_COMMIT_AUTHOR_EMAIL (Optional)
The email of the author of the commit. Example: john@example.com
DD_GIT_COMMIT_AUTHOR_DATE (Optional)
The date when the author submitted the commit expressed in ISO 8601 format. Example: 2021-08-16T15:41:45.000Z
DD_GIT_COMMIT_COMMITTER_NAME (Optional)
The name of the committer of the commit. Example: Jane Smith
DD_GIT_COMMIT_COMMITTER_EMAIL (Optional)
The email of the committer of the commit. Example: jane@example.com
DD_GIT_COMMIT_COMMITTER_DATE (Optional)
The date when the committer submitted the commit expressed in ISO 8601 format. Example: 2021-08-16T15:41:45.000Z
If you set only repository, branch and commit, the plugin will try to extract the rest of the Git information from the .git folder.
An example of usage:
pipeline{agentanystages{stage('Checkout'){steps{script{defgitVars=giturl:'https://github.com/my-org/my-repo.git',branch:'some/feature-branch'// Setting Git information manually via environment variables.
env.DD_GIT_REPOSITORY_URL=gitVars.GIT_URLenv.DD_GIT_BRANCH=gitVars.GIT_BRANCHenv.DD_GIT_COMMIT_SHA=gitVars.GIT_COMMIT}}}stage('Test'){steps{// Execute the rest of the pipeline.
}}}}
Include or exclude pipelines
You can configure the Jenkins Plugin to include or exclude specific pipelines:
In the web interface of your Jenkins instance, go to Manage Jenkins > Configure System.
Go to the Datadog Plugin section by scrolling down the configuration screen.
Click on the Advanced button.
Configure the Excluded Jobs.
Configure the Included Jobs.
Save your configuration.
Excluded jobs
A comma-separated list of Jenkins jobs that should not be monitored. The exclusion applies to all metrics, traces, events, and service checks. Excluded jobs can use regular expressions to reference multiple jobs. Environment variable: DATADOG_JENKINS_PLUGIN_EXCLUDED Example: susans-job,johns-.*,prod_folder/prod_release
Included jobs
A comma-separated list of Jenkins job names that should be monitored. If the included jobs list is empty, all jobs that are not excluded explicitly are monitored. The inclusion applies to all metrics, traces, events, and service checks. Included jobs can use regular expressions to reference multiple jobs. Environment variable: DATADOG_JENKINS_PLUGIN_INCLUDED Example: susans-job,johns-.*,prod_folder/prod_release
Lists of included and excluded jobs can contain regular expressions, but not glob patterns. To include a job with a specific prefix, use prefix-.*—not prefix-*.
Advanced configuration
Set the default branch name
To report pipeline results, attach the default branch name (for example, main) to pipeline spans in an attribute called git.default_branch. This is usually done automatically, but in some cases the plugin cannot extract this information because it might not be provided by Jenkins.
If this happens, set the default branch manually using the DD_GIT_DEFAULT_BRANCH environment variable in your build. For example:
To display and filter the teams associated with your pipelines, add team:<your-team> as a custom tag. The custom tag name must match your Datadog Teams team handle exactly.
Set global custom tags
You can configure the Jenkins Plugin to send custom tags (like global tags and global job tags) in all pipeline traces:
In the web interface of your Jenkins instance, go to Manage Jenkins > Configure System.
Go to the Datadog Plugin section, scrolling down the configuration screen.
Click on the Advanced button.
Configure the Global Tags.
Configure the Global Job Tags.
Save your configuration.
Global tags
A comma-separated list of tags to apply to all metrics, traces, events, and service checks. Tags can include environment variables that are defined in the Jenkins controller instance. Environment variable: DATADOG_JENKINS_PLUGIN_GLOBAL_TAGS Example: key1:value1,key2:${SOME_ENVVAR},${OTHER_ENVVAR}:value3
Global job tags
A comma-separated list of regexes to match a job and a list of tags to apply to that job. Tags can include environment variables that are defined in the Jenkins controller instance. Tags can reference match groups in the regex using the $ symbol. Environment variable: DATADOG_JENKINS_PLUGIN_GLOBAL_JOB_TAGS Example: (.*?)_job_(.*?)_release, owner:$1, release_env:$2, optional:Tag3
Visualize pipeline data in Datadog
Once the integration is successfully configured, both the CI Pipeline List and Executions pages populate with data after pipelines finish.
The CI Pipeline List page shows data for only the default branch of each repository. For more information, see Search and Manage CI Pipelines.
Troubleshooting
Generate diagnostic flare
When reporting an issue to the Datadog support team, generate a plugin diagnostic flare and provide it along with the issue description.
To generate the flare do the following:
In your Jenkins instance web interface, go to Manage Jenkins > Troubleshooting > Datadog.
In the Diagnostic Flare form, check which information you want to include in the flare. The default selection works best. The more information you provide, the easier it is to diagnose your issue.
Click Download to generate and download the flare archive.
Enable DEBUG log level for the Datadog Plugin
If you have any issues with the Datadog Plugin, you can set the logs for the plugin in DEBUG level. Using this level you are able to see stacktrace details if an exception is thrown.
In your Jenkins instance web interface, go to Manage Jenkins > System log.
Click on Add new log recorder button.
Type the log recorder name. E.g: Datadog Plugin Logs.
Add the following loggers to the list:
Logger: org.datadog.jenkins.plugins.datadog.clients -> Log Level ALL
Logger: org.datadog.jenkins.plugins.datadog.traces -> Log Level ALL
Logger: org.datadog.jenkins.plugins.datadog.logs -> Log Level ALL
Logger: org.datadog.jenkins.plugins.datadog.model -> Log Level ALL
Logger: org.datadog.jenkins.plugins.datadog.listeners -> Log Level ALL
Save the configuration.
You may also want to split the loggers into different log recorders.
Once the log recorders are successfully configured, you can check the logs in the DEBUG mode by accessing the desired log recorder through Manage Jenkins > System log.
If you trigger a Jenkins pipeline, you can search for the message Send pipeline traces in the Datadog Plugin Logs. This message indicates that the plugin is sending CI Visibility data to the Datadog Agent.
Pipeline executions data is not available in Datadog
HTTP connectivity check
If your Jenkins instance is behind an HTTP proxy, go to Manage Jenkins > Manage Plugins > Advanced tab and make sure the proxy configuration is correct:
If the Datadog plugin is configured to send data to a Datadog Agent, check that the Agent host has been added to the No Proxy Hosts section.
If the Datadog plugin is configured to send data directly to Datadog (Agentless mode), check that Datadog host has been added to the No Proxy Hosts section. The table below shows the supported Datadog sites and their corresponding host values:
Datadog site
Host value
US1
datadoghq.com
US3
us3.datadoghq.com
US5
us5.datadoghq.com
EU1
datadoghq.eu
AP1
ap1.datadoghq.com
The Datadog Plugin cannot write payloads to the server
If the following error message appears in the Jenkins Log, make sure that the plugin configuration is correct.
Error writing to server
If you are using localhost as the hostname, change it to the server hostname instead.
Jenkins logs are not available in Datadog
If the Datadog plugin is configured to send data to a Datadog Agent, do the following:
Go to the plugin configuration UI and click Test logs connection to verify logs connectivity.
The Datadog Plugin section does not appear in the Jenkins configuration
If the Datadog Plugin section does not appear in Jenkins configuration section, make sure that the plugin is enabled. To do so:
In your Jenkins instance web interface, go to Manage Jenkins > Manage Plugins.
Search for Datadog Plugin in the Installed tab.
Check that the Enabled checkbox is marked.
If you enable the plugin here, restart your Jenkins instance using the /safeRestart URL path.
The CI Visibility option does not appear in the Datadog Plugin section.
If the CI Visibility option does not appear in the Datadog Plugin section, make sure that the correct version is installed and restart the Jenkins instance. To do so:
In your Jenkins instance web interface, go to Manage Jenkins > Manage Plugins.
Search for Datadog Plugin in the Installed tab.
Check that the installed version is correct.
Restart your Jenkins instance using the /safeRestart URL path.
Infrastructure metrics do not get correlated with Jenkins pipelines