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

Environment variable with path ending in single letter is not expanded correctly in custom workspace

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • p4-plugin
    • None
    • Master runs Windows, slave runs Linux, Hudson ver is 1.351, Perforce plugin ver is 1.0.24

      We run our builds on networked drives, but have artefacts and history on a local drive. This means that we rely on custom workspaces to put the builds onto the network.
      In order to map correctly from both Windows and Linux slaves (some builds don't care), we use an environment variable to indicate the root of the filesystems (aka "drive").
      On Windows slaves, this variable (e.g. "N") will contain the drive letter ("N:"), on Linux slaves it will look like "/mnt/drive/N". The job then has a custom workspace looking like "${N}/hudson/workspace/my-job".
      It all works fine on Windows slaves, but doesn't on Linux slaves.
      The Hudson core correctly expands this variable to "/mnt/drive/N/hudson/workspace/my-job" and starts working, but the job fails as soon as the Perforce plugin attempts to sync, because it has set the workspace root to "/mnt/drive/hudson/workspace/my-job" (note the lack of "N" and a slash).
      I tried a couple of combinations and have clear indications that this will (only) happen if the last component of the path is a single letter. These values work fine: /mnt/drive/NN, /mnt/drive/Drive. Both /mnt/drive/N and /mnt/drive/n fail.
      I have worked around it with a symlink, but it's Not Great and requires that I remember this on any new slaves.

          [JENKINS-6064] Environment variable with path ending in single letter is not expanded correctly in custom workspace

          Rob Petti added a comment -

          There was a similar issue logged here for this, but it was for the more general case when a path element was only one character. Can you try setting the custom workspace path to something that doesn't contain a parameter, ie. /mnt/drive/N/hudson/workspace. That'll let me know if it's a problem with substitution, or something else.

          Rob Petti added a comment - There was a similar issue logged here for this, but it was for the more general case when a path element was only one character. Can you try setting the custom workspace path to something that doesn't contain a parameter, ie. /mnt/drive/N/hudson/workspace. That'll let me know if it's a problem with substitution, or something else.

          Rob Petti added a comment -

          Nevermind, I found it. It appears that there is code for removing '/./' from the path, but the person who wrote the code didn't realize they were using a regex, so '/./' matches any 1 character long path element...

          Rob Petti added a comment - Nevermind, I found it. It appears that there is code for removing '/./' from the path, but the person who wrote the code didn't realize they were using a regex, so '/./' matches any 1 character long path element...

          Code changed in hudson
          User: : rpetti
          Path:
          trunk/hudson/plugins/perforce/src/main/java/hudson/plugins/perforce/PerforceSCM.java
          http://jenkins-ci.org/commit/29235
          Log:
          [FIXED JENKINS-6064] fixed regex used on workspace root path to remove only '/./' and not '/[ANYCHARACTER]/'

          SCM/JIRA link daemon added a comment - Code changed in hudson User: : rpetti Path: trunk/hudson/plugins/perforce/src/main/java/hudson/plugins/perforce/PerforceSCM.java http://jenkins-ci.org/commit/29235 Log: [FIXED JENKINS-6064] fixed regex used on workspace root path to remove only '/./' and not '/ [ANYCHARACTER] /'

          torbent added a comment -

          Verified as working in plugin version 1.0.26

          torbent added a comment - Verified as working in plugin version 1.0.26

            rpetti Rob Petti
            torbent torbent
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: