Sometimes you want a Perforce instance up and running as fast as possible. You can find bash scripts online, but are they tailored to you?
I’m a solutions engineer at Assembla and I’ve put together this tutorial to help you breeze through your Perforce setup.
Here’s what you’ll need:
This tutorial assumes:
When managing tons of Perforce instances, you can utilize ChatGPT to make a suite of bash scripts to help you out and do tasks a lot quicker. For example, fetching P4Proxy and giving me default environment variables:
In the use-case above, I’m using aichat. Follow the instructions and install it from there. We have our P4Proxy bash script, now what if we wanted to have a regular Perforce setup, nothing special, just things like:
#!/bin/bash
set -e
wget http://cdist2.perforce.com/perforce/r21.1/bin.linux26x86_64/p4 -O /usr/local/bin/p4
chmod +x /usr/local/bin/p4
echo "P4USER=<username>" >> ~/.bashrc
echo "P4PORT=<server_address>:<port>" >> ~/.bashrc
p4 -c $P4CLIENT set P4USER=<username>
p4 -c $P4CLIENT set P4PORT=<server_address>:<port
This will install the Perforce in the binary /usr/local/bin/p4 and label under it 'p4'. You should now be able to set environment variables.
In this case we are using Assembla + Perforce, so our environment variables look like this:
P4PORT=ssl:perforce-us-east.assembla.com:1667
P4HOST=spacetest/p4-test
P4CLIENT=perforce
P4USER=MontanaMendy
P4_ssl:perforce-us-east.assembla.com:1667_CHARSET=auto
In the example below, I want to populate my mainline stream with a depot called mendy
I’d run the following:
p4 depot -t stream //depot/mendy
Now let’s setup the typemap:
cat typemap.txt | p4 typemap -i
We’re now going to create the mendy stream:
p4 stream -t mainline $mendy
You’ll need to make sure you are in the correct workspace by running p4 workspace. Check your changelist status by running p4 changes to ensure that all the files you made changes to are included in your changelist.
Next run p4 submit and review the changelist description that pops up in the text editor.
Now in the changelist description, include a brief summary of the changes you made and any relevant comments or details. Be sure to follow any specific requirements set by your team or organization. This would be similar to a git commit message.
Save and close the changelist description file, then exit the submit command by pressing Ctrl+C (Windows) or Command+C (Mac/Unix). After the changelist is submitted, you will receive a notification indicating the changelist number along with any messages or errors that may have occurred during the submission process.
You’ll now have files in the mendy stream. Now run p4 sync.
Let’s create a bash script to list my current streams, well let’s ask aichat
to do that:
To check you’re in the correct workspace run:
p4 where /depot/main/...
You should see something like this:
Change your P4CLIENT
to whatever you want then run this:
#!/bin/bash
set -e
p4 client -S //depot/main -o | p4 client -i
To make sure you’re in the correct workspace, just use grep
and have it search the p4enviro
file:
p4 info | grep 'User name'
p4 info | grep 'Client name'
You should get the results you were looking for and it should look similar to this:
Back to asking aichat things, let’s ask it to build us a bash script to install Helix Swarm:
Now as you can see Helix Swarm is installed, you can start to see how much time this could save in aggregate. Then run swarmctl start to start Helix Swarm, and then if you want to test it locally, you can do this via: http://localhost:8080/swarm.
You now have just set up Perforce and saved a lot of aggregate time using the aichat tool that uses ChatGPT. Version 2 of this blog post will be coming out soon, with more automation and more of a seamless Perforce setup using aichat.
As always, if you have any questions, any questions at all, please email me at montana@assembla.com.
Happy Perforcing & Assemblaing!
Montana Mendy – Solutions Engineer for Assembla