Steps to Reproduce:
1. Click "Manage Jenkins" -> Global Properties
2. Create an Environment Variable as follows: name: P4USER value: p4service (or another P4 Username)
3. Select an Existing Job that uses Perforce for Source Code Management
4. Select the Username field and enter "${P4USER}"
Result:
Result: build fails as follows: Started by user Administrator Building in workspace /usr/share/tomcat6/.jenkins/jobs/dpapi-int/workspace Using master perforce client: jenkins-dpapi-int [workspace] $ /usr/local/bin/p4 workspace -o jenkins-dpapi-int Caught exception communicating with perforce. Access for user 'com.tek42.perforce.PerforceException: Access for user ' at com.tek42.perforce.parse.AbstractPerforceTemplate.getPerforceResponse(AbstractPerforceTemplate.java:382) at com.tek42.perforce.parse.AbstractPerforceTemplate.getPerforceResponse(AbstractPerforceTemplate.java:292) at com.tek42.perforce.parse.Workspaces.getWorkspace(Workspaces.java:61) at hudson.plugins.perforce.PerforceSCM.getPerforceWorkspace(PerforceSCM.java:1461) at hudson.plugins.perforce.PerforceSCM.getPerforceWorkspace(PerforceSCM.java:1422) at hudson.plugins.perforce.PerforceSCM.checkout(PerforceSCM.java:793) at hudson.model.AbstractProject.checkout(AbstractProject.java:1256) at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:589) at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:88) at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:494) at hudson.model.Run.execute(Run.java:1502) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46) at hudson.model.ResourceController.execute(ResourceController.java:88) at hudson.model.Executor.run(Executor.java:236) ERROR: Unable to communicate with perforce. Access for user ' Sending e-mails to: eng-n2i@netshelter.com Finished: FAILURE
As you can see by the above: "Caught exception communicating with perforce. Access for user 'com.tek42.perforce.PerforceException: Access for user '"
Use Case:
If a user wishes to use exactly one user for all Jobs that use Perforce for SCM, he could enter this user in the Global Properties and then change the credentials user to poll Perforce at any time across all Jobs.