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

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

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Minor
    • Resolution: Fixed
    • kubernetes-plugin
    • None
    • Jenkins 2.32.1
      pipeline 2.4
      kubernetes-plugin 0.10

    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

            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.
            csanchez can you please add at least basic steps on how to configure integration test environment for this plugin?

            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. csanchez can you please add at least basic steps on how to configure integration test environment for this plugin?

            OK. It runs out of the box with minikube.

            electroma Roman Safronov added a comment - OK. It runs out of the box with minikube.
            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.

            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.
            electroma Roman Safronov added a comment - PR#146
            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

            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

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

              Dates

                Created:
                Updated:
                Resolved: