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

environment variable updated in slave's "node properties" works with "Execute Windows batch command", but not with "Execute shell"

    Details

    • Similar Issues:

      Description

      I configure a Windows slave, using "Start Slave as a Windows Service" method. In Node Properties, I add the following entry to update the PATH environment variable to include the Cygwin path (which is not added to the PATH on the slave machine itself):

      Node properties: Environment variables

      List of key-value pairs
      name PATH
      value c:\cygwin\bin;$PATH

      So, this seems to take affect and work as expected when I have a Jenkins job that adds, in the Build section, an entry for "Execute Windows batch command" . My test simply says to do a "set", so that I can look at the PATH, and then a call to Cygwin command from the Cygwin bin directory, namely the "sh" command.

      echo hi 1 from .bat. Do a set to look at path.
      set
      echo hi 2 from .bat after set command showing Cygwin is in the path. Now call Cygwin sh.
      sh -c "echo hi 3 from a Cygwin shell under .bat"
      echo bye, sh call is over.

      As mentioned above, it works as expected , although the PATH variable seems to have been updated with what I asked for twice:
      ---Start
      ....
      Path=c:\cygwin\bin;c:\cygwin\bin;C:\Windows\system32;C:\Windows;... etc
      ....
      c:\cygwin\local\builds\workspace\test shell call to windows cygwin machine>sh -c "echo hi 3 from a Cygwin shell under .bat"
      hi 3 from a Cygwin shell under .bat
      — Done

      However, when I try to execute a sh command directly, via a Build step "Execute shell", I get the following error indicating that the PATH variable does NOT include the update I added.

      [test shell call to windows cygwin machine] $ sh -xe C:\Users\beinfra\AppData\Local\Temp\hudson2056278742015919827.sh
      The system cannot find the file specified
      FATAL: command execution failed
      java.io.IOException: Cannot run program "sh" (in directory "c:\cygwin\local\builds\workspace\test shell call to windows cygwin machine"): CreateProcess error=2, The system cannot find the file specified.

      This is a problem since if I wish to use a multi-configuration job for both Windows and Unix slaves, then the multi-config job needs to execute the same build step "Execute shell" for both Windows and UNIX slaves, and this step does not work for the Windows slave. (I'm also aware of the Xshell plugin, but am not using that for a different reason). If my Windows machine's environment is updated to include the Cygwin\bin in its default path, then the Execute Shell works. I will attach the jobs config.cml, and the log, and the slaves section of Jenkins config.xml

        Attachments

        1. config.xml
          3 kB
        2. log
          7 kB
        3. slave_config.xml
          1 kB

          Activity

          There are no comments yet on this issue.

            People

            • Assignee:
              kohsuke Kohsuke Kawaguchi
              Reporter:
              rickybobpat Rick Patterson
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: