public override bool Execute() { TFVC oTfvc = new TFVC(); oTfvc.GetLatest(element, workspace, owner); oTfvc.Checkout(element, workspace, owner); return true; }
public override bool Execute() { TFVC oTfvc = new TFVC(); TeamFoundationServer tfs = oTfvc.GetTfs(); WorkItemStore store = (WorkItemStore)tfs.GetService(typeof(WorkItemStore)); WorkItem wi = store.GetWorkItem(_winum); wi.Open(); wi = Update(wi); wi.Save(); return true; }
private void UpdateBQ4PerviousBuilds() { TFVC oTfvc = new TFVC(); TeamFoundationServer tfs = oTfvc.GetTfs(); BuildStore bs = (BuildStore)tfs.GetService(typeof(BuildStore)); BuildData[] bd = bs.GetListOfBuilds(_project, _buildType); foreach (BuildData build in bd) { if (build.BuildQuality.Contains(_buildQuality)) { bs.UpdateBuildQuality(build.BuildUri, "Rejected"); } } }
/// <summary> /// Check to see if a build with the same build number foot print (Major.Minor.Fix) is /// already in Production. /// </summary> /// <param name="_project">The Team project the build is apart of</param> /// <param name="_buildType">The build type being built</param> /// <param name="_buildNumber">The build number to be created</param> /// <returns> /// True is returned if a matching Production build number is found /// </returns> public bool IsBuildInPRD(string _project, string _buildType, string _buildNumber) { TFVC oTfvc = new TFVC(); TeamFoundationServer tfs = oTfvc.GetTfs(); BuildStore bs = (BuildStore)tfs.GetService(typeof(BuildStore)); foreach (BuildData build in bs.GetListOfBuilds(_project, _buildType)) { if (build.BuildQuality.Equals("In-Production")) { if (_buildNumber.Remove(_buildNumber.LastIndexOf(".")).Equals(build.BuildNumber.Remove(build.BuildNumber.LastIndexOf(".")))) { return true; } } } return false; }
public override bool Execute() { try { TFVC _tfs = new TFVC(); if (_ext.Length != 0) { _tfs.DownloadLatestChangeSets(_lastGoodBuild, _sourceControlPath, _dropPath, _ext.Split(';')); } else { _tfs.DownloadLatestChangeSets(_lastGoodBuild, _sourceControlPath, _dropPath, new string[1] {"*"}); } } catch (Exception _ex) { throw (_ex); } return true; }
public override bool Execute() { try { TFVC _tfs = new TFVC(); bool _changesetsFound = false; foreach (string _vcPath in _tfs.GetWorkspaceWorkingFolderServerMappings(_ws, _owner)) { BuildMessageEventArgs _bmsg = new BuildMessageEventArgs("Checking: " + _vcPath, "help", null, MessageImportance.Low); BuildEngine.LogMessageEvent(_bmsg); if (_tfs.Check4ChangeSetsSinceLabel(_lastGoodBuild, _vcPath)) { BuildEngine.LogMessageEvent(new BuildMessageEventArgs("Changesets founds[" + _tfs.ChangesetsFoundCount + "]: " + _tfs.ChangesetsFound, "help", null, MessageImportance.Low)); _changesetsFound = true; break; } } if (_changesetsFound) { return true; } else { BuildErrorEventArgs _berror = new BuildErrorEventArgs("No Changes since last good build", "HIC:4201", null, 0, 0, 0, 0, "No changessets were found since the " + _lastGoodBuild, null, null); BuildEngine.LogErrorEvent(_berror); return false; } } catch (Exception _ex) { BuildErrorEventArgs _berr = new BuildErrorEventArgs(_ex.Message, _ex.StackTrace, _ex.Source, 0, 0, 0, 0, _ex.Message, _ex.HelpLink, null); BuildEngine.LogErrorEvent(_berr); return false; } }
private bool Merge() { TFVC _tfs = new TFVC(); BuildEngine.LogMessageEvent(new BuildMessageEventArgs("Starting Merge from " + _source + "To " + _target, "Help", "Me", MessageImportance.High)); bool _wasMergeSuccessful = _tfs.Merge(_source, _target, _wsName, _owner); if (!_wasMergeSuccessful) { BuildEngine.LogErrorEvent(new BuildErrorEventArgs("Merge Failure", "Merge", "TFVC", 6969, 69, 45, 25, "TFVC Merge conflict needs action\n" + "There was a failure during merge, maunal merge needed\nError Msg:\n" + _tfs.ErrorMsg, null, "TFSBuild")); return false; } BuildEngine.LogMessageEvent(new BuildMessageEventArgs("Merge Complete, checking in", "Help", "Me", MessageImportance.High)); bool _wasCheckinSuccessful = _tfs.CheckinAll(_wsName, _owner, "Merge for build " + _BuildNumer, _wiNum); if (!_wasCheckinSuccessful) { BuildEngine.LogErrorEvent(new BuildErrorEventArgs("Checkin Failure", "Merge", "TFVC", 6969, 69, 45, 25, "TFVC Checkin error\n" + "There was a failure during checkin, possible issues are no elements to check in after merge, TFSbuild does not have pend change rights to target, etc", null, "TFSBuild")); return false; } BuildEngine.LogMessageEvent(new BuildMessageEventArgs("Checking in complete", "Help", "Me", MessageImportance.High)); return true; }
private BuildStore GetBuildStore() { TFVC oTfvc = new TFVC(); TeamFoundationServer tfs = oTfvc.GetTfs(); BuildStore _bs = (BuildStore)tfs.GetService(typeof(BuildStore)); return (_bs); }
private bool GetExports() { TFVC _tfs = new TFVC(); Workspace _ws = _tfs.GetWorkSpace(_wsName, _owner); List<string> _files2BeCheckedOut = new List<string>(); List<string> _files2Add = new List<string>(); Dictionary<string, string> _outboundFileMapping = new Dictionary<string,string>(); string _importPath = String.Empty; bool _areThereAnyPackages = false; foreach (WorkingFolder _wf in _ws.Folders) { if (_wf.IsCloaked) { continue; } BuildEngine.LogMessageEvent(new BuildMessageEventArgs("Working Folder search: " + _wf.LocalItem, "Help", "Me", MessageImportance.High)); foreach (string _vcfile in Directory.GetFiles(_wf.LocalItem, "*.zip", SearchOption.AllDirectories)) { BuildEngine.LogMessageEvent(new BuildMessageEventArgs("Working Folder search file: " + _vcfile, "Help", "Me", MessageImportance.High)); if (Directory.GetFiles(_outbound, Path.GetFileName(_vcfile)).Length != 0) { BuildEngine.LogMessageEvent(new BuildMessageEventArgs("Adding " + _vcfile, "Help", "Me", MessageImportance.High)); _files2BeCheckedOut.Add(_vcfile); _outboundFileMapping.Add(_outbound + @"\" + Path.GetFileName(_vcfile), _vcfile); } } _importPath = _wf.LocalItem; } //now check to see if there are any new packages that need to be add string _folderName; if (_newPackageSearchString.Contains("_CL")) { _folderName = "CommercialLines"; } else if (_newPackageSearchString.Contains("_PL")) { _folderName = "PersonalLines"; } else if (_newPackageSearchString.Contains("_Agency")) { _folderName = "Agency"; } else { _folderName = "Common"; } foreach (string _newFile in Directory.GetFiles(_outbound)) { BuildEngine.LogMessageEvent(new BuildMessageEventArgs("Outbound Folder search for new packages: " + _newFile, "Help", "Me", MessageImportance.High)); if (Path.GetFileName(_newFile).Contains(_newPackageSearchString)) { FileInfo _fi = new FileInfo(_newFile); if (Directory.GetParent(_importPath).Name.Equals(_folderName)) { _importPath = Directory.CreateDirectory(Directory.GetParent(_importPath).ToString() + @"\" + Path.GetFileNameWithoutExtension(_newFile).Replace(_newPackageSearchString, String.Empty)).FullName; } else { _importPath = Directory.CreateDirectory(_importPath + @"\" + _folderName + @"\" +Path.GetFileNameWithoutExtension(_newFile).Replace(_newPackageSearchString, String.Empty)).FullName; } string _vcPathFileName = Path.GetFileName(_newFile).Replace(_newPackageSearchString, String.Empty); string _vcPath = _importPath + @"\" + _vcPathFileName; BuildEngine.LogMessageEvent(new BuildMessageEventArgs("TFVC import path: " + _vcPath, "Help", "Me", MessageImportance.High)); if (Directory.GetFiles(_importPath, _vcPathFileName).Length != 0) { BuildEngine.LogMessageEvent(new BuildMessageEventArgs("Package already exists in TFVC, checking out", "Help", "Me", MessageImportance.High)); //element already exists in TFVC _files2BeCheckedOut.Add(_vcPath); _outboundFileMapping.Add(_outbound + @"\" + Path.GetFileName(_vcPath), _vcPath); } else { BuildEngine.LogMessageEvent(new BuildMessageEventArgs("New package found: " + _newFile, "Help", "Me", MessageImportance.High)); _fi.CopyTo(_vcPath); _files2Add.Add(_vcPath); _fi.Delete(); } } } if (_files2BeCheckedOut.Count > 0) { if (_isHotFix) { int _count = 0; string _localDir2Map = ""; foreach (string _outFile in _outboundFileMapping.Keys) { FileInfo _newFile = new FileInfo(_outboundFileMapping[_outFile].Replace(_folderName, @"Hotfixes\" + _buildNumber)); if (!_newFile.Directory.Exists) { Directory.CreateDirectory(_newFile.Directory.FullName); } File.Copy(_outFile, _newFile.FullName, true); _files2Add.Add(_newFile.FullName); File.Delete(_outFile); if (_count.Equals(0)) { _localDir2Map = _newFile.Directory.Parent.Parent.FullName; //local folder should be SolutionRoot/Hotfixes/Build#/PackageName/Package.zip } _count++; } _ws.Map("$/WmProjects/Hotfixes/", _localDir2Map); //this is not the best way to do this but I need a quick fix } else { _ws.PendEdit(_files2BeCheckedOut.ToArray()); foreach (string _outFile in _outboundFileMapping.Keys) { FileInfo _fi = new FileInfo(_outFile); _fi.CopyTo(_outboundFileMapping[_outFile], true); if ((_fi.Attributes & FileAttributes.ReadOnly) == FileAttributes.ReadOnly) { _fi.Attributes &= ~FileAttributes.ReadOnly; } _fi.Delete(); } } _areThereAnyPackages = true; } if (_files2Add.Count > 0) { _ws.PendAdd(_files2Add.ToArray()); _areThereAnyPackages = true; } if (_areThereAnyPackages) { _ws.CheckIn(_ws.GetPendingChanges(), "Checkins exported from " + _outbound + " for build " + _buildNumber); return true; } else { BuildEngine.LogMessageEvent(new BuildMessageEventArgs("No Packages to check in", "Help", "Me", MessageImportance.High)); return false; } }
public override bool Execute() { try { TFVC _Tfvc = new TFVC(); TeamFoundationServer _tfs = _Tfvc.GetTfs(); BuildStore _bs = (BuildStore)_tfs.GetService(typeof(BuildStore)); BuildData _bd = _bs.GetBuildDetails(_buildUri); WorkItem _wi = _Tfvc.CreateNewWorkItem(_witype, _dbiProj); _wi.Fields["Build Number"].Value = _bn; _wi.Fields["HIC Team Build Type"].Value = _bd.BuildType; _wi.Fields["HIC Build Requested By"].Value = _bd.RequestedBy; _wi.Fields["HIC Team Build Project"].Value = _bd.TeamProject; _wi.Title = _bn; // this keep link w/ TFS Deployer if (!String.IsNullOrEmpty(_dbiHicProject)) { _wi.Fields["HIC DBI Project"].Value = _dbiHicProject; } if (!String.IsNullOrEmpty(_dbiHicSubProject)) { _wi.Fields["HIC DBI Sub-Project"].Value = _dbiHicSubProject; } if (!String.IsNullOrEmpty(_dbiType)) { _wi.Fields["HIC DBI Deployment Type"].Value = _dbiType; } else { _wi.Fields["HIC DBI Deployment Type"].Value = ".Net"; } _wi.Save(); _wiNumber = _wi.Id; } catch (Exception _ex) { string _msg = "Get WorkItem failure:\n" + _ex.Message + "\n" + _ex.StackTrace; BuildEngine.LogErrorEvent(new BuildErrorEventArgs("Workitem Failure", "Get Failure", _ex.Source, 0, 0, 0, 0, _msg, "Creating an BBI was unsuccessful", "TFSBuild")); return false; } return true; }
public override bool Execute() { TFVC oTfvc = new TFVC(); oTfvc.Checkin(element, workspace, owner, comment, witype, winum, project); return true; }