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

Cannot sync into workspaces with '@' in their path

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • p4-plugin
    • Jenkins 1.618
      Workflow 1.8
      P4 Plugin 1.2.4

      Attempting to sync into a workspace that contains '@' in the path fails:

      p4 client -i

      Error in client specification.
      Embedded special characters (*, %%, #, @) not allowed in 'd:\jenkins\workspace\workflow_test_parallel@2'.

      This is particularly an issue for workflow-plugin as it tends to append '@' to workspace paths such as the path used by the 'Store DSL script in SCM' ('@script'), and the second and later workspaces for a particular build script on a node ('@2', '@3', ...)

          [JENKINS-29387] Cannot sync into workspaces with '@' in their path

          Joel Brown added a comment -

          Somewhat related: JENKINS-25242. Same issue with "@" in the path.

          Joel Brown added a comment - Somewhat related: JENKINS-25242 . Same issue with "@" in the path.

          A workaround is mentioned in JENKINS-14354, referenced from JENKINS-25242, is to change a system property to use a different specifier for the extra workspaces: -Dhudson.slaves.WorkspaceList=_.

          The current discussion in JENKINS-25242 indicates that this problem is also the reason for that issue, so when that is resolved, this issue will either be resolved or turn out to be a workflow-plugin issue (if it doesn't honour that system property for some reason).

          Paul "TBBle" Hampson added a comment - A workaround is mentioned in JENKINS-14354 , referenced from JENKINS-25242 , is to change a system property to use a different specifier for the extra workspaces: -Dhudson.slaves.WorkspaceList=_ . The current discussion in JENKINS-25242 indicates that this problem is also the reason for that issue, so when that is resolved, this issue will either be resolved or turn out to be a workflow-plugin issue (if it doesn't honour that system property for some reason).

          Code changed in jenkins
          User: Paul Allen
          Path:
          src/main/java/org/jenkinsci/plugins/p4/PerforceScm.java
          http://jenkins-ci.org/commit/p4-plugin/f6727b45c5534741ed6f928b6dd583ef92a2f27f
          Log:
          Create a template workspace for parallel builds.

          If Jenkins attempts a parallel build it creates a workspace@2
          directory. This change creates a new template workspace (appended with
          .clone2) and substitutes the `@` to `%40` in the root path.

          JENKINS-29387

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Paul Allen Path: src/main/java/org/jenkinsci/plugins/p4/PerforceScm.java http://jenkins-ci.org/commit/p4-plugin/f6727b45c5534741ed6f928b6dd583ef92a2f27f Log: Create a template workspace for parallel builds. If Jenkins attempts a parallel build it creates a workspace@2 directory. This change creates a new template workspace (appended with .clone2) and substitutes the `@` to `%40` in the root path. JENKINS-29387

          Paul Allen added a comment -

          Fixed 1.3.1

          Paul Allen added a comment - Fixed 1.3.1

          Jay Spang added a comment -

          p4paul sorry to bump a very old issue, but how can I use your fix when I'm using raw p4groovy to do more advanced stuff?

          I have a function called get_synced_changelist() that does exactly what the name implies. This code works fine except if the job runs on an executor other than 0. If that happens, Jenkins appends '@2'  to the workspace and p4groovy crashes when it tries to use that as the workspace root.

          Unless I'm missing something, I don't see any way to specify the client's root at the time of instantiation, so I don't know how to avoid this bug.

          Here's the code. The best way to repro this is to pin your job to a certain node, then Build it rapidly a few times (ensuring concurrent builds). Any build NOT on the first executor will fail.

           
          def get_synced_changelist(String p4_credential_name, String client_name, String p4_stream) {
              def ws = [$class: 'StreamWorkspaceImpl', charset: 'none', format: client_name, pinHost: false, streamName: p4_stream]
              def p4 = p4(credential: p4_credential_name, workspace: ws)
              changelist = p4.run( 'changes', '-m1', "@"+ p4.getClientName() )    
              return changelist[0].change
          }
           
          get_synced_changelist('p4tools', 'jenkins-${NODE_NAME}${JOB_NAME}${EXECUTOR_NUMBER}', '//depot/stream_name')
           
           
           
           

          Jay Spang added a comment - p4paul sorry to bump a very old issue, but how can I use your fix when I'm using raw p4groovy to do more advanced stuff? I have a function called get_synced_changelist()  that does exactly what the name implies. This code works fine  except  if the job runs on an executor other than 0. If that happens, Jenkins appends '@2'  to the workspace and p4groovy crashes when it tries to use that as the workspace root. Unless I'm missing something, I don't see any way to specify the client's root at the time of instantiation, so I don't know how to avoid this bug. Here's the code. The best way to repro this is to pin your job to a certain node, then Build it rapidly a few times (ensuring concurrent builds). Any build NOT on the first executor will fail.   def get_synced_changelist(String p4_credential_name, String client_name, String p4_stream) {     def ws = [$class: 'StreamWorkspaceImpl', charset: 'none', format: client_name, pinHost: false, streamName: p4_stream]     def p4 = p4(credential: p4_credential_name, workspace: ws)     changelist = p4.run( 'changes', '-m1', "@"+ p4.getClientName() )          return changelist [0] .change }   get_synced_changelist('p4tools', 'jenkins-${NODE_NAME} ${JOB_NAME} ${EXECUTOR_NUMBER}', '//depot/stream_name')        

          Joel Brown added a comment -

          jayspang you wrote "Jenkins appends '@2'  to the workspace"

          Does the above -Dhudson.slaves.WorkspaceList=_ help out as an alternative char to the "@"?  That should obviate the need for the escaping Paul did.

          Joel Brown added a comment - jayspang you wrote "Jenkins appends '@2'  to the workspace" Does the above -Dhudson.slaves.WorkspaceList=_ help out as an alternative char to the "@"?  That should obviate the need for the escaping Paul did.

          Jay Spang added a comment -

          joel_brown I'm a bit reluctant to change a whole system property to fix this issue, but if p4paul says there's no easy way to do this with p4groovy, I'll definitely give that a try!

          Jay Spang added a comment - joel_brown I'm a bit reluctant to change a whole system property to fix this issue, but if p4paul says there's no easy way to do this with p4groovy, I'll definitely give that a try!

          Paul Allen added a comment -

          If you want to list changes limited by the 'view' of a client workspace use 'client syntax' e.g:

          changelist = p4.run( 'changes', '-m1', "//" + p4.getClientName() + "/..." )

          If you use the "//...@workspace" revision specifier then you are only listing the changes that are in the 'have' list for that workspaces.  If the workspace has never been synced then the have list will be empty and your script will have an empty array:
          java.lang.ArrayIndexOutOfBoundsException: 0

          Paul Allen added a comment - If you want to list changes limited by the 'view' of a client workspace use 'client syntax' e.g: changelist = p4.run( 'changes' , '-m1' , " //" + p4.getClientName() + "/..." ) If you use the "//...@workspace" revision specifier then you are only listing the changes that are in the 'have' list for that workspaces.  If the workspace has never been synced then the have list will be empty and your script will have an empty array: java.lang.ArrayIndexOutOfBoundsException: 0

            Unassigned Unassigned
            p_hampson Paul "TBBle" Hampson
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: