Getting error message "must create client 'ip-10-21-2-84' to access local files".
It appears when the job is executed on the jenkins slave the P4 client is not being created. Does the p4 plugin create the workspace and manages the workspace view. Or does the p4 plugin require an additional setup that I might be missing.
- Job Configuration: Reference attached job config.xml
- Build log attached.
Note that I also tested the job on a jenkins slave that was not in a container. Got the same error. When I ran 'p4 client' and set-up the root and mapping, the jenkins job worked.
- build.log
- 13 kB
- job-config.xml
- 5 kB
- is caused by
-
JENKINS-62008 Expose P4_CLIENT, P4_USER and P4_PORT as the environment variables P4CLIENT, P4USER and P4PORT for scripts
-
- Open
-
[JENKINS-61943] Jenkins2, P4 Plugin: Error must create client <name>' to access local files
Hi Karl, I really appreciate the quick response to my issue.
What I'm attempting to do is test upgrading our Jenkins1 (v1.651.2) environment to Jenkins2 (v2.222.1) before upgrading our production jenkin server and slaves. I was hoping that the upgrade was simply allowing the new p4@1.10.12 plugin manage the necessary scm class changes to create the p4 client to run the job without having to make additional changes. Note that we are NOT using P4Maven for our Perforce jobs.
Below is a snippet from the jenkins1 job config.xml versus the jenkins2 job config.xml after the upgrade. Note that the jenkins1 job.xml specifies the p4client and the jenkins2 job.xml does NOT . Is there a reason for that? I also attached the jenkins1 job config.xml and build log before the upgrade for your review.
Snippet from the jenkins1 job config.xml 'scm class' for plugin="perforce@1.3.35" BEFORE the upgrade.
The scm class specifies the tag <p4Client>ci-admin-ui-4.2</p4Client> .
<scm class="hudson.plugins.perforce.PerforceSCM" plugin="perforce@1.3.35"> <configVersion>2</configVersion> <p4User>compil</p4User> <p4Passwd>0f0kqlwaRgSE9uduYTPfa3AlrK8xqw==</p4Passwd> <p4Port>p4proxy:1667</p4Port> --> <p4Client>ci-admin-ui-4.2</p4Client> <projectPath>//depot/kernel/04.02/wars/admin-ui/... //ci-admin-ui-4.2/...</projectPath> <projectOptions>noallwrite clobber nocompress unlocked nomodtime rmdir</projectOptions> <p4SysDrive></p4SysDrive> <p4SysRoot></p4SysRoot> <p4Tool>2012.2</p4Tool> <useClientSpec>false</useClientSpec> <useStreamDepot>false</useStreamDepot> <forceSync>false</forceSync> <alwaysForceSync>true</alwaysForceSync> <dontUpdateServer>false</dontUpdateServer> <disableAutoSync>false</disableAutoSync> <disableChangeLogOnly>false</disableChangeLogOnly> <disableSyncOnly>false</disableSyncOnly> <showIntegChanges>false</showIntegChanges> <useOldClientName>false</useOldClientName> <createWorkspace>true</createWorkspace> <updateView>true</updateView> <dontRenameClient>false</dontRenameClient> <updateCounterValue>false</updateCounterValue> <dontUpdateClient>false</dontUpdateClient> <exposeP4Passwd>true</exposeP4Passwd> <wipeBeforeBuild>false</wipeBeforeBuild> <quickCleanBeforeBuild>false</quickCleanBeforeBuild> <restoreChangedDeletedFiles>false</restoreChangedDeletedFiles> <wipeRepoBeforeBuild>false</wipeRepoBeforeBuild> <firstChange>-1</firstChange> <fileLimit>0</fileLimit> <excludedFilesCaseSensitivity>true</excludedFilesCaseSensitivity> <slaveClientNameFormat>${basename}-${hash}</slaveClientNameFormat> <lineEndValue>local</lineEndValue> <useViewMask>false</useViewMask> <useViewMaskForPolling>true</useViewMaskForPolling> <useViewMaskForSyncing>false</useViewMaskForSyncing> <useViewMaskForChangeLog>false</useViewMaskForChangeLog> <pollOnlyOnMaster>false</pollOnlyOnMaster> </scm>
Below is a snippet from the jenkins2 job config.xml 'scm class' plugin="p4@1.10.12" AFTER the upgrade
The new scm class does NOT specify the <p4Client>**
<scm class="org.jenkinsci.plugins.p4.PerforceScm" plugin="p4@1.10.12"> <credential>p4-userpass</credential> <workspace class="org.jenkinsci.plugins.p4.workspace.ManualWorkspaceImpl"> <charset>none</charset> <pinHost>true</pinHost> <cleanup>false</cleanup> <name>jenkins-${NODE_NAME}-${JOB_NAME}-${EXECUTOR_NUMBER}</name> <spec> <allwrite>false</allwrite> <clobber>true</clobber> <compress>false</compress> <locked>false</locked> <modtime>false</modtime> <rmdir>false</rmdir> <streamName></streamName> <line>LOCAL</line> <view>//depot/kernel/04.02/wars/admin-ui/... //${P4_CLIENT}/...</view> <changeView></changeView> <type>WRITABLE</type> <serverID></serverID> <backup>true</backup> </spec> </workspace> <populate class="org.jenkinsci.plugins.p4.populate.AutoCleanImpl"> <have>true</have> <force>false</force> <modtime>false</modtime> <quiet>true</quiet> <pin></pin> <parallel> <enable>false</enable> <threads>4</threads> <minfiles>1</minfiles> <minbytes>1024</minbytes> </parallel> <replace>true</replace> <delete>true</delete> <tidy>false</tidy> </populate> </scm>
Hi drodspike,
Thanks.
The SCM class not longer hard codes all that information. In later versions of the plugin everything is built on the fly. So instead of specifying P4PORT and P4USER you pull in the Jenkins credential that encapsulates P4PORT, P4USER and P4PASSWD:
<credential>p4-userpass</credential>
P4CLIENT is also dynamically built based on 'name':
<name>jenkins-${NODE_NAME}-${JOB_NAME}-${EXECUTOR_NUMBER}</name>
For example if your node is WIN10, your job is mybuild and it runs on executor (Jenkins build thread) 1 the P4CLIENT (variable P4_CLIENT) would be:
jenkins-WIN10-mybuild-1
If you knew the job only ever runs on one node you could hard code the client name in the job definition to be 'ci-admin-ui-4.2'.
As for the error its occurring after P4Jenkins has finished and after the command "/data/jenkins_home/tools/apache-maven-3.6.3/bin/mvn -s " has executed. Also P4Jenkins doesnt use the 'p4' binary it uses P4Java that is dynamically sent to the slave as teh job executes:
ha:////4Lo+a7u/lzaTkq1HGH3U8JSMfSgah36g77z15FvpSvDYAAAAYB+LCAAAAAAAAP9b85aBtbiIQSmjNKU4P0+vJLE4u1gvPjexLDVPzxdEuhYV5Rf55ZekOlc7RKnPKH7IxMBQUcQgBdWQnJ9XnJ+TqucMoUEKGSCAEaSwAACsNFCqYAAAAA==[ERROR] Failed to execute goal com.mycom:mycom-build-info-plugin:1.0.14:create (vernum) on project admin.ui: Unable to fetch p4 head version for path/data/jenkins_home/workspace/admin-ui-4.2: P4 process `/bin/sh -c p4 -d /data/jenkins_home/workspace/admin-ui-4.2 changes -m1 ...` returned error code;rc;1;Error message;... - must create client 'ip-10-21-2-84' to access local files. -> [Help 1]
Note that it's running '/bin/sh -c p4'. So if this is not Maven then it is another script or job that is being executed by the Jenkins job.
The problem is that the P4CLIENT being built on the fly is not being passed to the environment that the job is executing under which is why I think it needs to be passed or picked up explicitly. For example if it's bash try using 'export P4CLIENT=P4_CLIENT'.
For example below is the output when I run a shell script from the job that displaye P4CLIENT and P4_CLIENT:
Note that P4CLIENT is not set but P4_CLIENT is.
Hi Karl,
The P4 command below is executed within maven
/bin/sh -c p4 -d /data/jenkins_home/workspace/admin-ui-4.2 changes -m1 ...
Why doesn't the P4CLIENT persist throughout the job like it does with Jenkins1. This way it's backward compatible when upgrading from jenkin1 to jenkins2. Otherwise the P4 Plugin it's not backward compatible.
I modified the job on both jenkins1 and jenkin2 job by removing the maven step and adding only the shell step to execute the above command. The jenkins job config.xml and console logs are attached.
Note on Jenkin1, the P4 command below in the log returns an expected change from the perforce repo. Is it possible for the the P4 plugin in Jenkins2 to do the same? If so, how?
Jenkin1 shell:
echo "P4CLIENT = $P4CLIENT" echo "P4_CLIENT = $P4_CLIENT" echo "PWD = `pwd` "cmd="/usr/bin/p4 -d /data/builds/workspace/drod-test-1.6 changes -m1 ..." `$cmd`
Sync complete, took 1003 ms
[drod-test-1.6] $ /bin/sh -xe /tmp/hudson1085421712960825854.sh
+ echo P4CLIENT = ci-drod-test-1.6-1091564373
P4CLIENT = ci-drod-test-1.6-1091564373
+ echo P4_CLIENT =
P4_CLIENT =
+ pwd
+ echo PWD = /data/builds/workspace/drod-test-1.6
PWD = /data/builds/workspace/drod-test-1.6
+ cmd=/usr/bin/p4 -d /data/builds/workspace/drod-test-1.6 changes -m1 ...
+ /usr/bin/p4 -d /data/builds/workspace/drod-test-1.6 changes -m1 ...
+ Change 290033 on 2018/11/16 by davidt@FR-NBSPT6 '<admin-ui-4.2*SCH> IT test fail'
/tmp/hudson1085421712960825854.sh: 8: /tmp/hudson1085421712960825854.sh: Change: not found
Build step 'Execute shell' marked build as failure
Finished: FAILURE
Jenkin2 shell:
echo "P4CLIENT = $P4CLIENT" echo "P4_CLIENT = $P4_CLIENT" echo "PWD = `pwd`" cmd="/usr/bin/p4 -d /data/jenkins_home/workspace/drod-test-2.222 changes -m1 ..." `$cmd`
[drod-test-2.222] $ /bin/sh -xe /tmp/jenkins7634372390604735818.sh
+ echo P4CLIENT =
P4CLIENT =
+ echo P4_CLIENT = ci-drod-test-2.222
P4_CLIENT = ci-drod-test-2.222
+ pwd
+ echo PWD = /data/jenkins_home/workspace/drod-test-2.222
PWD = /data/jenkins_home/workspace/drod-test-2.222
+ cmd=/usr/bin/p4 -d /data/jenkins_home/workspace/drod-test-2.222 changes -m1 ...
+ /usr/bin/p4 -d /data/jenkins_home/workspace/drod-test-2.222 changes -m1 ...
... - must create client 'ip-10-21-2-84' to access local files.
+
Build step 'Execute shell'
Hi drodspike - Not ignoring you but dont know the answer yet. Checking with the developers and will let you know when I have something.
Hi drodspike - Thanks for those kind words.
The developers have confirmed that 1.3.35 was the old community plugin. That did set the variables. The new plugin developed by Perforce has never set the variables because we were worried about stamping on environment variables that had been preconfigured already on build slaves.
I have therefore raised the following enhancement request:
https://issues.jenkins-ci.org/browse/JENKINS-62008
The workaround would still be the same that you need to manually set P4CLIENT in the build script based on P4_CLIENT.
Karl,
I did the workaround as suggested on the jenkin master 'Configure System' by adding P4CLIENT to the "Global properties" as follows. It worked.
Name: P4CLIENT
Value: $P4_CLIENT
I'm wondering if the Jenkins Guild below should also mention this issue for "Freestyle jobs configured for P4"
Helix Plugin for Jenkins Guide (1.10.x), Freestyle job - Manual Workspace setup
https://www.perforce.com/manuals/jenkins/Content/P4Jenkins/workspace-manual.html
Thanks again.
David
Hi drodspike - Aha. Another Jenkins feature I never knew about. Thanks. Great that it's now working and thanks for correcting the typos in the other job.
Yes I agree this should be documented so passed this job to our doc team. I'm going to suggest the following wording, but they will tweak it as needed to match the documentation standards and correct grammar:
Note that when using build steps such as 'Execute Shell' the standard Perforce variables P4PORT, P4USER and P4CLIENT are not set in the environment. This is to ensure the plugin does not overwrite variables on preconfigured build environments. If a build step needs access to these values the variables P4_PORT, P4_USER and P4_CLIENT can be used. For example in a shell script: export P4CLIENT=$P4_CLIENT To make the standard variables accessible by default they can be set in the 'Global properties' section on the Jenkins 'Configure System' page. For example:
Hi drodspike
This looks likes it a problem in Maven (possibly P4Maven if you are using it) not P4Jenkins.
We see P4Jenkins succesfully doing it's sync against a the client 'jenkins-jenkins-slave-test1-admin-ui-4.2-0' here on a node called 'ip-10-21-2-84':
Then later on when the Maven command runs:
[admin-ui-4.2] $ /data/jenkins_home/tools/apache-maven-3.6.3/bin/mvn -s /data/jenkins_home/maven_repository/settings.xml -Pmycomci clean deploy -B -U -Dit.skip=true
we see the error:
When P4CLIENT is not set in the environment we default to using the hostname for the client (in this case 'ip-10-21-2-84'.
Looking at the maven docs (https://www.perforce.com/manuals/p4maven/index.html) you may need to explicitly pass the client name onto Maven. Possibly: