/// <summary> /// Creates and configures the local repository and initally pulls a set of changes to start with if a remote repository is configured. /// </summary> /// <param name="result">The integration result.</param> /// <returns>The repository status (newly created, already exists or unknown).</returns> /// <remarks>The file system and file directory creator are used to delete and create the directory holding the repository.</remarks> private RepositoryStatus HgCreateLocalRepository(IIntegrationResult result) { string workingDirectory = BaseWorkingDirectory(result); string hgRepositoryDirectory = Path.Combine(workingDirectory, ".hg"); if (!_fileSystem.DirectoryExists(workingDirectory)) { Log.Debug(string.Concat("[Mercurial] Working directory '", workingDirectory, "' does not exist.")); HgInit(result); HgConfigureRepository(result); if (!string.IsNullOrEmpty(Repository)) { HgPull(result); } return(RepositoryStatus.Created); } if (!_fileSystem.DirectoryExists(hgRepositoryDirectory)) { Log.Debug(string.Concat("[Mercurial] Working directory '", workingDirectory, "' already exists, but it is not a hg repository. Try deleting it and starting again.")); _fileDirectoryDeleter.DeleteIncludingReadOnlyObjects(workingDirectory); return(HgCreateLocalRepository(result)); } return(RepositoryStatus.AlreadyExists); }
/// <summary> /// Executes the specified result. /// </summary> /// <param name="result">The result.</param> /// <returns></returns> /// <remarks></remarks> protected override bool Execute(IIntegrationResult result) { string gendarmeOutputFile = GetGendarmeOutputFile(result); //delete old nant output logfile, if exist fileDirectoryDeleter.DeleteIncludingReadOnlyObjects(gendarmeOutputFile); result.BuildProgressInformation.SignalStartRunTask(!string.IsNullOrEmpty(Description) ? Description : "Executing Gendarme to verifiy assemblies."); var info = CreateProcessInfo(result); ProcessResult processResult = TryToRun(CreateProcessInfo(result), result); if (File.Exists(gendarmeOutputFile)) { result.AddTaskResult(new FileTaskResult(gendarmeOutputFile)); } result.AddTaskResult(new ProcessTaskResult(processResult, true)); if (processResult.TimedOut) { result.AddTaskResult(MakeTimeoutBuildResult(info)); } return(processResult.Succeeded); }
/// <summary> /// Runs the integration using NAnt. The build number is provided for labelling, build /// timeouts are enforced. The specified targets are used for the specified NAnt build file. /// StdOut from nant.exe is redirected and stored. /// </summary> /// <param name="result">For storing build output.</param> protected override bool Execute(IIntegrationResult result) { string nantOutputFile = GetNantOutputFile(result); //delete old nant output logfile, if exist fileDirectoryDeleter.DeleteIncludingReadOnlyObjects(nantOutputFile); result.BuildProgressInformation.SignalStartRunTask(!string.IsNullOrEmpty(Description) ? Description : string.Format(System.Globalization.CultureInfo.CurrentCulture, "Executing Nant :BuildFile: {0} Targets: {1} ", BuildFile, string.Join(", ", Targets))); var info = CreateProcessInfo(result); ProcessResult processResult = TryToRun(info, result); if (File.Exists(nantOutputFile)) { result.AddTaskResult(new FileTaskResult(nantOutputFile)); } result.AddTaskResult(new ProcessTaskResult(processResult, true)); if (processResult.TimedOut) { result.AddTaskResult(MakeTimeoutBuildResult(info)); } return(processResult.Succeeded); }
/// <summary> /// Fetches a git repository. /// /// If the working directory doesn't exist then a 'git clone' is issued to /// initialize the local repo and fetch changes from the remote repo. /// Also setup the local repository with some required configuration settings. /// /// Else if the .git directory doesn't exist then delete the working directory /// and call the method recursive again. /// /// Else if the working directory is already a git repository then a 'git fetch' /// is issued to fetch changes from the remote repo. /// </summary> /// <param name="result">IIntegrationResult of the current build.</param> /// <returns>The action that was done, repository created or updated.</returns> private RepositoryAction CreateUpateLocalRepository(IIntegrationResult result) { string workingDirectory = BaseWorkingDirectory(result); string gitRepositoryDirectory = Path.Combine(workingDirectory, ".git"); // check whether the working directory exist if (!_fileSystem.DirectoryExists(workingDirectory)) { Log.Debug(string.Concat("[Git] Working directory '", workingDirectory, "' does not exist.")); // if the working does not exist, call git clone GitClone(result); // init submodules if (FetchSubmodules) { GitInitSubmodules(result); } // setup some required configuration settings for the local repository SetupLocalRepository(result); return(RepositoryAction.Created); } // check whether this is a local git repository or just an existing folder if (!_fileSystem.DirectoryExists(gitRepositoryDirectory)) { Log.Debug(string.Concat("[Git] Working directory '", workingDirectory, "' already exists, but it is not a git repository. Try deleting it and starting again.")); // delete working directory and call CreateUpateLocalRepository recursive _fileDirectoryDeleter.DeleteIncludingReadOnlyObjects(workingDirectory); return(CreateUpateLocalRepository(result)); } // we are in a local git repository, fetch the latest remote changes GitFetch(result); return(RepositoryAction.Updated); }
/// <summary> /// Gets the source. /// </summary> /// <param name="result">The result.</param> /// <remarks></remarks> public override void GetSource(IIntegrationResult result) { result.BuildProgressInformation.SignalStartRunTask("Getting source from Vault"); if (!_shim.AutoGetSource) { return; } Debug.Assert(_folderVersion > 0, "_folderVersion <= 0 when attempting to get source. This shouldn't happen."); //todo remove all debug.assert statements, replace by throw exception if (_shim.CleanCopy) { string cleanCopyWorkingFolder = null; if (string.IsNullOrEmpty(_shim.WorkingDirectory)) { cleanCopyWorkingFolder = GetVaultWorkingFolder(result); if (string.IsNullOrEmpty(cleanCopyWorkingFolder)) { throw new VaultException( string.Format(System.Globalization.CultureInfo.CurrentCulture, "Vault user {0} has no working folder set for {1} in repository {2} and no working directory has been specified.", _shim.Username, _shim.Folder, _shim.Repository)); } } else { cleanCopyWorkingFolder = result.BaseFromWorkingDirectory(_shim.WorkingDirectory); } Log.Debug("Cleaning out source folder: " + cleanCopyWorkingFolder); fileDirectoryDeleter.DeleteIncludingReadOnlyObjects(cleanCopyWorkingFolder); System.IO.Directory.CreateDirectory(cleanCopyWorkingFolder); } Log.Info("Getting source from Vault"); Execute(GetSourceProcessInfo(result)); }