private void GetCorrectVaultInstance() { if (VaultSourceControl != null) { return; } if (VaultVersionIs317OrBetter()) { Log.Debug("Vault CLC is at least version 3.1.7."); _vaultSourceControl = new Vault317(this); } else { Log.Debug("Vault CLC is older than version 3.1.7."); _vaultSourceControl = new Vault3(this); } }
public VaultVersionChecker(IHistoryParser historyParser, ProcessExecutor executor, EForcedVaultVersion forceVersion) { _forcedVaultVersion = forceVersion; switch (forceVersion) { case EForcedVaultVersion.Vault3: _vaultSourceControl = new Vault3(this, historyParser, executor); break; case EForcedVaultVersion.Vault317: _vaultSourceControl = new Vault317(this, historyParser, executor); break; default: Debug.Fail("You have to force a version of Vault from the unit tests."); break; } }
public VaultVersionChecker(IHistoryParser historyParser, ProcessExecutor executor, EForcedVaultVersion forceVersion) { _forcedVaultVersion = forceVersion; switch ( forceVersion ) { case EForcedVaultVersion.Vault3: _vaultSourceControl = new Vault3(this, historyParser, executor); break; case EForcedVaultVersion.Vault317: _vaultSourceControl = new Vault317(this, historyParser, executor); break; default: Debug.Fail("You have to force a version of Vault from the unit tests."); break; } }
private void GetCorrectVaultInstance() { if ( VaultSourceControl != null ) return; if ( VaultVersionIs317OrBetter() ) { Log.Debug("Vault CLC is at least version 3.1.7."); _vaultSourceControl = new Vault317(this); } else { Log.Debug("Vault CLC is older than version 3.1.7."); _vaultSourceControl = new Vault3(this); } }
/// <summary> /// Gets the most recent folder version via Vault's versionhistory command. /// /// If we don't yet have a folder version, we need to get one so getSource and LabelSource have a version to work with, /// whether there's been changes or not. (On a forced build or a multi-source control setup, we might get and/or label /// when there's been no change.) /// /// So if we have no folder version, we get the latest version of the folder via Vault's versionhistory command and see /// if the timestamp on that folder is more recent than the last build. If we already have a folder version, we simply /// ask Vault to give us the most recent folder version after then one we already know about. /// </summary> /// <param name="from"></param> /// <param name="to"></param> /// <returns></returns> private bool GetFolderVersion(IIntegrationResult from, IIntegrationResult to) { bool bFoundChanges = false; // If we don't yet have a folder version, we need to just get the latest, rather than checking for a change. bool bForceGetLatestVersion = (_folderVersion == 0); // get version history ProcessResult result = ExecuteWithRetries(VersionHistoryProcessInfo(from, to, bForceGetLatestVersion)); // parse out changes string versionHistory = Vault3.ExtractXmlFromOutput(result.StandardOutput); XmlDocument versionHistoryXml = new XmlDocument(); versionHistoryXml.LoadXml(versionHistory); XmlNodeList versionNodeList = versionHistoryXml.SelectNodes("/vault/history/item"); XmlNode folderVersionNode = null; if (bForceGetLatestVersion) { Debug.Assert(versionNodeList.Count == 1, "Attempted to retrieve folder's current version and got no results."); folderVersionNode = versionNodeList.Item(0); } else { Debug.Assert(versionNodeList.Count == 0 || versionNodeList.Count == 1, "Vault versionhistory -rowlimit 1 returned more than 1 row."); if (versionNodeList.Count == 1) { folderVersionNode = versionNodeList.Item(0); // We asked vault for only new folder versions, so if we got one, the folder has changed. bFoundChanges = true; } } if (folderVersionNode != null) { if (bForceGetLatestVersion) { // We asked Vault for the most recent folder version. We have to check its date to // see if this represents a change since the last integration. XmlAttribute dateAttr = (XmlAttribute)folderVersionNode.Attributes.GetNamedItem("date"); Debug.Assert(dateAttr != null, "date attribute not found in version history"); DateTime dtLastChange = DateTime.Parse(dateAttr.Value, culture); if (dtLastChange > from.StartTime) { bFoundChanges = true; } } // get the new most recent folder version XmlAttribute versionAttr = (XmlAttribute)folderVersionNode.Attributes.GetNamedItem("version"); Debug.Assert(versionAttr != null, "version attribute not found in version history"); _folderVersion = long.Parse(versionAttr.Value); Log.Debug("Most recent folder version: " + _folderVersion); // get the new most recent TxId XmlAttribute txIdAttr = (XmlAttribute)folderVersionNode.Attributes.GetNamedItem("txid"); Debug.Assert(txIdAttr != null, "txid attribute not found in version history"); _lastTxID = long.Parse(txIdAttr.Value); Log.Debug("Most recent TxID: " + _lastTxID); } return(bFoundChanges); }
/// <summary /// The Vault command line client (vault.exe), at least for /// version 2.0.4, is not guaranteed to output valid XML in /// that there may be some not XML output surrounding the XML. /// This method strips away any non-XML output surrounding /// the <vault>...</vault> elements. /// </summary /// <param name="history"Output from Vault client is read from this reader.</param> /// <returns>string containing only the XML output from the Vault client.</returns> /// <exception cref="CruiseControlException">The <vault> start element or </vault> end element cannot be found.</exception> private string ExtractXmlFromHistory(TextReader history) { string output = history.ReadToEnd(); return(Vault3.ExtractXmlFromOutput(output)); }