public override void ExecuteBuild() { // Parse the parameters string DepotPath = ParseParamValue("DepotPath"); if (DepotPath == null) { throw new AutomationException("Missing -DepotPath=... parameter"); } string OutputDir = ParseParamValue("OutputDir"); if (OutputDir == null) { throw new AutomationException("Missing -OutputDir=... parameter"); } // Create a temporary client to sync down the folder string ClientName = String.Format("{0}_{1}_SyncDepotPath_Temp", P4Env.User, Environment.MachineName); List <KeyValuePair <string, string> > RequiredView = new List <KeyValuePair <string, string> >(); RequiredView.Add(new KeyValuePair <string, string>(DepotPath, "/...")); if (P4.DoesClientExist(ClientName)) { P4.DeleteClient(ClientName); } P4ClientInfo Client = new P4ClientInfo(); Client.Owner = P4Env.User; Client.Host = Environment.MachineName; Client.RootPath = OutputDir; Client.Name = ClientName; Client.View = RequiredView; Client.Stream = null; Client.Options = P4ClientOption.NoAllWrite | P4ClientOption.Clobber | P4ClientOption.NoCompress | P4ClientOption.Unlocked | P4ClientOption.NoModTime | P4ClientOption.RmDir; Client.LineEnd = P4LineEnd.Local; P4.CreateClient(Client); // Sync the workspace, then delete the client try { P4Connection Perforce = new P4Connection(P4Env.User, ClientName); Perforce.Sync("-f //..."); } finally { P4.DeleteClient(ClientName); } }
public override void ExecuteBuild() { string TemplateClient = "ue4_licensee_workspace"; var Clients = P4.GetClientsForUser("UE4_Licensee"); string TestClient = "UAT_Test_Client"; P4ClientInfo NewClient = null; foreach (var Client in Clients) { if (Client.Name == TemplateClient) { NewClient = Client; break; } } if (NewClient == null) { throw new AutomationException("Could not find template"); } NewClient.Owner = P4Env.User; // this is not right, we need the actual licensee user! NewClient.Host = Environment.MachineName.ToLower(); NewClient.RootPath = @"C:\TestClient"; NewClient.Name = TestClient; if (P4.DoesClientExist(TestClient)) { P4.DeleteClient(TestClient); } P4.CreateClient(NewClient); //P4CLIENT Name of client workspace p4 help client //P4PASSWD User password passed to server p4 help passwd string[] VarsToSave = { "P4CLIENT", //"P4PASSWD", }; var KeyValues = new Dictionary <string, string>(); foreach (var ToSave in VarsToSave) { KeyValues.Add(ToSave, GetEnvVar(ToSave)); } SetEnvVar("P4CLIENT", NewClient.Name); //SetEnv("P4PASSWD", ParseParamValue("LicenseePassword"); //Sync(CombinePaths(PathSeparator.Slash, P4Env.BuildRootP4, "UE4Games.uprojectdirs")); string Output; P4.P4Output(out Output, "files -m 10 " + CombinePaths(PathSeparator.Slash, P4Env.Branch, "...")); var Lines = Output.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); string SlashRoot = CombinePaths(PathSeparator.Slash, P4Env.Branch, "/"); string LocalRoot = CombinePaths(CmdEnv.LocalRoot, @"\"); foreach (string Line in Lines) { if (Line.Contains(" - ") && Line.Contains("#")) { string depot = Line.Substring(0, Line.IndexOf("#")); if (!depot.Contains(SlashRoot)) { throw new AutomationException("{0} does not contain {1} and it is supposed to.", depot, P4Env.Branch); } string local = CombinePaths(depot.Replace(SlashRoot, LocalRoot)); LogInformation("{0}", depot); LogInformation(" {0}", local); } } // should be used as a sanity check! make sure there are no files! P4.LogP4Output(out Output, "files -m 10 " + CombinePaths(PathSeparator.Slash, P4Env.Branch, "...", "NoRedist", "...")); // caution this doesn't actually use the client _view_ from the template at all! // if you want that sync -f -k /... // then use client syntax in the files command instead // don't think we care, we don't rely on licensee _views_ foreach (var ToLoad in VarsToSave) { SetEnvVar(ToLoad, KeyValues[ToLoad]); } P4.DeleteClient(TestClient); }
void ExecuteInner(string Dir, int PR) { string PRNum = PR.ToString(); // Discard any old changes we may have committed RunGit("reset --hard"); // show-ref is just a double check that the PR exists //var Refs = RunGit("show-ref"); /*if (!Refs.Contains("refs/remotes/origin/pr/" + PRNum)) * { * throw new AutomationException("This is not among the refs: refs/remotes/origin/pr/{0}", PRNum); * }*/ RunGit(String.Format("fetch origin refs/pull/{0}/head:pr/{1}", PRNum, PRNum)); RunGit(String.Format("checkout pr/{0} --", PRNum)); int CLBase; string DepotBase; ScanForBranchAndCL_BaseVersion(String.Format("log --author=TimSweeney --author=UnrealBot -100 pr/{0} --", PRNum), out DepotBase, out CLBase); int CLLive; string DepotLive; ScanForBranchAndCL_LiveVersion(String.Format("log -100 pr/{0} --", PRNum), out DepotLive, out CLLive); if (CLLive == 0 && CLBase == 0) { throw new AutomationException("Could not find a base change and branch using either method."); } int CL = 0; string Depot = ""; if (CLBase > CLLive) { CL = CLBase; Depot = DepotBase; } else { CL = CLLive; Depot = DepotLive; } if (CL < 2000000 || String.IsNullOrWhiteSpace(Depot)) { throw new AutomationException("Could not find a base change and branch using either method."); } P4ClientInfo NewClient = P4.GetClientInfo(P4Env.Client); foreach (var p in NewClient.View) { LogInformation("{0} = {1}", p.Key, p.Value); } string TestClient = P4Env.User + "_" + Environment.MachineName + "_PullRequests_" + Depot.Replace("/", "_"); NewClient.Owner = P4Env.User; NewClient.Host = Environment.MachineName; NewClient.RootPath = Dir; NewClient.Name = TestClient; NewClient.View = new List <KeyValuePair <string, string> >(); NewClient.View.Add(new KeyValuePair <string, string>(Depot + "/...", "/...")); NewClient.Stream = null; if (!P4.DoesClientExist(TestClient)) { P4.CreateClient(NewClient); } var P4Sub = new P4Connection(P4Env.User, TestClient, P4Env.ServerAndPort); P4Sub.Sync(String.Format("-f -k -q {0}/...@{1}", Depot, CL)); var Change = P4Sub.CreateChange(null, String.Format("GitHub pull request #{0}", PRNum)); P4Sub.ReconcileNoDeletes(Change, CommandUtils.MakePathSafeToUseWithCommandLine(CombinePaths(Dir, bDoingUT ? "UnrealTournament" : "Engine", "..."))); P4Sub.Shelve(Change); P4Sub.Revert(Change, "-k //..."); }