CI/CD Integration Plugin
Overview#
The CI/CD integration plugin offers a wide range of capabilities and is available for both Gradle and Maven.
All these functions are provided under a single tool because they are related to tasks executed within Maven or Gradle.
Features#
CI/CD Integration Plugin functions include:
Downloading and configuring the Drill4J Java Agent
Enabling agent features:
- Coverage collection - to capture code coverage for application classes
- Test tracing - to map tests to code coverage and vice versa
- Class scanning - to scan application classes at build time or runtime
- Test recommendations - to skip tests for unchanged code
Generating change testing reports:
- With a command - useful to call on branch push event.
- On GitHub Pull Request
- On GitLab Merge Request
Sending Git metadata to Drill4J API - to supply Drill4J with commit information (date, hash, author) from which a particular application version is built.
How to use#
The general gist of using the CI/CD integration plugin is:
- Add the plugin to your Maven or Gradle configuration.
- Configure the agent and enable desired features (coverage, test tracing, etc.)
- Use commands provided by CI/CD Integration Plugin and integrate it with your CI/CD scripts
The exact configuration files and commands you should use depend on the task at hand. This page provides general reference. For step-by-step guides refer to Integration Guides section (see documentation sidebar at the top of the page).
Adding plugin#
This section describes how to add CI/CD integration plugin to your Gradle/Maven project.
Set Up#
Gradle#
Add the following to Gradle build file plugins section:
plugins {id("com.epam.drill.integration.cicd") version "0.1.15"}
Maven#
Add the Drill4J CI/CD integration plugin to <build> section of pom.xml file:
<build><plugins><plugin><groupId>com.epam.drill.integration</groupId><artifactId>drill-maven-plugin</artifactId><version>0.1.15</version><configuration><!-- Plugin configuration goes here, see sections below for details --></configuration></plugin></plugins></build>
API Key Configuration#
For the plugin to be able to send data to Drill4J backend, it needs to be configured with Drill4J API address and API key. You can set these parameters in two ways:
- Option 1 (recommended): using environment variables.
- Option 2 (not recommended): using Gradle/Maven plugin configuration.
Gradle#
Maven#
Per-task configuration override#
The Gradle CI/CD integration plugin allows you to override any Drill4J configuration parameter for a specific Gradle task. This can be used to:
- Disable specific features for certain tasks
- Enable features only for selected tasks (without enabling them globally)
- Customize parameters like
packagePrefixes,buildVersion, or feature-specific options on a per-task basis
To override configuration for a specific task, add a drill {} block inside the task configuration:
Overriding test task configuration#
Overriding archive task configuration#
This approach is not available for Maven. In Maven, use dedicated profiles to control which goals include the Drill4J agent.
Agent Setup#
Drill4J uses a single agent for JVM-based applications and JVM-based tests. The agent is configured within the drill {} block and enables features such as coverage collection, test tracing, and class scanning.
For more details on the agent itself, see the Java Agent reference page.
Set up#
Prerequisite - CI/CD integration plugin added to project
Gradle#
To set up the Drill4J agent in a Gradle project, add the following to your build file:
drill {// Required parametersgroupId = "my-group"appId = "my-application"// Specifies the java packages for Drill4J to monitor// Use "/" separator for package name partspackagePrefixes = arrayOf("my/awesome/application")// Optional, identifies app version built from checked out commitbuildVersion = "1.0.0"// Agent download configurationagent {version = "0.9.20"}// Enable desired features (see sections below)coverage()testTracing()}
If
coverage()ortestTracing()feature is enabled, the agent will automatically launch for every Gradle test and JavaExec task. To override configuration for specific tasks, refer to Per-Task Configuration Override.
Maven#
To set up the Drill4J agent in a Maven project, add the following to pom.xml:
<plugin><groupId>com.epam.drill.integration</groupId><artifactId>drill-maven-plugin</artifactId><version>0.1.15</version><configuration><!-- Required parameters --><groupId>my-group</groupId><appId>my-application</appId><!-- Specifies the java packages for Drill4J to monitor --><!-- Use "/" separator for package name parts --><packagePrefixes>my/awesome/application</packagePrefixes><!-- Optional, identifies app version built from checked out commit --><buildVersion>1.0.0</buildVersion><!-- Agent download configuration --><agent><version>0.9.20</version></agent><!-- Enable desired features (see sections below) --><coverage><enabled>true</enabled></coverage><testTracing><enabled>true</enabled></testTracing></configuration><!-- adds enableAgent goal --><executions><execution><goals><goal>enableAgent</goal></goals></execution></executions></plugin>
The agent will automatically launch for every Maven test goal.
Agent files download source#
There are 3 ways to specify where CI/CD plugin should load agent from:
- Automatic download by version tag - the default option.
- Custom URL download - arbitrary URL to ZIP release.
- Local path to ZIP release - local path to ZIP release.
Automatic download#
To enable automatic download specify version parameter with concrete version. See list of available versions on Java Agent GitHub repository releases page.
GitHub API has rate limits for unauthenticated downloads. To increase these limits, set the
GH_USER_TOKENenvironment variable.
Gradle#
agent {version = "0.9.20"}
Maven#
<agent><version>0.9.20</version></agent>
Custom URL download#
To download the agent from a custom URL, set the downloadUrl parameter to the desired link:
Gradle#
Maven#
Local path to ZIP release#
To use a locally available agent, set the zipPath parameter to the path of the local zip archive:
Gradle#
Maven#
Setting agent mode#
Drill4J has two modes of running the agent:
NATIVE- uses native library file (more capabilities)JAVA- uses drill-runtime.jar file (platform agnostic)
By default, the agent uses NATIVE mode. To set JAVA mode, set the agentMode parameter in agent configuration:
Gradle#
Maven#
Coverage Collection#
Enables Drill4J to collect code coverage for application classes. See the Java Agent reference page for more details.
Set up#
Prerequisite:
- Agent setup is configured
- Enabling coverage collection requires the
packagePrefixesparameter to be specified.
Gradle#
To enable coverage collection in a Gradle project, add coverage() to the drill {} block:
drill {groupId = "my-group"appId = "my-application"packagePrefixes = arrayOf("my/awesome/application")buildVersion = "1.0.0"agent {version = "0.9.20"}// Enables coverage collectioncoverage()}
Maven#
To enable coverage collection in a Maven project, add the <coverage> configuration:
<plugin><groupId>com.epam.drill.integration</groupId><artifactId>drill-maven-plugin</artifactId><version>0.1.15</version><configuration><groupId>my-group</groupId><appId>my-application</appId><packagePrefixes>my/awesome/application</packagePrefixes><buildVersion>1.0.0</buildVersion><agent><version>0.9.20</version></agent><!-- Enables coverage collection --><coverage><enabled>true</enabled></coverage></configuration><executions><execution><goals><goal>enableAgent</goal></goals></execution></executions></plugin>
Test Tracing#
Enables Drill4J to establish test-to-code mapping, linking each test to the specific code it exercises and vice versa. In addition, it provides test tracking capabilities — recording which tests were executed along with their outcomes (passed, failed, skipped, etc.).
Set up#
Prerequisite - Agent setup is configured
Gradle#
To enable test tracing in a Gradle project, add testTracing() to the drill {} block:
drill {groupId = "my-group"appId = "my-application"packagePrefixes = arrayOf("my/awesome/application")agent {version = "0.9.20"}// Enables test tracingtestTracing()}
Maven#
To enable test tracing in a Maven project, add the <testTracing> configuration:
<plugin><groupId>com.epam.drill.integration</groupId><artifactId>drill-maven-plugin</artifactId><version>0.1.15</version><configuration><groupId>my-group</groupId><appId>my-application</appId><packagePrefixes>my/awesome/application</packagePrefixes><agent><version>0.9.20</version></agent><!-- Enables test tracing --><testTracing><enabled>true</enabled></testTracing></configuration><executions><execution><goals><goal>enableAgent</goal></goals></execution></executions></plugin>
Test tracing options#
You can configure test tracing with the following options:
| Option | Description |
|---|---|
testSessionId | Custom identifier for the test session. Generated automatically in UUID format for each test session if not specified. |
perTestSession | When enabled, groups trace data by test session. |
perTestLaunch | When enabled, records granular per-launch trace data for each test execution. |
Enabling
perTestLaunchmay increase the amount of trace data collected, which can impact performance and storage. Use this option if you need detailed insights into each test execution.
Gradle#
Maven#
Class Scanning#
Drill4J scans application classes and methods to identify structural changes between application builds. This can be done at either:
- runtime during application execution;
- before running a test task;
- after a build;
- directly by executing the dedicated Gradle/Maven command.
Set up#
Prerequisite:
- Agent setup is configured
- Enabling coverage collection requires the
packagePrefixesparameter to be specified.
Gradle#
To enable class scanning in a Gradle project, add classScanning to the drill {} block:
drill {groupId = "my-group"appId = "my-application"packagePrefixes = arrayOf("my/awesome/application")agent {version = "0.9.20"}// Class scanning configurationclassScanning {appClasses = files("build/classes/java/main") //Optional, path to compiled application classestestClasses = files("build/classes/java/test") //Optional, path to compiled test classes}}
Maven#
To enable class scanning in a Maven project, add the <execution> configuration for any phase you want to trigger scanning:
<plugin><groupId>com.epam.drill.integration</groupId><artifactId>drill-maven-plugin</artifactId><version>0.1.15</version><configuration><groupId>my-group</groupId><appId>my-application</appId><packagePrefixes>my/awesome/application</packagePrefixes><agent><version>0.9.20</version></agent><classScanning><appClasses>target/classes</appClasses> <!-- Optional, path to compiled application classes --><testClasses>target/test-classes</testClasses> <!-- Optional, path to compiled test classes --></classScanning></configuration><executions><execution><!-- Enables class scanning before test task execution --><id>scan-app-classes</id><phase>YOUR_PHASE_HERE</phase><goals><goal>scanAppArchive</goal></goals></execution></executions></plugin>
Scan after build#
Drill4J can automatically scan application classes after a build archive (JAR/WAR/EAR) task completes. This allows Drill4J to collect class metadata right after the application is built, without waiting for it to be run.
Gradle#
To scan application classes after a build archive task completes set the afterBuild option to true:
You can also enable class scanning for a specific build task only:
Maven#
Scan before test execution#
Scanning application classes before test execution allows Drill4J to collect class metadata before the tests are run, which can be useful for impacted tests.
Gradle#
To enable scanning before test execution, set the beforeRun option to true:
Maven#
Runtime class scanning#
The Drill4J agent can scan application classes as they are loaded by the JVM during task execution (e.g., during application run time). This allows Drill4J to collect class metadata from the actual runtime classpath rather than from a static archive.
To enable runtime class scanning, set the runtime option to true:
Gradle#
Maven#
Runtime ClassLoader scanning#
Runtime class scanning capability allows to scan all application's active threads in runtime, retrieves their class loaders, and scans the files loaded by each class loader.
This scanning mode is enabled by default when you enable runtime class scanning. If you want to disable it, set the runtimeClassLoaderScanning enabled option to false:
Gradle#
Maven#
The optional delay parameter specifies a waiting period (in milliseconds) before scanning begins, giving class loaders time to finish loading.
Gradle#
Maven#
Scan by running command#
You can scan the application archive (JAR/WAR/EAR) by executing the dedicated Gradle task or Maven goal as described below.
Gradle#
Execute the following Gradle command:
Maven#
Execute the following Maven command:
Test Recommendations#
Drill4J helps to significantly reduce test execution time by providing recommendations on which tests can be skipped because the code they cover has already been tested before.
Set up#
Prerequisites:
- Agent setup is configured.
- Test tracing is enabled.
- Before running the tests, make sure that the application under test is already deployed with coverage collection enabled.
Gradle#
To enable test recommendations add the following properties to your Gradle build file:
drill {// Group IDgroupId = "my-group"// ID of the application under testappId = "my-application"// Identifies the version of the application under test that is based on the checked out commitbuildVersion = "1.0.0"agent {version = "0.9.20"}// Enables Coverage Collectioncoverage()// Enables Test TracingtestTracing()// Enables Test RecommendationsrecommendedTests()}
Maven#
To enable test recommendations add the following properties to your Maven pom.xml file:
<plugin><groupId>com.epam.drill.integration</groupId><artifactId>drill-maven-plugin</artifactId><version>0.1.15</version><configuration><!-- Group ID --><groupId>my-group</groupId><!-- ID of the application under test --><appId>my-application</appId><!-- Identifies the version of the application under test that is based on the checked out commit --><buildVersion>1.0.0</buildVersion><agent><version>0.9.20</version></agent><!-- Enables Coverage Collection --><coverage><enabled>true</enabled></coverage><!-- Enables Test Tracing --><testTracing><enabled>true</enabled></testTracing><!-- Enables Test Recommendations --><recommendedTests><enabled>true</enabled></recommendedTests></configuration><executions><execution><goals><goal>enableAgent</goal></goals></execution></executions></plugin>
Disabling recommended tests#
Gradle#
To disable recommended tests, make the following changes to your Gradle file:
recommendedTests {// Optional, disables test recommendationsenabled = false}
Maven#
To disable recommended tests, make the following changes to your Maven file:
<recommendedTests><!-- Disables Test Recommendations --><enabled>false</enabled></recommendedTests>
Comparing with baseline#
Drill4J allows you to run tests only for code that has changed compared to the baseline version. To skip tests for unchanged code, set the baseline version to compare with.
See the Baseline Strategy section for more information.
Gradle#
To set the baseline configuration, add the following properties to your Gradle build file:
drill {// Group IDgroupId = "my-group"// ID of the application under testappId = "my-application"// Identifies the version of the application under test that is based on the checked out commitbuildVersion = "1.0.0"// Set either to SEARCH_BY_MERGE_BASE or SEARCH_BY_TAG. See "Baseline Strategy" section on the page below for more infobaseline {searchStrategy = "SEARCH_BY_TAG"}// Enable Test Recommendations and Test Agent...}
Maven#
Set the <baseline> Drill4J configuration to your Maven pom.xml file:
<configuration><!-- Group ID --><groupId>my-group</groupId><!-- ID of the application under test --><appId>my-application</appId><!-- Identifies the version of the application under test that is based on the checked out commit --><buildVersion>1.0.0</buildVersion><!-- Set either to SEARCH_BY_MERGE_BASE or SEARCH_BY_TAG. See "Baseline Strategy" section on the page below for more info --><baseline><searchStrategy>SEARCH_BY_TAG</searchStrategy></baseline><!-- Enable Test Recommendations and Test Agent -->...</configuration>
Generating a change testing report#
A Change Testing Report provides insights into the code changes that have been tested, allowing you to ensure the quality of newly introduced changes.
For step-by-step integrations guide see:
Gradle#
Add the following properties to your Gradle build file:
To generate the Change Testing Report, execute the following Gradle command:
The report will be saved in the /build/drill-reports/ directory.
Maven#
Add the following properties to your Maven pom.xml file:
<plugin><groupId>com.epam.drill.integration</groupId><artifactId>drill-maven-plugin</artifactId><version>0.1.15</version><configuration><!-- Enter appropriate parameter values --><groupId>my-group</groupId><appId>my-application</appId><!-- Set either to SEARCH_BY_MERGE_BASE or SEARCH_BY_TAG. See "Baseline Strategy" section on the page below for more info --><baseline><searchStrategy>SEARCH_BY_TAG</searchStrategy></baseline></configuration><executions><execution><goals><goal>generateChangeTestingReport</goal></goals></execution></executions></plugin>
To generate the Change Testing Report, execute the following Maven command:
The report will be saved in the /target/drill-reports/ directory.
GitHub Pull Request report#
This feature posts a report of the tested changes as a comment on a GitHub Pull Request. It compares the current build with the merge base build of the target branch for the Pull Request.
IMPORTANT! This command can only be executed within a GitHub workflow and requires specific environment variables available only in a GitHub Actions job.
To execute this command, you need to provide a GitHub API token. API token should have following rights:
- repo
- write:discussion
Gradle#
Add the following properties to your Gradle build file:
To leave a comment on a Pull Request, execute the following Gradle command:
Maven#
Add the following properties to the Drill4J plugin configuration in your Maven pom.xml file:
<plugin><groupId>com.epam.drill.integration</groupId><artifactId>drill-maven-plugin</artifactId><version>0.1.15</version><configuration><!-- Enter appropriate parameter values --><groupId>my-group</groupId><appId>my-application</appId><github><!-- Enter your GitHub Token --><token>your-github-token-here</token></github></configuration><executions><execution><goals><goal>githubPullRequestReport</goal></goals></execution></executions></plugin>
To leave a comment on a Pull Request, execute the following Maven command:
GitLab Merge Request report#
This feature posts a report of the tested changes as a comment on a GitLab Merge Request. It compares the current build with the merge base build of the target branch for the Merge Request.
IMPORTANT! This command can only be executed within a GitLab CI/CD job and requires specific environment variables available only during GitLab CI/CD execution.
To execute this command, you need to provide a GitLab private token.
Gradle#
Add the following properties to your Gradle build file:
To post a comment on a Merge Request, execute the following Gradle command:
Maven#
Add the following properties to your Maven pom.xml file:
<plugin><groupId>com.epam.drill.integration</groupId><artifactId>drill-maven-plugin</artifactId><version>0.1.15</version><configuration><!-- Set appropriate parameter values --><groupId>my-group</groupId><appId>my-application</appId><gitlab><!-- Adjust if running on a private GitLab instance--><apiUrl>https://gitlab.com/api/v4/</apiUrl><!-- Enter your personal token --><privateToken>someToken</privateToken></gitlab></configuration><executions><execution><goals><goal>gitlabMergeRequestReport</goal></goals></execution></executions></plugin>
To leave a comment on a Merge Request, execute the following Maven command:
Sending Git metadata to Drill4J API#
This enables Drill4J to display additional data on build in the reports, such as:
- Build version
- Current commit SHA
- Current commit message
- Commit author
It makes reports more readable and allows to easily associate reports with particular commits.
Gradle#
Add the following parameters to your Gradle build file:
To send the build information to the Drill4J backend, execute the following Gradle command:
Maven#
Add the following parameters to your Maven pom.xml file:
<plugin><groupId>com.epam.drill.integration</groupId><artifactId>drill-maven-plugin</artifactId><version>0.1.15</version><configuration><!-- Set appropriate parameter values --><groupId>my-group</groupId><appId>my-application</appId><!-- Optional, identifies app version built from checked out commit --><buildVersion>1.0.0</buildVersion></configuration><executions><execution><goals><goal>sendBuildInfo</goal></goals></execution></executions></plugin>
To send the build information to the Drill4J backend, execute the following Maven command
Baseline strategy#
To generate a Change Testing Report or enable Test Recommendations, the current build must be compared to a baseline build. Drill4J supports multiple strategies for identifying the baseline build.
- Search by tags
- Search by merge base
Search by tags#
This strategy compares the current build to a baseline build identified by Git tags.
IMPORTANT! You need to have at least one Git tag in your repository for this strategy to work.
Gradle#
Maven#
Search by merge base#
This strategy compares the current build to the baseline based on the common ancestor (merge base) of two branches.
Gradle#
Maven#
Troubleshooting#
How to confirm that agents are enabled when running tests?#
Once loaded, the Drill4J agent prints the following ASCII logo in the Gradle/Maven console log:
IMPORTANT! Maven does not print the Drill4J logs by default, you need to add the
-Xparameter to the command line:
Tests do not appear in Drill4J after running in Maven with Java 17#
If you run tests in Maven with Java 17 or higher and see the following message:
You should provide --add-opens option to the JVM argument line in Maven Surefire Plugin:
IMPORTANT! Don't forget to add
@{argLine}to keep Drill4J agents enabled.