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

"dir" context is not honored by "sh" step

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Minor
    • Resolution: Fixed
    • Component/s: kubernetes-plugin
    • Labels:
      None
    • Environment:
      Jenkins 2.32.1
      pipeline 2.4
      kubernetes-plugin 0.10
    • Similar Issues:

      Description

      If pipeline has dir wrapper, i.e.

      podTemplate(...) {
        node('pod') {
          container('mycontainer') {
            dir('my/dir/path') {
              sh 'ls -l'
            }
          }
        }
      }
      

      shell step is still executed in the context of workspace root.
      Same pipeline works as expected (within directory path specified by dir step) outside of kubernetes pod.

        Attachments

          Issue Links

            Activity

            Hide
            electroma Roman Safronov added a comment - - edited

            I'm looking at the code of org.jenkinsci.plugins.workflow.steps.PushdStep.Execution#start and org.csanchez.jenkins.plugins.kubernetes.pipeline.ContainerExecDecorator#decorate and it look like context is just ignored by LauncherDecorator.

            I want to try to fix this issue.
            Carlos Sanchez can you please add at least basic steps on how to configure integration test environment for this plugin?

            Show
            electroma Roman Safronov added a comment - - edited I'm looking at the code of org.jenkinsci.plugins.workflow.steps.PushdStep.Execution#start and org.csanchez.jenkins.plugins.kubernetes.pipeline.ContainerExecDecorator#decorate and it look like context is just ignored by LauncherDecorator. I want to try to fix this issue. Carlos Sanchez can you please add at least basic steps on how to configure integration test environment for this plugin?
            Hide
            electroma Roman Safronov added a comment -

            OK. It runs out of the box with minikube.

            Show
            electroma Roman Safronov added a comment - OK. It runs out of the box with minikube.
            Hide
            electroma Roman Safronov added a comment - - edited

            So, it looks like hudson.Launcher.ProcStarter#pwd() provides correct path including "dir" context.
            It is available in org.csanchez.jenkins.plugins.kubernetes.pipeline.ContainerExecDecorator.

            Is there a reason not to use it?
            If not I can make PR with change and test.

            Show
            electroma Roman Safronov added a comment - - edited So, it looks like hudson.Launcher.ProcStarter#pwd() provides correct path including "dir" context. It is available in org.csanchez.jenkins.plugins.kubernetes.pipeline.ContainerExecDecorator. Is there a reason not to use it? If not I can make PR with change and test.
            Hide
            electroma Roman Safronov added a comment -
            Show
            electroma Roman Safronov added a comment - PR#146
            Hide
            jknurek J Knurek added a comment -

            should this already be closed if v0.11 (the current released version) doesn't contain the fix? Isn't Resolved the proper status? 

            or in other words, can we get 0.12 built

            Show
            jknurek J Knurek added a comment - should this already be closed if v0.11 (the current released version) doesn't contain the fix? Isn't Resolved the proper status?  or in other words, can we get 0.12 built

              People

              • Assignee:
                csanchez Carlos Sanchez
                Reporter:
                electroma Roman Safronov
              • Votes:
                1 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: