Martin, Jenkins and Perforce both have a concept of “workspace”. The Jenkins workspace is the folder that the job will run in. This will be named typically Remote Root/job name. Then Perforce has a “workspace”. Jenkins creates its own Perforce workspace based on the values you set in the Jenkins job. You do not need to create a workspace in Perforce first. Jenkins sets the root of its Perforce workspace to the Remote Root of the machine you are building on (again typically plus the job name). This is what you are seeing. It then pulls all the sources as defined in the view box into that folder location and you build from there.
If your build process is not relative to the root folder Jenkins creates (that means you reference files with absolute paths) then this will not work for you.
To get Jenkins to use the Perforce workspace you defined, you need to tell Jenkins NOT to manage the Perforce workspace, and to run in your folder, not the one it would normally use. To confuse things just a little, there are 2 Perforce plugins. You appear to be using the one I do not use, so I can’t tell you how configure the Perforce plugin to do this.
Use the 'custom workspace' in the Advanced project option, and change the folder location to /home/abigail/p4/test/ to tell Jenkins where to run.
From: jenkins...@googlegroups.com [mailto:jenkins...@googlegroups.com]
On Behalf Of Martin
Sent: Wednesday, July 22, 2015 2:50 AM
To: Jenkins Users
Subject: Re: Jenkins Perforce workspace question
Hi, Iata:
Thanks for your detailed info. But I still have some questions. To keep it simpler, I did the following:
I created a super simple test case. It would be great if you can point out where I may be wrong. I just want to have a simple test of using P4 Jenkins plugin. My steps are below:
1) Following the P4 wizard, I created a workspace named "test", which point to the root of the directory /home/abigail/p4/test/test1 on my local machine.
Please see the attached "p4-workspace.png"
2) In the P4 depot there are two projects, "test1" & "test2", and test1 maps to the workspace "test".
Please see "p4-depot.png"
3) In Jenkins, I typed the workspace name "test" and the view map "//depot/test1/... //test/...".
Please see "P4-jenkins.png"
4) admin@Jenkins:~$ p4 info
User name: admin
Client name: test
Client host: Jenkins
Client root: /home/abigail/p4/test/test1
Current directory: /home/admin
Peer address: ...
Client address: xx.xx.xx.xx
Server address: xx.xx.xx.xx:1666
Server root: /opt/p4d
Server date: 2015/07/22 01:42:32 -0400 EDT
Server uptime: 00:32:40
Server version: P4D/LINUX26X86_64/2015.1/1171507 (2015/06/30)
Server license: none
Case Handling: sensitive
My Jenkins is installed by default /var/lib/jenkins/....
Event time the Jenkins build finishes, the root of the workspace "test" changes to "/var/lib/jenkins/..." from /home/abigail/p4/test/test1 on my local machine. This is not the right behavior, or not the good practice, right? I need the root directory "/home/abigail/p4/test/test1" on my local machine because all my project resides in this directory, and I can sync with P4, but this root is not known by Jenkins, so it copies all files from my local workspace root directory to Jenkin's default installation location /var/lib/jenkins... for each build. I guess my setting of workspace root isn't quite right? But I just followed the P4 wizard to create the workspace, and I can syc with P4 correctly. The problem is when Jenkins comes into play.
Please use simple or step-wise language to help me get this configured properly. This is a simple typical setup. I want to configure nothing Unique or Special. Thank you.
Martin
--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/jenkinsci-users/e9d6497d-581a-4b82-88ad-2089f2156b2c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.