# withDatadogTestOptimizationEnv

Sets up Datadog CI Visibility environment variables for the given steps. These env vars can then be passed into a container to populate git metadata and Jenkins pipeline info 
so that test results reported to Datadog are correctly attributed.

This exposes the following env vars, ensure you pass these into your running container:

| Variable | Source | Description |
|---|---|---|
| `DD_GIT_REPOSITORY_URL` | `env.GIT_URL` | Repository URL |
| `DD_GIT_COMMIT_SHA` | `env.GIT_COMMIT` | Full commit SHA |
| `DD_GIT_BRANCH` | `env.GIT_BRANCH` | Branch name |
| `DD_GIT_COMMIT_AUTHOR_NAME` | `git log` | Commit author name |
| `DD_GIT_COMMIT_AUTHOR_EMAIL` | `git log` | Commit author email |
| `DD_GIT_COMMIT_MESSAGE` | `git log` | Commit subject line |

## Examples

```groovy
withDatadogTestOptimizationEnv {
    dir('integration_test_framework') {
        sh 'docker compose up --build --exit-code-from integration-tests'
    }
}
```
