Reputation: 17631
P4 Server 2013.1/610569
I am trying to script the submission of default changelist with a Job. I understand that it is not possible to directly add a job to a pending changelist and submit it however I am open to doing things the indirect fashion. Basically the steps for me are
Can someone post me the p4 commands that need to be run for this? I tried doing this from the P4V and capture the commands at the bottom but it appears when you move files we have to list all files and I was looking for a straight-forward way of doing this.
Upvotes: 0
Views: 1319
Reputation: 16389
Here's a starting place:
p4 change -o | sed 's/<enter.*>/Change to fix job000001/' >change.dat
echo 'Jobs: job000001' >> change.dat
p4 change -i < change.dat >changenumber.out
p4 submit -c `cut -f 2 -d ' ' < changenumber.out`
The first two lines construct the form data for the new changelist.
The third line creates the numbered changelist, and saves the output, which is something like "Change 12345 saved".
The fourth line extracts that change number and gives it to 'p4 submit -c'.
Of course, I haven't done any error checking, reporting of the results to the user, etc.
As an alternative, consider this:
p4 submit -d "Change to fix job000001" | grep 'Change .* submitted' | cut -f 2 -d ' ' >change.out
p4 fix -c `cat change.out` job000001
That variant submits the change without the job attached, then associates the change with the job.
Either way, please consider using one of the Perforce scripting APIs (P4Perl, P4Ruby, P4Python, etc.) instead of this, as they are much, much easier.
Upvotes: 1