Template workspace

Template workspaces use a predefined template to generate the workspace view. The name of the workspace is generated using the Workspace Name Format field. Use template workspaces when working with Matrix builds.

The type of a workspace cannot be changed, as P4 Server does not allow changing the type of an existing client workspace. As a result, if you attempt to create a new workspace using an existing name but with a different template type, the P4 for Jenkins will not create the new workspace. To proceed, delete existing workspace with the same name or choose a new name for the new workspace.

Template Workspace Configuration

  1. Workspace behaviour: select Template (view generated for each node) from the dropdown list.
  2. Character Set: sets the character set used by Jenkins when syncing files from the Perforce P4 Server. This should be set to none unless the workspace is connected to a Unicode enabled P4 Server.
  3. Template workspace: specify an existing Perforce workspace that will be used to create or update the Jenkins build workspace. If you are connected to a P4 Server, workspaces will be auto suggested as you type.
  4. Pin the workspace to the build host: this can usually be left unselected because the ${NODE_NAME} variable in the Workspace Name Format field does this for you.
  5. Workspace Name Format: Jenkins agent nodes must each use a unique Perforce workspace. The format string configures the workspace name by substituting the specified variables. At least one variable must be used, but it is recommended that, as a minimum, the following variables are used:
  6. jenkins-${NODE_NAME}-${JOB_NAME}-${EXECUTOR_NUMBER}

    For more information about variables, see Variable Expansion.

    Pipeline:

    • Use a unique workspace name for the Jenkinsfile that will not get reused by the sync steps in the script. A postfix of -script will help to identify the workspace's use and make it unique from code sync steps.
    • Variables in the script for the workspace name must be surrounded by single quotes as shown:

    • name: 'jenkins-${NODE_NAME}-${JOB_NAME}-${EXECUTOR_NUMBER}',

      Using full double quotes " expands the variables early and the script will fail.