Skip to content
This repository has been archived by the owner on Oct 28, 2024. It is now read-only.

Add elastic specific env variables for withOtelEnv #1250

Merged
merged 2 commits into from
Aug 25, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions vars/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3158,6 +3158,8 @@ environment variables:
* `OTEL_EXPORTER_OTLP_ENDPOINT`
* `OTEL_SERVICE_NAME`
* `OTEL_EXPORTER_OTLP_HEADERS`
* `ELASTIC_APM_SERVER_URL`
* `ELASTIC_APM_SECRET_TOKEN`

```
withOtelEnv() {
Expand All @@ -3172,6 +3174,8 @@ environment variables:

* credentialsId: the name of the credentials. Optional.

**NOTE**: It requires the [OpenTelemetry plugin](https://plugins.jenkins.io/opentelemetry")

## withSecretVault
Grab a secret from the vault, define the environment variables which have been
passed as parameters and mask the secrets
Expand Down
5 changes: 4 additions & 1 deletion vars/withOtelEnv.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,11 @@ def call(Map args = [:], Closure body) {

// Then, mask and provide the environment variables.
withCredentials([string(credentialsId: credentialsId, variable: 'OTEL_TOKEN_ID')]) {
def entrypoint = otelPlugin.getEndpoint()
withEnvMask(vars: [
[var: 'OTEL_EXPORTER_OTLP_ENDPOINT', password: otelPlugin.getEndpoint()],
[var: 'ELASTIC_APM_SERVER_URL', password: entrypoint],
[var: 'ELASTIC_APM_SECRET_TOKEN', password: env.OTEL_TOKEN_ID],
[var: 'OTEL_EXPORTER_OTLP_ENDPOINT', password: entrypoint],
[var: 'OTEL_SERVICE_NAME', password: otelPlugin.getServiceName()],
[var: 'OTEL_EXPORTER_OTLP_HEADERS', password: "authorization=Bearer ${env.OTEL_TOKEN_ID}"]
]) {
Expand Down
4 changes: 4 additions & 0 deletions vars/withOtelEnv.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ environment variables:
* `OTEL_EXPORTER_OTLP_ENDPOINT`
* `OTEL_SERVICE_NAME`
* `OTEL_EXPORTER_OTLP_HEADERS`
* `ELASTIC_APM_SERVER_URL`
* `ELASTIC_APM_SECRET_TOKEN`

```
withOtelEnv() {
Expand All @@ -17,3 +19,5 @@ environment variables:
```

* credentialsId: the name of the credentials. Optional.

**NOTE**: It requires the [OpenTelemetry plugin](https://plugins.jenkins.io/opentelemetry")