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

Environment variables from setenv plugin are not inherited/parsed by batch tasks

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • batch-task-plugin
    • None
    • Hudson 1.344, Hudson batch task plugin 1.12

      Some last Hudson version brought a new "Set environment variables" field in job configuration.
      This environment variables not inherited or parsed by shell tasks.

      One has to duplicate the needed variables in order to be used in task's script commands.

      Although the job's environment variables are passed, I've only tested these: parameter variables, $WORKSPACE, $JAVA_HOME, $CLEARCASE_VIEWNAME, etc. Global Environment variables set in hudson's configuration are also correctly parsed.

      I don't know if this an issue with tasks or because the "Set environment variables" field is coming after tasks definition in job's configuration view.

      Thanks in advance.


      UPDATED!

          [JENKINS-5580] Environment variables from setenv plugin are not inherited/parsed by batch tasks

          Alan Harder added a comment -

          I made a task with "env" to print env vars.. I see build vars (WORKSPACE and JAVA_HOME) and global vars (from main /configure page) here. I don't see any problem since batch task 1.11 which includes JENKINS-5039 fix.

          Alan Harder added a comment - I made a task with "env" to print env vars.. I see build vars (WORKSPACE and JAVA_HOME) and global vars (from main /configure page) here. I don't see any problem since batch task 1.11 which includes JENKINS-5039 fix.

          hmonteiro added a comment - - edited

          Description updated.

          I don't know if I mistakenly mixed description/report of tickets or something when checking and creating this and other tickets.
          I've writen the description in a way that reports a reverse behaviour that I was noticing and wanted to report here. Description is now corrected.

          hmonteiro added a comment - - edited Description updated. I don't know if I mistakenly mixed description/report of tickets or something when checking and creating this and other tickets. I've writen the description in a way that reports a reverse behaviour that I was noticing and wanted to report here. Description is now corrected.

          hmonteiro added a comment -

          Just a small correction,

          "Set environment variables" field comes from a plugin called "Setenv" and not from Hudson. The plugin is not listed in the selectable "Component/s" field when opening tickets (that's why I mentioned new hudson's field), although I just found it listed as a plugin in plugins wiki page.

          The "Set environment variables" field appears immediately before build steps. I've also opened a ticket regarding this plugin's behaviour, that is, not exporting variables all over job's configuration and only to the execution sections.

          Thanks.

          hmonteiro added a comment - Just a small correction, "Set environment variables" field comes from a plugin called "Setenv" and not from Hudson. The plugin is not listed in the selectable "Component/s" field when opening tickets (that's why I mentioned new hudson's field), although I just found it listed as a plugin in plugins wiki page. The "Set environment variables" field appears immediately before build steps. I've also opened a ticket regarding this plugin's behaviour, that is, not exporting variables all over job's configuration and only to the execution sections. Thanks.

          Code changed in hudson
          User: : mindless
          Path:
          trunk/hudson/plugins/batch-task/pom.xml
          trunk/hudson/plugins/batch-task/src/main/java/hudson/plugins/batch_task/BatchRun.java
          http://jenkins-ci.org/commit/27256
          Log:
          [batch-task] [FIXED JENKINS-5580] Not sure if tasks should use all BuildWrappers
          (xvnc for example), but look specifically for wrapper from setenv plugin and
          apply its env settings.

          SCM/JIRA link daemon added a comment - Code changed in hudson User: : mindless Path: trunk/hudson/plugins/batch-task/pom.xml trunk/hudson/plugins/batch-task/src/main/java/hudson/plugins/batch_task/BatchRun.java http://jenkins-ci.org/commit/27256 Log: [batch-task] [FIXED JENKINS-5580] Not sure if tasks should use all BuildWrappers (xvnc for example), but look specifically for wrapper from setenv plugin and apply its env settings.

          hmonteiro added a comment -

          Hi there,
          Funny that you mentioned xvnc plugin, we also use it to build packages and exporting it's variable to tasks would also be great.
          But like you, I'm also not sure if using all BuildWrappers should interfere or mess with something else that we can't see now. I mean, I only use a specific set of plugins, and could be that some can give strange behaviours because of what you mention.

          Either way, thanks for this fix.

          hmonteiro added a comment - Hi there, Funny that you mentioned xvnc plugin, we also use it to build packages and exporting it's variable to tasks would also be great. But like you, I'm also not sure if using all BuildWrappers should interfere or mess with something else that we can't see now. I mean, I only use a specific set of plugins, and could be that some can give strange behaviours because of what you mention. Either way, thanks for this fix.

          Reopening, since this is not working in Jenkins 1.413, setenv 1.1, and promoted builds 2.1.

          Matthew Webber added a comment - Reopening, since this is not working in Jenkins 1.413, setenv 1.1, and promoted builds 2.1.

            Unassigned Unassigned
            hmonteiro hmonteiro
            Votes:
            2 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated: