Jump to content

Add a Job to a ChangeList using the p4api.net

p4api.net Change list jobs

  • Please log in to reply
2 replies to this topic

#1 charder



  • Members
  • Pip
  • 9 posts

Posted 25 February 2015 - 08:16 PM


I am trying to add a job to a changelist.
I have created the Job as follows and it is visible via the P4Client when I check.
P4API_Net.Job job = _mRepository.GetJob("Job");
job["Job"] = "changerequest" + newCRNumber;
job["Description"] = "Automatic Job Creation";
job["Status"] = "closed";
I then have tried a number of iteration to add this job to the changelist, but get blocked at every turn...
Create a Fix, added the Job id to it, hitting changelist.FixJobs,... etc.
I finally added the Job this way:

Dictionary<string, string> jobDic = new Dictionary<string, string>();
jobDic.Add(job.Id, "changerequest" + newCRNumber);
_changeList.Jobs = jobDic;
It obviously shows in the Changelist when I view it in code, but there is no Server communication here.
What am I missing, what is the pattern to do this...
Please Help

Thanks in advance.

#2 P4Matt


    Advanced Member

  • Members
  • PipPipPip
  • 1383 posts

Posted 25 February 2015 - 09:12 PM

This is a snippet from our unit test for this functionality. It should do the trick. I'm not on my machine with a windows dev environment on it, so if there are issues let me know I'll build up a full example.

Changelist change = new Changelist(9, true);

Job job = new Job();
job.Id = "job000001";

Options opt = new Options(FixJobsCmdFlags.None, -1, null);
IList<Fix> fixes = change.FixJobs(null, job);

#3 charder



  • Members
  • Pip
  • 9 posts

Posted 25 February 2015 - 10:30 PM

When you do it, it looks so simple! ;-)

Thanks for the help, this worked perfectly!

Also tagged with one or more of these keywords: p4api.net, Change list, jobs

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users