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

Pipeline dir('foo') block creates foo? folder

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      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.

        Attachments

          Activity

          Hide
          abayer Andrew Bayer added a comment -

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

          Show
          abayer Andrew Bayer added a comment - Are you running this inside a Docker container as the agent?
          Hide
          mohit_dharamshi Mohit Dharamshi added a comment -

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

          Show
          mohit_dharamshi Mohit Dharamshi added a comment - No, job is running on master and Jenkins is running using native command: java -jar jenkins.war
          Hide
          mohit_dharamshi 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

          Show
          mohit_dharamshi 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
          Hide
          abayer Andrew Bayer added a comment -

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

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

            People

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

              Dates

              • Created:
                Updated:
                Resolved: