Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-53404

Environment variables difficult to set when using Debian Jenkins distribution

    Details

    • Type: Improvement
    • Status: Open (View Workflow)
    • Priority: Minor
    • Resolution: Unresolved
    • Component/s: packaging
    • Labels:
      None
    • Environment:
      Ubuntu 14.04 and 18.04
    • Similar Issues:

      Description

      Setting environment variables (to be used by plugins for example) is not easy when Jenkins is installed with the debian packaging.

      Use case: in order to configure the various options for the Jenkins Configuration As Code (JCasC), environment variables must be set. 

       

      Problem statement:

      While most of the parameters for the Jenkins Daemon are set via the /etc/defaults/jenkins file, it is not possible to set environment variables through that mechanism. The only way is to create/update the .profile in the jenkins user home directory. This is counter-intuitive.

       

      Expected behavior:

      Setting an option in {{/etc/defaults/}}jenkins will result in the environment variable to be loaded in Jenkins  (thus displayed in the "Manage Jenkins"-> "System Information").

       

      Technical discussion:

      As can be seen in the sources of the startup script (https://github.com/jenkinsci/packaging/blob/master/deb/build/debian/jenkins.init), the loading of the daemon's environment is done by setting the --env parameter in the DAEMON_ARGS. There is no mechanism to add options defined in the /etc/defaults/jenkins to the DAEMON_ARGS.

      The hard-coded --inherit makes it possible to load environment variables defined in the user (aka jenkins user) impersonated to start the daemon. This is why setting variables in the .profile of the jenkins user works.

       

      Solution proposal

      • (quick win): add a comment in the /etc/defaults/jenkins (https://github.com/jenkinsci/packaging/blob/master/deb/build/debian/jenkins.default) explaining that to set an environment variable, it is necessary to add a line like export myVar="the value of the variable" in the .config located in the jenkins user home directory.
      • implement a mechanism to add Daemon launch parameters (or just environment variables) from the /etc/defaults/jenkins file.

        Attachments

          Activity

          There are no comments yet on this issue.

            People

            • Assignee:
              kohsuke Kohsuke Kawaguchi
              Reporter:
              jm_meessen Jean-Marc Meessen
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: