jenkinsci / datadog-plugin

A Jenkins plugin used to forward metrics, events, and service checks to an account at Datadog, automatically.
https://plugins.jenkins.io/datadog/
MIT License
30 stars 48 forks source link

Fix support for setting environment variables in pipeline stages #356

Closed nikita-tkachenko-datadog closed 1 year ago

nikita-tkachenko-datadog commented 1 year ago

Requirements for Contributing to this repository

What does this PR do?

Update BuildData creation logic: when a new instance is created, a check is made to see whether the associated run already refers to another instance that was created and updated during previous pipeline stages. If there is a previously created instance, it is used to populate Git values in the new instance, in case they are missing.

For instance, if there are environment variables that are set inside a pipeline stage (e.g. Git branch and repo URL that are set during SCM checkout), these variables will only be available during that stage: later stages will not be able to use them. The fallback mechanism ensures that these variables are propagated whenever a new BuildData instance is created at some later point.

This fixes https://datadoghq.atlassian.net/browse/AGENT-10162

Description of the Change

Alternate Designs

Possible Drawbacks

Verification Process

Verified manually using a dockerized Jenkins instance.

Additional Notes

Release Notes

Review checklist (to be filled by reviewers)