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

WORKSPACE not defined properly when node steps are nested inside other node steps

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • kubernetes-plugin
    • jenkins 2.387.1
      kubernetes plugin 3900.va_dce992317b_4

      we have a linux node and some k8s defined. no relation between them or their file systems.

      we have a scripted pipeline which looks like this:

      node("some_linux_node")
      {
          println "pwd = " + pwd()
          println "env.WORKSPACE = " + env.WORKSPACE
          podTemplate(/define any container you want here... DON'T specify the workspace path/)
          {
              println "pwd = " + pwd()         
              println "env.WORKSPACE = " + env.WORKSPACE /// here we think there is a problem...     
          }
      }
      

      the output of this looks like:

      pwd = /workspace_on_node

      env.WORKSPACE = /workspace_on_node

      pwd = /workspace_inside_container

      env.WORKSPACE = /workspace_on_node

       

      I expected the last line to show the exact same location as the third line (pwd in the container).

      I expect that the podTemplate scope, once running, should set the env.WORKSPACE variable to the actual workspace, and only when the scope ends, the value returns to be the one it was before (on the node...).

      the behavior we expect is what we see when hopping between nodes (node section inside another node section).

          [JENKINS-70883] WORKSPACE not defined properly when node steps are nested inside other node steps

          Mark Waite added a comment - - edited

          Nested node steps are reported to have unexpected behaviors. I believe you can avoid that problem by choosing to not nest the node steps. If that's not workable for you, then you may need to submit a pull request to the affected plugin to resolve the unexpected behavior.

          Mark Waite added a comment - - edited Nested node steps are reported to have unexpected behaviors. I believe you can avoid that problem by choosing to not nest the node steps. If that's not workable for you, then you may need to submit a pull request to the affected plugin to resolve the unexpected behavior.

            Unassigned Unassigned
            amidar Amit Dar
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: