Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing global environment variables in Jenkins and must be inherited to each Jenkins slave #624

Closed
sourabhsharma-devsecops-specialist opened this issue May 16, 2022 · 6 comments
Labels
bug Something isn't working

Comments

@sourabhsharma-devsecops-specialist

Describe the bug

Using this Helm chart, I've been trying to enable/set the Global environment variables in Jenkins (as attached) such as proxy details etc..

By setting up the environment variables under Global properties in Jenkins configuration section, this helps to get those environments values for all the Jenkins slave automatically.

Screen Shot 2022-05-16 at 8 37 00 PM

Version of Helm and Kubernetes

- Helm: v3.8.2
- Kubernetes: v1.23.6

Chart version

jenkins-2.329

What happened?

No response

What you expected to happen?

Set the environment variables globally which must be inherited to each Jenkins slave such as proxy details etc...

How to reproduce it

No response

Anything else we need to know?

No response

@sourabhsharma-devsecops-specialist sourabhsharma-devsecops-specialist added the bug Something isn't working label May 16, 2022
@timja
Copy link
Member

timja commented May 16, 2022

How is this related to the helm chart?

Your question isn't very clear but I would suggest posting on https://community.jenkins.io instead

@sourabhsharma-devsecops-specialist
Copy link
Author

sourabhsharma-devsecops-specialist commented May 17, 2022

@timja - I am using this helm chart and want to enable the environment variable globally by the code and not from the UI. So can you suggest, how this is possible using this helm chart.

Manually, I am able to add the environment variables in global properties section under Jenkins configuration but not working with helm.

I tried to update values.yaml as below:

initContainerEnv: - name: SOMENAME value: "SOMEVALUE" containerEnv: - name: SOMENAME value: "SOMEVALUE"

@timja
Copy link
Member

timja commented May 17, 2022

Use the configuration as code plugin

You can configure it and then export the configuration using the export functionality:
https://github.com/jenkinsci/configuration-as-code-plugin/blob/master/docs/features/configExport.md

and then add it to the configuration as code support in the helm chart:
https://github.com/jenkinsci/helm-charts/tree/main/charts/jenkins#configuration-as-code

@sourabhsharma-devsecops-specialist

@timja : JCasC suggestion worked perfectly fine for my use cases. Thanks for your quick response.

@jimsnab
Copy link

jimsnab commented Jul 26, 2022

@timja comment above is excellent and helped me understand the way of converting manual configuration to helm chart values.yaml.

Just so others know they are on track, my working global variable config looks like this in my values.yaml:

controller:
  JCasC:
    # The inner name like 'global-vars' is your choice, but it ends up in a configmap
    # key and must be lowercase alphanumeric with optional middle dashes and dots.
    # (See RFC 1123 subdomain naming rules for precise details.)

    configScripts:
      global-vars: |
        jenkins:
          globalNodeProperties:
          - envVars:
              env:
              - key: "PROJECT_NAME"
                value: "${project_name}"
              - key: "ARTEFACT_SERVER"
                value: "${harbor_dns_name_full}"
              - key: "DEPLOYMENT_SERVER"
                value: "${argocd_dns_name_full}"

@madhubala2022
Copy link

@jimsnab --- Thanks for sharing your values.yaml. It worked :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants