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

P4 Plugin update 1.8.7 breaks against workspaces using the $JOB_NAME variable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Blocker Blocker
    • p4-plugin

      Upgraded to 1.8.7 and this has broken all jobs on our instance which use the JOB_NAME variable for workspace name/mapping.

      Looking at the failed jobs, I can see that the ${JOB_NAME} variable used for both the Workspace name and list of mappings is being treated differently.

      Consider the output below.

      p4 client -o syd_jenkins_NightlyTesting-BUILD_COMPILER-clang-3.5.0
      
      ... p4 client -i +
      P4: Unable to setup workspace: com.perforce.p4java.exception.RequestException: Error in client specification.
      Mapping '//syd_jenkins_NightlyTesting/BUILD_COMPILER=clang-3.5.0/...' is not under '//syd_jenkins_NightlyTesting-BUILD_COMPILER-clang-3.5.0/...'.
      
      

      The job configuration contains a workspace name of {{syd_jenkins_\$
      {JOB_NAME} }}and there are a list of mappings for this workspace that take the form of:

      //Depot/core/dummy/... //syd_jenkins_${JOB_NAME}/...

       

      From the output above, I believe the expansion of the JOB_NAME variable is treated differently within the two fields, rendering the 1.8.7 release of the P4 plugin unusable for anyone running in this manner.

      I have downgraded to 1.8.6 in the interim and this has resolved the issue.

          [JENKINS-50393] P4 Plugin update 1.8.7 breaks against workspaces using the $JOB_NAME variable

          da5id_, thanks for raising this issue. Are you paying perforce customer? If yes, would you raise this through the support channel as well please? This would ensure a better traction.

          W Basu Perforce added a comment - da5id_ , thanks for raising this issue. Are you paying perforce customer? If yes, would you raise this through the support channel as well please? This would ensure a better traction.

          Confirmed this happens for us as well with 1.8.7 and we had to downgrade to 1.8.6.  It would appear that folder paths, in particular, are not escaped properly in the workspace name (but still escape properly in the client spec).  Workspace names are not properly converting the job_name of a folder, which will have a path style syntax with "/" for folder breaks, into "-" hyphen's which was the traditional behavior.  It still works for the clientspec however.

          This effectively breaks anyone using jobs in folders. For us this occurred trying to load global libraries for a pipeline in the folder global library config, but we can repro it at the job level as well. 

          Maxfield Stewart added a comment - Confirmed this happens for us as well with 1.8.7 and we had to downgrade to 1.8.6.  It would appear that folder paths, in particular, are not escaped properly in the workspace name (but still escape properly in the client spec).  Workspace names are not properly converting the job_name of a folder, which will have a path style syntax with "/" for folder breaks, into "-" hyphen's which was the traditional behavior.  It still works for the clientspec however. This effectively breaks anyone using jobs in folders. For us this occurred trying to load global libraries for a pipeline in the folder global library config, but we can repro it at the job level as well. 

          Paul Allen added a comment -

          The only significant change introduced in 1.8.7 was from pull request https://github.com/jenkinsci/p4-plugin/pull/70

          Paul Allen added a comment - The only significant change introduced in 1.8.7 was from pull request https://github.com/jenkinsci/p4-plugin/pull/70

          Karl Wirth added a comment - - edited

          Confirm reproduction steps
          (1) Create a Folder

          (2) Create Freestyle johb under folder

          (3) Use recomended workspace naming convention 'jenkins-${NODE_NAME}${JOB_NAME}${EXECUTOR_NUMBER}' when setting up Perforce connection.

          (4) 'Build Now'

          Error as mentioned above is because the folder is part of the JOB_NAME but in the name '/' is replaced with '-' but not in the view:

          ERROR: P4: Unable to setup workspace: com.perforce.p4java.exception.RequestException: Error in client specification.
          Mapping '//jenkins-master-Folder2/FreestyleUnderFolder-1/...' is not under '//jenkins-master-Folder2-FreestyleUnderFolder-1/...'.
          

          Karl Wirth added a comment - - edited Confirm reproduction steps (1) Create a Folder (2) Create Freestyle johb under folder (3) Use recomended workspace naming convention 'jenkins-${NODE_NAME} ${JOB_NAME} ${EXECUTOR_NUMBER}' when setting up Perforce connection. (4) 'Build Now' Error as mentioned above is because the folder is part of the JOB_NAME but in the name '/' is replaced with '-' but not in the view: ERROR: P4: Unable to setup workspace: com.perforce.p4java.exception.RequestException: Error in client specification. Mapping ' //jenkins-master-Folder2/FreestyleUnderFolder-1/...' is not under '//jenkins-master-Folder2-FreestyleUnderFolder-1/...' .

          Michael Rose added a comment - - edited

          I just ran into a similar issue that occurs with pipeline jobs.

          Michael Rose added a comment - - edited I just ran into a similar issue that occurs with pipeline jobs.

          Michael Rose added a comment -

          In my case, I switched from ${JOB_NAME} to ${JOB_BASE_NAME} as a short-term fix.

          Michael Rose added a comment - In my case, I switched from ${JOB_NAME} to ${JOB_BASE_NAME} as a short-term fix.

          Code changed in jenkins
          User: Paul Allen
          Path:
          src/main/java/org/jenkinsci/plugins/p4/workspace/ManualWorkspaceImpl.java
          src/test/java/org/jenkinsci/plugins/p4/client/WorkspaceTest.java
          http://jenkins-ci.org/commit/p4-plugin/befa99fd217ab61ca72ae0d0e925b2015c32da6a
          Log:
          Look for the expanded original name when updating the view.

          Added test case for Job names with a '/' restricted character.

          JENKINS-50393

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Paul Allen Path: src/main/java/org/jenkinsci/plugins/p4/workspace/ManualWorkspaceImpl.java src/test/java/org/jenkinsci/plugins/p4/client/WorkspaceTest.java http://jenkins-ci.org/commit/p4-plugin/befa99fd217ab61ca72ae0d0e925b2015c32da6a Log: Look for the expanded original name when updating the view. Added test case for Job names with a '/' restricted character. JENKINS-50393

          Paul Allen added a comment -

          If anyone wants to test the fix the latest build for the HPI file is here:

          https://ci.jenkins.io/job/Plugins/job/p4-plugin/job/master/188/

          Paul Allen added a comment - If anyone wants to test the fix the latest build for the HPI file is here: https://ci.jenkins.io/job/Plugins/job/p4-plugin/job/master/188/

          Paul Allen added a comment -

          Ready for release.

          Paul Allen added a comment - Ready for release.

          Paul Allen added a comment -

          Released in 1.8.8

          Paul Allen added a comment - Released in 1.8.8

            p4paul Paul Allen
            da5id_ David Hows
            Votes:
            3 Vote for this issue
            Watchers:
            10 Start watching this issue

              Created:
              Updated:
              Resolved: