ฉันมี 2 สาขาในคลังของฉัน
//depot/project/mainline/...
//depot/project/staging/...
ฉันใช้เครื่องมือภายในองค์กรที่จัดการบิลด์ของโปรเจ็กต์ และต้องการสร้างขั้นตอนบิลด์ที่เลื่อนระดับไฟล์ทั้งหมดตั้งแต่เมนไลน์ไปจนถึงสเตจโดยอัตโนมัติ ฉันพยายามเขียนโดยใช้ p4.net API ตามตัวอย่างต่อไปนี้ ฉันสามารถรันคำสั่ง PowerShell จากเครื่องมือ build ได้ แผนของฉันคือการเขียนแอปพลิเคชันคอนโซล c# คอมไพล์โดยใช้เครื่องมือ จากนั้นดำเนินการเป็นขั้นตอนการสร้าง น่าเสียดายที่ฉันไม่ได้รับตัวอย่างนั้นเลย ฉันสามารถสร้างไคลเอนต์ สร้างข้อมูลจำเพาะสาขา และแม้แต่ซิงค์ไฟล์ลงได้ แต่ตลอดชีวิตฉันไม่รู้ว่าจะส่งการผสานรวมอย่างไร ฉันรู้สึกเหมือนกำลังพยายามคิดทางวิศวกรรมมากเกินไป นี่คือสิ่งที่ควรจะทำได้ง่าย ฉันกำลังแนบรหัสที่เสียหายด้านล่าง หากมันไม่สมเหตุสมผล นั่นเป็นเพราะฉันใช้การลองผิดลองถูกเพื่อหาคำตอบและยังไม่ได้ผ่านขั้นตอนสุดท้ายไป ที่กล่าวว่าหากฉันไม่จำเป็นต้องใช้ p4 api ก็จะดีกว่า ข้อกำหนดเพียงอย่างเดียวคือไม่จำเป็นต้องป้อนข้อมูลโดยผู้ใช้เพื่อรันคำสั่ง หากมีข้อขัดแย้งในการผสาน ฉันต้องการยอมรับแหล่งที่มาโดยอัตโนมัติ
ขอบคุณ
string uri = "server";
string user = "user";
string pass = null;
string ws_client = "Project-Temp-"+ Guid.NewGuid().ToString();
Server server = new Server(new ServerAddress(uri));
Repository rep = new Repository(server);
Connection con = rep.Connection;
con.UserName = user;
con.Client = new Client();
con.Client.Name = ws_client;
con.Client.ViewMap = new ViewMap();
con.Connect(null);
Credential cred = con.Login(pass, null, null);
rep.DeleteClient(con.Client, null);
rep.CreateClient(con.Client);
con.Client.ViewMap.Clear();
con.Client.ViewMap.Add("//depot/project/...", String.Format("//{0}/...", con.Client.Name), MapType.Include);
rep.UpdateClient(con.Client);
var files = con.Client.SyncFiles(new SyncFilesCmdOptions(SyncFilesCmdFlags.None, -1));
ViewMap vm = new ViewMap();
vm.Add(new MapEntry(MapType.Include,new ClientPath("//depot/project/mainline/..."), new ClientPath("//depot/project/staging/...")));
string msg = "Mainline to Staging";
BranchSpec bs = new BranchSpec("Project-Temp", user, DateTime.Now, DateTime.Now, msg, true, vm, null, null);
int change = -1;
IntegrateFilesCmdOptions BranchOptions = new IntegrateFilesCmdOptions(IntegrateFilesCmdFlags.None, change, -1, "Project-Temp", null, null);
rep.CreateBranchSpec(bs);
rep.UpdateClient(con.Client);
var integrated = con.Client.IntegrateFiles(BranchOptions);
con.Client.ResolveFiles(files, new ResolveCmdOptions(ResolveFilesCmdFlags.AutomaticYoursMode, change));
rep.DeleteClient(con.Client, null);