when running below

      dir('foo') {

        sh "touch test.txt"

      }

      in workspace I have foo folder what I had checked out, however, pipeline ends up creating a "foo?" adjacent to foo. And the touch operation happens in the "foo?" folder.

      the above snippet is in a global-shared-library.

      I am running Jenkins 2.73.3
      workflow-basic-steps: 2.6

      workflow-cps-global-lib: 2.9

       

      I am running a single build manually so no concurrent builds are being triggered.

          [JENKINS-48128] Pipeline dir('foo') block creates foo? folder

          Andrew Bayer added a comment -

          Are you running this inside a Docker container as the agent?

          Andrew Bayer added a comment - Are you running this inside a Docker container as the agent?

          No, job is running on master and Jenkins is running using native command: java -jar jenkins.war

          Mohit Dharamshi added a comment - No, job is running on master and Jenkins is running using native command: java -jar jenkins.war

          Mohit Dharamshi added a comment - - edited

          Found the root cause:

          The parameter i am providing to the dir() is generated dynamically from a shell script.

          The value returned by the shell script has a new line character at the end.

          if this returned value is fed to the dir(), then operations happen in the foo? directory.

          If the new line character is truncated using .trim() and then fed to dir(), then correct working directory is used.

          Can the plugin be revised to cater for such new line characters or trailing white spaces?

          Changing issue type to improvement

          Mohit Dharamshi added a comment - - edited Found the root cause: The parameter i am providing to the dir() is generated dynamically from a shell script. The value returned by the shell script has a new line character at the end. if this returned value is fed to the dir(), then operations happen in the foo? directory. If the new line character is truncated using .trim() and then fed to dir(), then correct working directory is used. Can the plugin be revised to cater for such new line characters or trailing white spaces? Changing issue type to improvement

          Andrew Bayer added a comment -

          No, we kinda trust you to have handled that already. =) Remember that .trim() is your friend. =)

          Andrew Bayer added a comment - No, we kinda trust you to have handled that already. =) Remember that .trim() is your friend. =)

            Unassigned Unassigned
            mohit_dharamshi Mohit Dharamshi
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: