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

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

XMLWordPrintable

    • 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).

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

              Created:
              Updated: