Skip to main content

CI/CD Integration

Prerequisites#

Perform a one time setup before you continue with CI/CD integration.

CI/CD Integration#

The Drill4Net agent should run after the build step in CI/CD pipeline:

1. Update Build Version in Configurations#

Each build should update build version in Drill4Net Scanner and Drill4Net Injector configuration files.

  1. Update adminAgentConfig:buildVersion in Drill4Net Scanner appsettings.yml to version of current build.
  2. Update AdminAgentConfig:BuildVersion in Drill4Net Injector drill4netsettings.yml to version of current build.

2. Run Drill4Net Scanner#

After each build, you should run Drill4Net Scanner for application under test assembly.

3. Run Drill4Net Injector#

After each build, you should run Drill4Net Injector for assembly with tests.

4. Run Tests#

After Drill4Net Scanner and Drill4Net Injector finished work, you should run tests from assembly provided to Drill4Net Injector.

Make sure that application under test assembly and assembly with tests are not rebuilt before running tests.Drill4Net Scanner and Drill4Net Injector make some important modifications to the assembly to make Drill4Net solution work.

5. Get Tests to Run#

You can execute the curl command to get tests to run:

curl -i -H "accept: application/json" \
-H "content-type: application/json" \
-X GET {drill4j-address}/api/agents/{agent-id}/plugins/test2code/data/tests-to-run

drill4j-address is the address of Drill4J Admin, for example http://localhost:8091.

agent-id is the value of adminAgentConfig:id provided in Drill4Net Scanner earlier.

To cover new build's Risks (methods modified since previous build) it is enough to only run tests returned in thr response.

6. Creating Environment Variable for SessionId#

When running a bunch of tests on different machines, it's essential to maintain consistency in test sessions. To achieve this, you can set up a unique session identifier using environment variables. The value for this environment variable can be any string, but it's important to ensure its uniqueness for proper session tracking. Ensure that you maintain this session ID consistency across all test machines.

Examples of scripts for creating environment variables:#

Bash#
#!/bin/bash
guidValue=$(date +"%Y%m%d%H%M%S")
export Drill4NetSessionId=$guidValue
PowerShell#
$guidValue = [guid]::NewGuid().ToString()
# This script needs to execute in the same process tree as tests
[System.Environment]::SetEnvironmentVariable('Drill4NetSessionId', $guidValue, [System.EnvironmentVariableTarget]::Process)
Write-Output "Created/Updated environment variable Drill4NetSessionId with value: $guidValue"