question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Merging global node environment variables from multiple config files

See original GitHub issue

Your checklist for this issue

  • Jenkins version 2.223
  • Plugin version 1.35
  • OS Ubuntu 18.04

Description

When having multiple .casc files to configure different aspects of Jenkins, if multiple files have global environment variables configuration, they are not merged, but stored as a separate envVars sections:

config1.yaml

jenkins:
  globalNodeProperties:
  - envVars:
      env:
      - key: VARIABLE1
        value: foo

config2.yaml

jenkins:
  globalNodeProperties:
  - envVars:
      env:
      - key: VARIABLE2
        value: bar

resulting config in Jenkins:

jenkins:
  globalNodeProperties:
  - envVars:
      env:
      - key: VARIABLE1
        value: foo
  - envVars:
      env:
      - key: VARIABLE2
        value: bar

While tests show that all variables still end up in environment, when you go to Manage Jenkins -> Configure System, it only shows contents of first “envVars” block.

Expected: all global variables end up in a single “envVars” block thus avoiding visualization problem

jenkins:
  globalNodeProperties:
  - envVars:
      env:
      - key: VARIABLE1
        value: foo
      - key: VARIABLE2
        value: bar

PS It seems that originally it is not expected to have multiple instances of the same type of global node properties descriptors.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
jetersencommented, Aug 25, 2021

The #1218 PR is also adding a merge feature as I understand the PR. See the merge strategy called ErrorOnConflict. It is doing deep merging.

0reactions
DaveB93commented, Aug 5, 2022

I would suggest re-opening this issue as it’s not currently fixed. PR #1218 does not yet support merging

  globalNodeProperties:
  - envVars:

we misread the comments on this issue and the other PR and assumed that we could merge envVars, then spent a bit of time trying to get it to work, then realized it wasn’t fully implemented yet. PR #1218 does support partial merging which is useful.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Merge different config files in environment files - Stack Overflow
I'm trying to have separate config files which I import/merge in the environment files to provide a further global CONFIG object with all ......
Read more >
Working with Environment Variables in Node.js - Twilio
Environment variables are a great way to configure parts of your Node.js application. Learn how to work with them using helpful tools such ......
Read more >
Customizing Node.js .env files - LogRocket Blog
Learn how to configure a Node.js application via environment variables and customize an .env file with new environment variables.
Read more >
Environment Variables .env with Node.js - YouTube
In this edition of Stripe Developer Office Hours, follow along as CJ Avilla walks through the fundamentals of managing environment variables ...
Read more >
Organizing Cluster Access Using kubeconfig Files - Kubernetes
kube/config . If the KUBECONFIG environment variable does exist, kubectl uses an effective configuration that is the result of merging the files ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found