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

Environment variables are not set in init script

    Details

    • Similar Issues:

      Description

      It looks like init-scripts don't get the environment variables defined for a node, or global environment variables defined in the main Configure Jenkins page, injected. At least for EC2 nodes.

      The environment variables are present when running jobs, but not when running init scripts. Even when those environment variables are shown in the "Enviroment Variables" list under "System Information" for a node, an init script that has a line like:

      env > /tmp/init-environ
      

      will print an environment that doesn't include them, and shell substitutions won't use them.

      In case they were set but not exported I tested with:

      set > /tmp/set-environ
      

      but the vars weren't present there either.

      This makes it harder to parameterize init scripts.

      The environment that was set was:

      SHELL=/bin/bash
      TERM=dumb
      USER=root
      SUDO_USER=admin
      SUDO_UID=1000
      USERNAME=root
      MAIL=/var/mail/root
      PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin
      PWD=/home/admin
      SHLVL=1
      SUDO_COMMAND=/tmp/init.sh
      HOME=/root
      LOGNAME=root
      SUDO_GID=1000
      _=/usr/bin/env
      

        Attachments

          Activity

          ringerc Craig Ringer created issue -
          ringerc Craig Ringer made changes -
          Field Original Value New Value
          Description It looks like init-scripts don't get the environment variables defined for a node, or global environment variables defined in the main Configure Jenkins page, injected.

          The environment variables are present when running jobs, but not when running init scripts. Even when those environment variables are shown in the "Enviroment Variables" list under "System Information" for a node, an init script that has a line like:

          {code}
          env > /tmp/init-environ
          {code}

          will print an environment that doesn't include them, and shell substitutions won't use them.

          In case they were set but not exported I tested with:

          {code}
          set > /tmp/set-environ
          {code}

          but the vars weren't present there either.

          This makes it harder to parameterize init scripts.
          It looks like init-scripts don't get the environment variables defined for a node, or global environment variables defined in the main Configure Jenkins page, injected. At least for EC2 nodes.

          The environment variables are present when running jobs, but not when running init scripts. Even when those environment variables are shown in the "Enviroment Variables" list under "System Information" for a node, an init script that has a line like:

          {code}
          env > /tmp/init-environ
          {code}

          will print an environment that doesn't include them, and shell substitutions won't use them.

          In case they were set but not exported I tested with:

          {code}
          set > /tmp/set-environ
          {code}

          but the vars weren't present there either.

          This makes it harder to parameterize init scripts.
          ringerc Craig Ringer made changes -
          Description It looks like init-scripts don't get the environment variables defined for a node, or global environment variables defined in the main Configure Jenkins page, injected. At least for EC2 nodes.

          The environment variables are present when running jobs, but not when running init scripts. Even when those environment variables are shown in the "Enviroment Variables" list under "System Information" for a node, an init script that has a line like:

          {code}
          env > /tmp/init-environ
          {code}

          will print an environment that doesn't include them, and shell substitutions won't use them.

          In case they were set but not exported I tested with:

          {code}
          set > /tmp/set-environ
          {code}

          but the vars weren't present there either.

          This makes it harder to parameterize init scripts.
          It looks like init-scripts don't get the environment variables defined for a node, or global environment variables defined in the main Configure Jenkins page, injected. At least for EC2 nodes.

          The environment variables are present when running jobs, but not when running init scripts. Even when those environment variables are shown in the "Enviroment Variables" list under "System Information" for a node, an init script that has a line like:

          {code}
          env > /tmp/init-environ
          {code}

          will print an environment that doesn't include them, and shell substitutions won't use them.

          In case they were set but not exported I tested with:

          {code}
          set > /tmp/set-environ
          {code}

          but the vars weren't present there either.

          This makes it harder to parameterize init scripts.

          The environment that was set was:

          {code}
          SHELL=/bin/bash
          TERM=dumb
          USER=root
          SUDO_USER=root
          SUDO_UID=0
          USERNAME=root
          MAIL=/var/mail/root
          PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin
          PWD=/home/admin
          DEBIAN_PRIORITY=critical
          SHLVL=1
          SUDO_COMMAND=/bin/bash
          HOME=/root
          LOGNAME=root
          DEBIAN_FRONTEND=noninteractive
          SUDO_GID=0
          _=/usr/bin/env
          {code}
          ringerc Craig Ringer made changes -
          Labels ec2 environment environment-variables init-script
          Description It looks like init-scripts don't get the environment variables defined for a node, or global environment variables defined in the main Configure Jenkins page, injected. At least for EC2 nodes.

          The environment variables are present when running jobs, but not when running init scripts. Even when those environment variables are shown in the "Enviroment Variables" list under "System Information" for a node, an init script that has a line like:

          {code}
          env > /tmp/init-environ
          {code}

          will print an environment that doesn't include them, and shell substitutions won't use them.

          In case they were set but not exported I tested with:

          {code}
          set > /tmp/set-environ
          {code}

          but the vars weren't present there either.

          This makes it harder to parameterize init scripts.

          The environment that was set was:

          {code}
          SHELL=/bin/bash
          TERM=dumb
          USER=root
          SUDO_USER=root
          SUDO_UID=0
          USERNAME=root
          MAIL=/var/mail/root
          PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin
          PWD=/home/admin
          DEBIAN_PRIORITY=critical
          SHLVL=1
          SUDO_COMMAND=/bin/bash
          HOME=/root
          LOGNAME=root
          DEBIAN_FRONTEND=noninteractive
          SUDO_GID=0
          _=/usr/bin/env
          {code}
          It looks like init-scripts don't get the environment variables defined for a node, or global environment variables defined in the main Configure Jenkins page, injected. At least for EC2 nodes.

          The environment variables are present when running jobs, but not when running init scripts. Even when those environment variables are shown in the "Enviroment Variables" list under "System Information" for a node, an init script that has a line like:

          {code}
          env > /tmp/init-environ
          {code}

          will print an environment that doesn't include them, and shell substitutions won't use them.

          In case they were set but not exported I tested with:

          {code}
          set > /tmp/set-environ
          {code}

          but the vars weren't present there either.

          This makes it harder to parameterize init scripts.

          The environment that was set was:

          {code}
          SHELL=/bin/bash
          TERM=dumb
          USER=root
          SUDO_USER=admin
          SUDO_UID=1000
          USERNAME=root
          MAIL=/var/mail/root
          PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin
          PWD=/home/admin
          SHLVL=1
          SUDO_COMMAND=/tmp/init.sh
          HOME=/root
          LOGNAME=root
          SUDO_GID=1000
          _=/usr/bin/env
          {code}
          rtyler R. Tyler Croy made changes -
          Workflow JNJira [ 156728 ] JNJira + In-Review [ 179370 ]
          thoulen FABRIZIO MANFREDI made changes -
          Issue Type Bug [ 1 ] New Feature [ 2 ]

            People

            • Assignee:
              francisu Francis Upton
              Reporter:
              ringerc Craig Ringer
            • Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated: