How to Sync the Latest Code From Perforce Repository Using Jenkins?
Suppose you are running your scripts on client Machine or VM machine. In that case you have to always sync the latest code on the target machine manually. However, if you are using Jenkins, then you can implement and sync the latest code easily before running the scripts.
- Go to the target machine (client Machine or VM machine where your scripts will run) and open command prompt.
- Type the command: ‘p4 client’ and press ENTER button.
- Client file will open and update the ‘Client:’ and ‘Root:’ information. Here, ‘Client:’ is your perforce’s work space name (Test_perforce) and ‘Root:’ is the location (C:\etc) where code will be saved.
- Save the opened file.
- Now open the environment variable and set ‘P4CLIENT’ into ‘Test _perforce’ (perforce work space name).
- Restart the machine.
- Open the Jenkins URL
- Open the Jenkins Job.
- Add ‘Execute Window Batch Command’ option before executing your scripts.
- Enter the below mentioned code with correct user/password.
p4 set P4USER=[perforce user] P4PASSWD=[password]
p4 sync -f //etc/qa/Automation/selenium/adaptiveinsight/main/...[Location of your project]
11. Now run the Jenkins job.
You might also like: How to Change the Data into Properties File Using Jenkins?