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 setting Datadog API key credentials with configuration as code #438

Closed nikita-tkachenko-datadog closed 3 weeks ago

nikita-tkachenko-datadog commented 3 weeks ago

Requirements for Contributing to this repository

What does this PR do?

Fixes setting Datadog APU key credential ID with Configuration-as-Code Jenkins plugin.

Description of the Change

When configuring Datadog plugin with configuration as code, targetCredentialsApiKey field is set, but not the usedApiKey which refers to the actual API key used by the plugin (could be either the credential or the API key supplied in text input).

The workaround is to check whether the used key field is initialised when the plugin attempts to read it. If the field is not initialised, both "target" fields are checked to see if the key was supplied using one of them.

This is a temporary workaround that will be removed later when the plugin configuration is refactored to have only one field for key.

Alternate Designs

Possible Drawbacks

Verification Process

Additional Notes

Release Notes

Review checklist (to be filled by reviewers)