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

workflow-plugin: 'env' before 'sh' will hang 'sh'

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Critical Critical
    • pipeline
    • None
    • Jenkins LTS 1.580.3
      (master) Ubuntu Trusty 14.04, all updates
      (slave) Windows Server 2012 x64
      Oracle JDK 1.7.1_71

      Using the workflow-plugin the 'sh' task hangs after an 'env' task call, even when the 'env' is on a different node. Here's a real example that hangs on the 'sh' call:

      node('windows-doc') {
          echo "On my Windows slave"
          env.PATH = "C:\\Program Files (x86)\\MadCap Software\\MadCap Flare V10\\Flare.app;%PATH%"
      }
      
      node('master') {
          echo "On master"
          sh "ls -l"
      }
      

      Remove the 'env.PATH' from that, and it will not hang.

          [JENKINS-27105] workflow-plugin: 'env' before 'sh' will hang 'sh'

          smarmit created issue -
          smarmit made changes -
          Description Original: Using the workflow-plugin the 'sh' task hangs after an 'env' task call, even when the 'env' is on a different node. Here's a real example that hangs on the 'sh' call:

          ---
          node('windows-doc') {
              echo "On my Windows slave"
              env.PATH = "C:\\Program Files (x86)\\MadCap Software\\MadCap Flare V10\\Flare.app;%PATH%"
          }

          node('master') {
              echo "On master"
              sh "ls -l"
          }
          ---

          Remove the 'env.PATH' from that, and it will not hang.
          New: Using the workflow-plugin the 'sh' task hangs after an 'env' task call, even when the 'env' is on a different node. Here's a real example that hangs on the 'sh' call:

          {code}
          node('windows-doc') {
              echo "On my Windows slave"
              env.PATH = "C:\\Program Files (x86)\\MadCap Software\\MadCap Flare V10\\Flare.app;%PATH%"
          }

          node('master') {
              echo "On master"
              sh "ls -l"
          }
          {code}

          Remove the 'env.PATH' from that, and it will not hang.
          Jesse Glick made changes -
          Link New: This issue duplicates JENKINS-26105 [ JENKINS-26105 ]

          Jesse Glick added a comment -

          This is a user error which is not reported gracefully, as noted in JENKINS-26105. env is global to the flow build, not block-scoped (see JENKINS-26128), so by the time the sh step is run it is given a $PATH which does not include /bin and thus the sh executable is not found.

          For this reason the Workflow tutorial does not advocate using env for anything machine-specific (like file paths) if you are using multiple nodes. Use fully-qualified executable names instead.

          Jesse Glick added a comment - This is a user error which is not reported gracefully, as noted in JENKINS-26105 . env is global to the flow build, not block-scoped (see JENKINS-26128 ), so by the time the sh step is run it is given a $PATH which does not include /bin and thus the sh executable is not found. For this reason the Workflow tutorial does not advocate using env for anything machine-specific (like file paths) if you are using multiple nodes. Use fully-qualified executable names instead.
          Jesse Glick made changes -
          Link New: This issue duplicates JENKINS-26128 [ JENKINS-26128 ]
          Jesse Glick made changes -
          Resolution New: Duplicate [ 3 ]
          Status Original: Open [ 1 ] New: Resolved [ 5 ]

          smarmit added a comment -

          Great, thank you. I didn't pick that up in the tutorial. That is the exact workaround I found. Thanks!

          smarmit added a comment - Great, thank you. I didn't pick that up in the tutorial. That is the exact workaround I found. Thanks!
          R. Tyler Croy made changes -
          Workflow Original: JNJira [ 161298 ] New: JNJira + In-Review [ 196707 ]
          Andrew Bayer made changes -
          Component/s New: pipeline-general [ 21692 ]
          Andrew Bayer made changes -
          Component/s Original: workflow-plugin [ 18820 ]

            jglick Jesse Glick
            smarmit smarmit
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: