/// <summary> /// Run the specified executable and add its output to the build results. /// </summary> /// <param name="result">the IIntegrationResult object for the build</param> protected override bool Execute(IIntegrationResult result) { result.BuildProgressInformation.SignalStartRunTask(!string.IsNullOrEmpty(Description) ? Description : string.Format(System.Globalization.CultureInfo.CurrentCulture, "Executing {0}", Executable)); ProcessInfo info = CreateProcessInfo(result); ProcessResult processResult = TryToRun(info, result); if (!StringUtil.IsWhitespace(processResult.StandardOutput) || !StringUtil.IsWhitespace(processResult.StandardError)) { // The executable produced some output. We need to transform it into an XML build report // fragment so the rest of CC.Net can process it. ProcessResult newResult = new ProcessResult( StringUtil.MakeBuildResult(processResult.StandardOutput, string.Empty), StringUtil.MakeBuildResult(processResult.StandardError, "Error"), processResult.ExitCode, processResult.TimedOut, processResult.Failed); processResult = newResult; } result.AddTaskResult(new ProcessTaskResult(processResult)); if (processResult.TimedOut) { result.AddTaskResult(MakeTimeoutBuildResult(info)); } return(processResult.Succeeded); }
/// <summary> /// Executes the specified result. /// </summary> /// <param name="result">The result.</param> /// <returns></returns> /// <remarks></remarks> protected override bool Execute(IIntegrationResult result) { result.BuildProgressInformation.SignalStartRunTask(!string.IsNullOrEmpty(Description) ? Description : string.Format(System.Globalization.CultureInfo.CurrentCulture, "Executing Devenv :{0}", GetArguments(result))); ProcessResult processResult = TryToRun(result); // rei added 30.5.2010, merge devenv output to task result string buildOutputFile = DevEnvOutputFile(result); if (File.Exists(buildOutputFile)) { result.AddTaskResult(new FileTaskResult(buildOutputFile) { WrapInCData = true }); } result.AddTaskResult(new DevenvTaskResult(processResult)); Log.Info("Devenv build complete. Status: " + result.Status); if (processResult.TimedOut) { throw new BuilderException(this, string.Format(System.Globalization.CultureInfo.CurrentCulture, "Devenv process timed out after {0} seconds.", BuildTimeoutSeconds)); } return(!processResult.Failed); }
/// <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> /// Run the task. /// </summary> /// <param name="result"></param> protected override bool Execute(IIntegrationResult result) { result.BuildProgressInformation.SignalStartRunTask(!string.IsNullOrEmpty(Description) ? Description : "Running NCover profile"); // Make sure there is a root directory rootPath = BaseDirectory; if (string.IsNullOrEmpty(rootPath)) { rootPath = result.WorkingDirectory; } // Run the executable var info = this.CreateProcessInfo(result); var processResult = this.TryToRun(info, result); result.AddTaskResult(new ProcessTaskResult(processResult, false)); if (processResult.TimedOut) { result.AddTaskResult(MakeTimeoutBuildResult(info)); } if (Publish && processResult.Succeeded) { var coverageFile = string.IsNullOrEmpty(CoverageFile) ? "coverage.xml" : CoverageFile; result.AddTaskResult(new FileTaskResult(RootPath(coverageFile, false))); } return(processResult.Succeeded); }
public void Run(IIntegrationResult result) { ProcessResult processResult = executor.Execute(NewProcessInfo(result)); string buildOutputFile = MsBuildOutputFile(result); if (File.Exists(buildOutputFile)) { result.AddTaskResult(new FileTaskResult(buildOutputFile)); } result.AddTaskResult(new ProcessTaskResult(processResult)); }
/// <summary> /// Run the task. /// </summary> /// <param name="result"></param> protected override bool Execute(IIntegrationResult result) { result.BuildProgressInformation.SignalStartRunTask(!string.IsNullOrEmpty(Description) ? Description : "Running CodeItRight analysis"); // Run the executable var info = this.CreateProcessInfo(result); var processResult = this.TryToRun(info, result); // Need to start a new result as CodeItRight returns the number of violation processResult = new ProcessResult( processResult.StandardOutput, processResult.StandardError, processResult.ExitCode, processResult.TimedOut, processResult.ExitCode < 0); result.AddTaskResult(new ProcessTaskResult(processResult)); if (processResult.TimedOut) { result.AddTaskResult(MakeTimeoutBuildResult(info)); } if (processResult.Succeeded) { var xmlFile = result.BaseFromWorkingDirectory("codeitright.xml"); result.AddTaskResult( fileSystem.GenerateTaskResultFromFile(xmlFile, true)); } // Check the failure threshold var failed = !processResult.Succeeded; if (!failed && (this.FailureThreshold != Severity.None)) { var xmlFile = result.BaseFromWorkingDirectory("codeitright.xml"); var document = new XmlDocument(); if (this.fileSystem.FileExists(xmlFile)) { using (var stream = this.fileSystem.OpenInputStream(xmlFile)) { document.Load(stream); } for (var level = (int)Severity.CriticalError; level >= (int)this.FailureThreshold; level--) { failed = CodeItRightTask.CheckReportForSeverity(document, (Severity)level); if (failed) { break; } } } } return(!failed); }
/// <summary> /// Execute the actual task functionality. /// </summary> /// <param name="result">The result to use.</param> /// <returns> /// <c>true</c> if the task was successful; <c>false</c> otherwise. /// </returns> protected override bool Execute(IIntegrationResult result) { result.BuildProgressInformation.SignalStartRunTask(!string.IsNullOrEmpty(Description) ? Description : "Updating configuration"); var fileSystem = this.FileSystem ?? new SystemIoFileSystem(); // Check if the config file exists var configFile = this.FindConfigFile(result, fileSystem); if (configFile == null) { return(true); } // Check for any differences var currentFile = PathUtils.ConfigFileLocation; var updateFile = this.AlwaysUpdate || HasDifferences(fileSystem, configFile, currentFile); if (!updateFile) { Log.Info("Skipping validation and copy - nothing has changed"); return(true); } // Validate the file if (this.ValidateFile) { this.fileToValidate = configFile; this.validationLogFile = Path.GetTempFileName(); Log.Info("Executing CCValidator"); var info = this.CreateProcessInfo(result); var processResult = this.TryToRun(info, result); if (processResult.TimedOut) { Log.Warning("CCValidator timed out"); result.AddTaskResult(MakeTimeoutBuildResult(info)); return(false); } // Check the results result.AddTaskResult(new ProcessTaskResult(processResult, false)); result.AddTaskResult(fileSystem.GenerateTaskResultFromFile(this.validationLogFile, true)); if (processResult.Failed) { Log.Warning("CCValidator failed"); return(false); } } // Update the file Log.Info("Copying config file to '{0}'", currentFile); fileSystem.Copy(configFile, currentFile); return(true); }
/// <summary> /// Run the task. /// </summary> /// <param name="result">The result to use.</param> /// <returns> /// True if the task was successful, false otherwise. /// </returns> protected override bool Execute(IIntegrationResult result) { result.BuildProgressInformation.SignalStartRunTask(!string.IsNullOrEmpty(Description) ? Description : "Executing DupFinder"); this.logger = this.logger ?? new DefaultLogger(); this.executable = string.IsNullOrEmpty(this.Executable) ? DefaultExecutable : this.Executable; if (!Path.IsPathRooted(this.executable)) { this.executable = result.BaseFromWorkingDirectory(this.executable); this.logger.Debug("Executable changed to " + this.executable); } // Run the executable this.logger.Info("Executing DupFinder"); var info = this.CreateProcessInfo(result); var processResult = this.TryToRun(info, result); if (processResult.TimedOut) { result.AddTaskResult(MakeTimeoutBuildResult(info)); } if (this.ShortenFileNames || this.IncludeCode) { // Load the results into an XML document var document = new XmlDocument(); document.LoadXml(processResult.StandardOutput); if (this.IncludeCode) { this.logger.Info("Including duplicate code lines"); this.ImportCode(document); } if (this.ShortenFileNames) { this.logger.Info("Shortening filenames"); this.RemoveInputDir(document); } // Generate a new result processResult = new ProcessResult( document.OuterXml, processResult.StandardError, processResult.ExitCode, processResult.TimedOut, processResult.Failed); } // Add the result result.AddTaskResult(new ProcessTaskResult(processResult, false)); return(processResult.Succeeded); }
protected override bool Execute(IIntegrationResult result) { var info = this.CreateProcessInfo(result); var processResult = this.TryToRun( info, result); result.AddTaskResult(new ProcessTaskResult(processResult)); if (processResult.TimedOut) result.AddTaskResult(MakeTimeoutBuildResult(info)); return processResult.Succeeded; }
protected override bool Execute(IIntegrationResult result) { ProcessInfo processInfo = this.CreateProcessInfo(result); ProcessResult run = base.TryToRun(processInfo, result); result.AddTaskResult(run.StandardOutput); result.AddTaskResult(new ProcessTaskResult(run, true)); if (run.TimedOut) { result.AddTaskResult(BaseExecutableTask.MakeTimeoutBuildResult(processInfo)); } return(run.Succeeded); }
/// <summary> /// Run the task. /// </summary> /// <param name="result"></param> protected override bool Execute(IIntegrationResult result) { result.BuildProgressInformation.SignalStartRunTask(!string.IsNullOrEmpty(Description) ? Description : "Running NCover reporting"); // Make sure there is a root directory rootPath = BaseDirectory; if (string.IsNullOrEmpty(rootPath)) { rootPath = result.WorkingDirectory; } // Take a before snapshot of all the files var outputDirectory = new DirectoryInfo(RootPath(OutputDir, false)); var oldFiles = GenerateOriginalFileList(outputDirectory); // Run the executable var info = this.CreateProcessInfo(result); var processResult = this.TryToRun(info, result); result.AddTaskResult(new ProcessTaskResult(processResult, false)); if (processResult.TimedOut) { result.AddTaskResult(MakeTimeoutBuildResult(info)); } // Check for any new files and copy them to the artefact folder if (processResult.Succeeded) { outputDirectory.Refresh(); var newFiles = ListFileDifferences(oldFiles, outputDirectory); if (newFiles.Length > 0) { // Copy all the new files over var publishDir = Path.Combine(result.BaseFromArtifactsDirectory(result.Label), "NCover"); Log.Debug(string.Format(System.Globalization.CultureInfo.CurrentCulture, "Copying {0} files to {1}", newFiles.Length, publishDir)); var index = outputDirectory.FullName.Length + 1; foreach (FileInfo newFile in newFiles) { var fileInfo = new FileInfo(Path.Combine(publishDir, newFile.FullName.Substring(index))); if (!fileInfo.Directory.Exists) { fileInfo.Directory.Create(); } newFile.CopyTo(fileInfo.FullName, true); } } } return(processResult.Succeeded); }
protected override bool Execute(IIntegrationResult result) { var info = this.CreateProcessInfo(result); var processResult = this.TryToRun( info, result); result.AddTaskResult(new ProcessTaskResult(processResult)); if (processResult.TimedOut) { result.AddTaskResult(MakeTimeoutBuildResult(info)); } return(processResult.Succeeded); }
public virtual void Run(IIntegrationResult result) { string outputFile = result.BaseFromArtifactsDirectory(OutputFile); ProcessResult nunitResult = processExecutor.Execute(NewProcessInfo(outputFile, result)); result.AddTaskResult(new ProcessTaskResult(nunitResult)); if (File.Exists(outputFile)) { result.AddTaskResult(new FileTaskResult(outputFile)); } else { Log.Warning(string.Format("NUnit test output file {0} was not created", outputFile)); } }
protected override bool Execute(IIntegrationResult result) { BuildProgressInformation buildProgressInformation = result.BuildProgressInformation; buildProgressInformation.SignalStartRunTask($"Executing Nunit{Version}"); ProcessInfo processInfo = this.CreateProcessInfo(result); ProcessResult run = base.TryToRun(processInfo, result); result.AddTaskResult(new ProcessTaskResult(run, true)); if (run.TimedOut) { result.AddTaskResult(BaseExecutableTask.MakeTimeoutBuildResult(processInfo)); } return(run.Succeeded); }
public void Run(IIntegrationResult result) { foreach (string mergeFile in MergeFiles) { string fullMergeFile = mergeFile; if (!Path.IsPathRooted(mergeFile)) { fullMergeFile = Path.Combine(result.WorkingDirectory, mergeFile); } WildCardPath path = new WildCardPath(fullMergeFile); FileInfo[] files = path.GetFiles(); foreach (FileInfo fileInfo in files) { Log.Info("Merging file: " + fileInfo); if (fileInfo.Exists) { result.AddTaskResult((new FileTaskResult(fileInfo))); } else { Log.Warning("File not Found: " + fileInfo); } } } }
public override void GetSource(IIntegrationResult result) { var processResult = this.ExecuteCommand(result, "get"); result.AddTaskResult( new ProcessTaskResult(processResult)); }
public virtual void Run(IIntegrationResult result) { string outputFile = result.BaseFromArtifactsDirectory(OutputFile); ProcessResult nunitResult = processExecutor.Execute(NewProcessInfo(outputFile, result), result.ProjectName); result.AddTaskResult(new ProcessTaskResult(nunitResult)); if (File.Exists(outputFile)) { result.AddTaskResult(new FileTaskResult(outputFile)); } else { Log.Warning(string.Format("NUnit test output file {0} was not created", outputFile)); } }
public void Run(IIntegrationResult result) { if (result.Succeeded) { return; } if (this.BadChangeSet == null) { Log.Debug("The changeset to rollback has not been set."); return; } string Arguments = string.Format("rollback /changeset:{0} /noprompt", this.BadChangeSet.ChangesetId); ProcessInfo Info = new ProcessInfo(this.Executable, Arguments, this.BaseDirectory); try { ProcessResult RollBackResult = this.Executor.Execute(Info); result.AddTaskResult(new ProcessTaskResult(RollBackResult)); } catch (Exception ProcessException) { throw new BuilderException(this, string.Format("Unable to RollBack: {0}\n{1}", Info, ProcessException), ProcessException); } finally { this.BadChangeSet = null; } }
public void Run(IIntegrationResult result) { result.BuildProgressInformation.SignalStartRunTask(String.Format("Building MSI package {0} with Advanced Installer", result.ProjectName)); AdvancedInstallerResult aiResult = AttemptToBuild(result); result.AddTaskResult(aiResult); }
/// <summary> /// Executes the specified result. /// </summary> /// <param name="result">The result.</param> /// <returns></returns> /// <remarks></remarks> protected override bool Execute(IIntegrationResult result) { result.BuildProgressInformation.SignalStartRunTask(!string.IsNullOrEmpty(Description) ? Description : "Executing null task"); System.Threading.Thread.Sleep(5000); if (SimulateFailure) { result.AddTaskResult(SimulateFailureMessage); throw new System.Exception(SimulateFailureMessage); } else { result.AddTaskResult("All OK for " + (!string.IsNullOrEmpty(Description) ? Description : "Null task")); } return true; }
/// <summary> /// Executes the specified result. /// </summary> /// <param name="result">The result.</param> /// <returns></returns> /// <remarks></remarks> protected override bool Execute(IIntegrationResult result) { result.BuildProgressInformation.SignalStartRunTask(!string.IsNullOrEmpty(Description) ? Description : "Executing null task"); System.Threading.Thread.Sleep(5000); if (SimulateFailure) { result.AddTaskResult(SimulateFailureMessage); throw new System.Exception(SimulateFailureMessage); } else { result.AddTaskResult("All OK for " + (!string.IsNullOrEmpty(Description) ? Description : "Null task")); } return(!SimulateFailure); }
internal void Set(IIntegrationResult result) { string physicalPath = GetPhysicalPath(result); result.AddTaskResult("SiteName:" + SiteName); using (var iis = new ServerManager()) { Site site = iis.Sites[SiteName]; if (site == null) { site = iis.Sites.Add(SiteName, physicalPath, 0); site.Bindings.Clear(); } else { return; } SetSiteOption(site); site.Name = SiteName; site.ApplicationDefaults.ApplicationPoolName = PoolName; ApplicationPool pool = iis.ApplicationPools[PoolName]; if (pool == null) { pool = iis.ApplicationPools.Add(PoolName); } SetApplicationPoolOption(pool); pool.Name = PoolName; // set binginds site.Bindings.Clear(); foreach (var binding in Bindings) { if (binding.HasSSL) { site.Bindings.Add(binding.GetBindingInfomation(), binding.GetCertificateHash(), binding.GetCertificateStoreName()); } else { site.Bindings.Add(binding.GetBindingInfomation(), binding.GetBindingProtocol()); } } // set virtualPath var defaultPath = site.Applications[0].VirtualDirectories["/"]; site.Applications[0].VirtualDirectories.Clear(); site.Applications[0].VirtualDirectories.Add(defaultPath); foreach (var vd in VirtualDirectories) { site.Applications[0].VirtualDirectories.Add(vd.Key, vd.Value); } iis.CommitChanges(); } }
public void Run(IIntegrationResult result) { ProcessResult processResult = AttemptToExecute(NewProcessInfoFrom(result)); result.AddTaskResult(new ProcessTaskResult(processResult)); if (processResult.TimedOut) { throw new BuilderException(this, "Command Line Build timed out (after " + BuildTimeoutSeconds + " seconds)"); } }
public override void LabelSourceControl(IIntegrationResult result) { if (result.Succeeded) { var processResult = this.ExecuteCommand(result, "label", result.Label); result.AddTaskResult( new ProcessTaskResult(processResult)); } }
/// <summary> /// Execute the actual task functionality. /// </summary> /// <param name="result">The result details to use.</param> /// <returns> /// True if the task was successful, false otherwise. /// </returns> protected override bool Execute(IIntegrationResult result) { result.BuildProgressInformation .SignalStartRunTask("Adding a comment to the log"); (this.Logger ?? new DefaultLogger()) .Debug("Logging " + (this.FailTask ? "error " : string.Empty) + "message: " + this.Message); result.AddTaskResult( new GeneralTaskResult(!this.FailTask, Message)); return true; }
/// <summary> /// Execute the actual task functionality. /// </summary> /// <param name="result">The result details to use.</param> /// <returns> /// True if the task was successful, false otherwise. /// </returns> protected override bool Execute(IIntegrationResult result) { result.BuildProgressInformation .SignalStartRunTask("Adding a comment to the log"); (this.Logger ?? new DefaultLogger()) .Debug("Logging " + (this.FailTask ? "error " : string.Empty) + "message: " + this.Message); result.AddTaskResult( new GeneralTaskResult(!this.FailTask, Message)); return(true); }
protected override bool Execute(IIntegrationResult result) { SetDefaultEnvironmentVariable(); BuildProgressInformation buildProgressInformation = result.BuildProgressInformation; buildProgressInformation.SignalStartRunTask($"Executing TqRsync"); ProcessInfo processInfo = this.CreateProcessInfo(result); result.AddTaskResult(processInfo.FileName + " " + processInfo.Arguments); ProcessResult run = base.TryToRun(processInfo, result); result.AddTaskResult(new ProcessTaskResult(run, true)); if (run.TimedOut) { result.AddTaskResult(BaseExecutableTask.MakeTimeoutBuildResult(processInfo)); } return(run.Succeeded); }
public void Run(IIntegrationResult result) { foreach (FilePair Pair in this.FilePairs) { string XmlFilePath = Pair.XmlFile; if (!Path.IsPathRooted(XmlFilePath)) { XmlFilePath = Path.Combine(result.WorkingDirectory, XmlFilePath); } string XslFilePath = Pair.XslFile; if (!Path.IsPathRooted(XslFilePath)) { XslFilePath = Path.Combine(result.WorkingDirectory, XslFilePath); } string XslFileName = Path.GetFileName(XslFilePath); if (!File.Exists(XslFilePath)) { Log.Warning("File not Found: " + XslFileName); } WildCardPath Pattern = new WildCardPath(XmlFilePath); FileInfo[] Files = Pattern.GetFiles(); foreach (FileInfo XmlFileInfo in Files) { Log.Info(String.Format("Merging file {0} through {1}", XmlFileInfo, XslFileName)); if (XmlFileInfo.Exists) { string Data; String Contents; using (TextReader Reader = XmlFileInfo.OpenText()) { Contents = Reader.ReadToEnd(); } XslTransformer Transformer = new XslTransformer(); Dictionary <string, string> XslParms = new Dictionary <string, string>(); XslParms.Add("CCNetServer", this.DashboardServerName); XslParms.Add("CCNetBuild", new LogFile(result).Filename); XslParms.Add("CCNetProject", result.ProjectName); XslParms.Add("XmlSourceName", Path.GetFileName(XmlFilePath)); XslParms.Add("XmlSourcePath", XmlFileInfo.FullName); Data = Transformer.Transform(Contents, XslFilePath, XslParms); result.AddTaskResult((new XslMergerTaskResult(Data))); } else { Log.Warning("File not Found: " + XmlFileInfo); } } } }
protected override bool Execute(IIntegrationResult result) { result.BuildProgressInformation .SignalStartRunTask("Sending a hello world greeting"); for (var loop = 0; loop < this.RepeatCount; loop++) { result.AddTaskResult( new HelloWorldTaskResult(this.PersonsName, result)); } return(true); }
public void Run(IIntegrationResult result) { if (_reportFileName.Equals(String.Empty)) _reportFileName = result.ProjectName; _instrument.NUnitTask = _nunit; _instrument.ReportName = _reportFileName; _instrument.Instrument(); _builder.Run(result); _nunit.Run(result); _instrument.Report(); result.AddTaskResult(new FileTaskResult(new FileInfo(_reportFileName))); }
protected override bool Execute(IIntegrationResult result) { result.BuildProgressInformation .SignalStartRunTask("Sending a hello world greeting"); for (var loop = 0; loop < this.RepeatCount; loop++) { result.AddTaskResult( new HelloWorldTaskResult(this.PersonsName, result)); } return true; }
public virtual void Run(IIntegrationResult result) { ProcessResult processResult = AttemptToExecute(result.WorkingDirectory); result.AddTaskResult(new DevenvTaskResult(processResult)); Log.Info("Devenv build complete. Status: " + result.Status); if (processResult.TimedOut) { throw new BuilderException(this, string.Format("Devenv process timed out after {0} seconds.", BuildTimeoutSeconds)); } }
/// <summary> /// Executes the specified result. /// </summary> /// <param name="result">The result.</param> /// <returns></returns> /// <remarks></remarks> protected override bool Execute(IIntegrationResult result) { result.BuildProgressInformation.SignalStartRunTask(!string.IsNullOrEmpty(Description) ? Description : "Executing NUnit"); string outputFile = result.BaseFromArtifactsDirectory(OutputFile); ProcessResult nunitResult = executor.Execute(NewProcessInfo(outputFile, result)); DeleteNUnitAgentProcesses(); result.AddTaskResult(new ProcessTaskResult(nunitResult, true)); if (File.Exists(outputFile)) { result.AddTaskResult(new FileTaskResult(outputFile)); } else { Log.Warning(string.Format(System.Globalization.CultureInfo.CurrentCulture, "NUnit test output file {0} was not created", outputFile)); } return(!nunitResult.Failed); }
/// <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> public void Run(IIntegrationResult result) { ProcessResult processResult = AttemptExecute(CreateProcessInfo(result), result.ProjectName); result.AddTaskResult(new ProcessTaskResult(processResult)); // is this right?? or should this break the build if (processResult.TimedOut) { throw new BuilderException(this, "NAnt process timed out (after " + BuildTimeoutSeconds + " seconds)"); } }
public void Run(IIntegrationResult result) { result.BuildProgressInformation .SignalStartRunTask("Sending a hello world greeting"); for (var loop = 0; loop < this.RepeatCount; loop++) { result.AddTaskResult("Hello " + this.PersonsName + " from " + result.ProjectName + "(build started " + result.StartTime.ToString() + ")"); } result.Status = IntegrationStatus.Success; }
public void Run(IIntegrationResult result) { result.BuildProgressInformation .SignalStartRunTask("Sending a hello world greeting"); for (var loop = 0; loop < this.RepeatCount; loop++) { result.AddTaskResult("Hello " + this.PersonsName + " from " + result.ProjectName + "(build started " + result.StartTime + ")"); } result.Status = IntegrationStatus.Success; }
public void Run(IIntegrationResult result) { foreach (FilePair Pair in this.FilePairs) { string XmlFilePath = Pair.XmlFile; if (!Path.IsPathRooted(XmlFilePath)) { XmlFilePath = Path.Combine(result.WorkingDirectory, XmlFilePath); } string XslFilePath = Pair.XslFile; if (!Path.IsPathRooted(XslFilePath)) { XslFilePath = Path.Combine(result.WorkingDirectory, XslFilePath); } string XslFileName = Path.GetFileName(XslFilePath); if (!File.Exists(XslFilePath)) { Log.Warning("File not Found: " + XslFileName); } WildCardPath Pattern = new WildCardPath(XmlFilePath); FileInfo[] Files = Pattern.GetFiles(); foreach (FileInfo XmlFileInfo in Files) { Log.Info(String.Format("Merging file {0} through {1}", XmlFileInfo, XslFileName)); if (XmlFileInfo.Exists) { string Data; String Contents; using (TextReader Reader = XmlFileInfo.OpenText()) { Contents = Reader.ReadToEnd(); } XslTransformer Transformer = new XslTransformer(); Data = Transformer.Transform(Contents, XslFilePath, new Dictionary<string, string>()); result.AddTaskResult((new XslMergerTaskResult(Data))); } else { Log.Warning("File not Found: " + XmlFileInfo); } } } }
/// <summary> /// Run the specified PowerShell and add its output to the build results. /// </summary> /// <param name="result">the IIntegrationResult object for the build</param> protected override bool Execute(IIntegrationResult result) { result.BuildProgressInformation.SignalStartRunTask(string.Format("Executing {0}", Executable)); ProcessInfo processInfo = NewProcessInfoFrom(result); ProcessResult processResult = AttemptToExecute(processInfo); if (!StringUtil.IsWhitespace(processResult.StandardOutput) || !StringUtil.IsWhitespace(processResult.StandardError)) { // The PowerShell produced some output. We need to transform it into an XML build report // fragment so the rest of CC.Net can process it. ProcessResult newResult = new ProcessResult( MakeBuildResult(processResult.StandardOutput,string.Empty), MakeBuildResult(processResult.StandardError, "Error"), processResult.ExitCode, processResult.TimedOut, processResult.Failed); processResult = newResult; } result.AddTaskResult(new ProcessTaskResult(processResult)); if (processResult.TimedOut) { throw new BuilderException(this, "Command Line Build timed out (after " + BuildTimeoutSeconds + " seconds)"); } return !processResult.Failed; }
public void Run(IIntegrationResult result) { result.AddTaskResult(string.Format("Task #{0} has run", TaskNumber)); result.Status = Result; }
/// <summary> /// Run the specified executable and add its output to the build results. /// </summary> /// <param name="result">the IIntegrationResult object for the build</param> protected override bool Execute(IIntegrationResult result) { result.BuildProgressInformation.SignalStartRunTask(!string.IsNullOrEmpty(Description) ? Description : string.Format(System.Globalization.CultureInfo.CurrentCulture, "Executing {0}", Executable)); ProcessInfo info = CreateProcessInfo(result); ProcessResult processResult = TryToRun(info, result); if (!StringUtil.IsWhitespace(processResult.StandardOutput) || !StringUtil.IsWhitespace(processResult.StandardError)) { // The executable produced some output. We need to transform it into an XML build report // fragment so the rest of CC.Net can process it. ProcessResult newResult = new ProcessResult( StringUtil.MakeBuildResult(processResult.StandardOutput, string.Empty, this), StringUtil.MakeBuildResult(processResult.StandardError, "Error", this), processResult.ExitCode, processResult.TimedOut, processResult.Failed); processResult = newResult; } result.AddTaskResult(new ProcessTaskResult(processResult)); if (processResult.TimedOut) result.AddTaskResult(MakeTimeoutBuildResult(info)); return processResult.Succeeded; }
private void AddUserNameToResults(IIntegrationResult result, UserInformation UserInfo) { result.AddTaskResult(string.Format("<ForcedBuildInformation UserName=\"{0}\" />", UserInfo.Name)); }
/// <summary> /// Executes the specified result. /// </summary> /// <param name="result">The result.</param> /// <returns></returns> /// <remarks></remarks> protected override bool Execute(IIntegrationResult result) { result.BuildProgressInformation.SignalStartRunTask(!string.IsNullOrEmpty(Description) ? Description : string.Format(System.Globalization.CultureInfo.CurrentCulture,"Executing FinalBuilder : BuildFile: {0} ", ProjectFile)); ProcessResult processResult = AttemptToExecute(NewProcessInfoFrom(result), result.ProjectName); result.AddTaskResult(new ProcessTaskResult(processResult)); if (processResult.TimedOut) { throw new BuilderException(this, "Build timed out (after " + Timeout + " seconds)"); } return !processResult.Failed; }
/// <summary> /// Executes the specified result. /// </summary> /// <param name="result">The result.</param> /// <returns></returns> /// <remarks></remarks> protected override bool Execute(IIntegrationResult result) { result.BuildProgressInformation.SignalStartRunTask(!string.IsNullOrEmpty(Description) ? Description : string.Format(System.Globalization.CultureInfo.CurrentCulture, "Executing Devenv :{0}", GetArguments(result))); ProcessResult processResult = TryToRun(result); // rei added 30.5.2010, merge devenv output to task result string buildOutputFile = DevEnvOutputFile(result); if (File.Exists(buildOutputFile)) result.AddTaskResult(new FileTaskResult(buildOutputFile) { WrapInCData = true }); result.AddTaskResult(new DevenvTaskResult(processResult)); Log.Info("Devenv build complete. Status: " + result.Status); if (processResult.TimedOut) throw new BuilderException(this, string.Format(System.Globalization.CultureInfo.CurrentCulture, "Devenv process timed out after {0} seconds.", BuildTimeoutSeconds)); return !processResult.Failed; }
/// <summary> /// Execute the actual task functionality. /// </summary> /// <param name="result"></param> /// <returns> /// True if the task was successful, false otherwise. /// </returns> protected override bool Execute(IIntegrationResult result) { result.BuildProgressInformation.SignalStartRunTask(!string.IsNullOrEmpty(Description) ? Description : "Publishing build results"); if (result.Succeeded || AlwaysPublish) { var srcDir = new DirectoryInfo(result.BaseFromWorkingDirectory(SourceDir)); var pubDir = new DirectoryInfo(result.BaseFromArtifactsDirectory(PublishDir)); Log.Debug("Publish directory is '{0}'", pubDir.FullName); Log.Debug("Source directory is '{0}'", srcDir.FullName); if (!srcDir.Exists) { Log.Warning("Source directory '{0}' does not exist - cancelling task", srcDir.FullName); var errorResult = new GeneralTaskResult( false, "Unable to find source directory '" + srcDir.FullName + "'"); result.AddTaskResult(errorResult); return false; } if (!pubDir.Exists) { Log.Info("Publish directory '{0}' does not exist - creating", pubDir.FullName); pubDir.Create(); } else { if (CleanPublishDirPriorToCopy) { DeleteFolder(pubDir.FullName); pubDir.Create(); } } if (UseLabelSubDirectory) pubDir = pubDir.CreateSubdirectory(result.Label); RecurseSubDirectories(srcDir, pubDir, this.Recurse); switch (CleanUpMethod) { case CleanupPolicy.NoCleaning: break; case CleanupPolicy.DeleteBuildsOlderThanXDays: DeleteSubDirsOlderThanXDays(new DirectoryInfo(result.BaseFromArtifactsDirectory(PublishDir)).FullName, CleanUpValue, result.BuildLogDirectory); break; case CleanupPolicy.KeepLastXBuilds: KeepLastXSubDirs(new DirectoryInfo(result.BaseFromArtifactsDirectory(PublishDir)).FullName, CleanUpValue, result.BuildLogDirectory); break; default: throw new System.Exception(string.Format(System.Globalization.CultureInfo.CurrentCulture, "unmapped cleaning method choosen {0}", CleanUpMethod)); } } return true; }
/// <summary> /// Run the task. /// </summary> /// <param name="result">The result to use.</param> /// <returns> /// True if the task was successful, false otherwise. /// </returns> protected override bool Execute(IIntegrationResult result) { result.BuildProgressInformation.SignalStartRunTask(!string.IsNullOrEmpty(Description) ? Description : "Executing DupFinder"); this.logger = this.logger ?? new DefaultLogger(); this.executable = string.IsNullOrEmpty(this.Executable) ? DefaultExecutable : this.Executable; if (!Path.IsPathRooted(this.executable)) { this.executable = result.BaseFromWorkingDirectory(this.executable); this.logger.Debug("Executable changed to " + this.executable); } // Run the executable this.logger.Info("Executing DupFinder"); var info = this.CreateProcessInfo(result); var processResult = this.TryToRun(info, result); if (processResult.TimedOut) { result.AddTaskResult(MakeTimeoutBuildResult(info)); } if (this.ShortenFileNames || this.IncludeCode) { // Load the results into an XML document var document = new XmlDocument(); document.LoadXml(processResult.StandardOutput); if (this.IncludeCode) { this.logger.Info("Including duplicate code lines"); this.ImportCode(document); } if (this.ShortenFileNames) { this.logger.Info("Shortening filenames"); this.RemoveInputDir(document); } // Generate a new result processResult = new ProcessResult( document.OuterXml, processResult.StandardError, processResult.ExitCode, processResult.TimedOut, processResult.Failed); } // Add the result result.AddTaskResult(new ProcessTaskResult(processResult, false)); return processResult.Succeeded; }
protected override bool Execute(IIntegrationResult result) { ProcessInfo processInfo = CreateProcessInfo(result); result.BuildProgressInformation.SignalStartRunTask(!string.IsNullOrEmpty(Description) ? Description : string.Format("Executing Rake: {0}", processInfo.PublicArguments)); ProcessResult processResult = TryToRun(processInfo, result); if (!StringUtil.IsWhitespace(processResult.StandardOutput) || !StringUtil.IsWhitespace(processResult.StandardError)) { // The executable produced some output. We need to transform it into an XML build report // fragment so the rest of CC.Net can process it. ProcessResult newResult = new ProcessResult( StringUtil.MakeBuildResult(processResult.StandardOutput,string.Empty), StringUtil.MakeBuildResult(processResult.StandardError, "Error"), processResult.ExitCode, processResult.TimedOut, processResult.Failed); processResult = newResult; } result.AddTaskResult(new ProcessTaskResult(processResult)); if (processResult.TimedOut) throw new BuilderException(this, "Command Line Build timed out (after " + BuildTimeoutSeconds + " seconds)"); return (!processResult.Failed); }
public void Run(IIntegrationResult result) { result.AddTaskResult(string.Format(System.Globalization.CultureInfo.CurrentCulture,"Task #{0} has run", TaskNumber)); result.Status = Result; }
/// <summary> /// Executes the specified result. /// </summary> /// <param name="result">The result.</param> /// <returns></returns> /// <remarks></remarks> protected override bool Execute(IIntegrationResult result) { result.BuildProgressInformation.SignalStartRunTask(!string.IsNullOrEmpty(Description) ? Description : "Executing NUnit"); string outputFile = result.BaseFromArtifactsDirectory(OutputFile); ProcessResult nunitResult = executor.Execute(NewProcessInfo(outputFile, result)); DeleteNUnitAgentProcesses(); result.AddTaskResult(new ProcessTaskResult(nunitResult, true)); if (File.Exists(outputFile)) { result.AddTaskResult(new FileTaskResult(outputFile)); } else { Log.Warning(string.Format(System.Globalization.CultureInfo.CurrentCulture,"NUnit test output file {0} was not created", outputFile)); } return !nunitResult.Failed; }
public void Run(IIntegrationResult result) { if (result.Succeeded) return; if (this.BadChangeSet == null) { Log.Debug("The changeset to rollback has not been set."); return; } string Arguments = string.Format("rollback /changeset:{0} /noprompt", this.BadChangeSet.ChangesetId); ProcessInfo Info = new ProcessInfo(this.Executable, Arguments, this.BaseDirectory); try { ProcessResult RollBackResult = this.Executor.Execute(Info); result.AddTaskResult(new ProcessTaskResult(RollBackResult)); } catch (Exception ProcessException) { throw new BuilderException(this, string.Format("Unable to RollBack: {0}\n{1}", Info, ProcessException), ProcessException); } finally { this.BadChangeSet = null; } }
/// <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> /// Execute the actual task functionality. /// </summary> /// <param name="result">The result to use.</param> /// <returns><c>true</c> if the task was successful; <c>false</c> otherwise.</returns> protected override bool Execute(IIntegrationResult result) { var fakeOutputFile = GetFakeOutputFile(result); //delete old nant output logfile, if exist fileDirectoryDeleter.DeleteIncludingReadOnlyObjects(fakeOutputFile); result.BuildProgressInformation.SignalStartRunTask(!string.IsNullOrEmpty(Description) ? Description : string.Format(System.Globalization.CultureInfo.CurrentCulture,"Executing FAKE - {0}", ToString())); var info = CreateProcessInfo(result); var processResult = TryToRun(info, result); if (File.Exists(fakeOutputFile)) result.AddTaskResult(new FileTaskResult(fakeOutputFile)); result.AddTaskResult(new ProcessTaskResult(processResult, true)); if (processResult.TimedOut) result.AddTaskResult(MakeTimeoutBuildResult(info)); return processResult.Succeeded; }
public void Run(IIntegrationResult result) { result.AddTaskResult(BUILDER_OUTPUT); HasRun = true; }
/// <summary> /// Run the task. /// </summary> /// <param name="result"></param> protected override bool Execute(IIntegrationResult result) { result.BuildProgressInformation.SignalStartRunTask(!string.IsNullOrEmpty(Description) ? Description : "Running CodeItRight analysis"); // Run the executable var processResult = TryToRun(CreateProcessInfo(result), result); // Need to start a new result as CodeItRight returns the number of violation processResult = new ProcessResult( processResult.StandardOutput, processResult.StandardError, processResult.ExitCode, processResult.TimedOut, processResult.ExitCode < 0); result.AddTaskResult(new ProcessTaskResult(processResult)); if (!processResult.Failed) { var xmlFile = result.BaseFromWorkingDirectory("codeitright.xml"); result.AddTaskResult( new FileTaskResult(xmlFile, true)); } // Check the failure threshold var failed = processResult.Failed; if (!failed && (this.FailureThreshold != Severity.None)) { var xmlFile = result.BaseFromWorkingDirectory("codeitright.xml"); var document = new XmlDocument(); if (File.Exists(xmlFile)) { document.Load(xmlFile); for (var level = (int)Severity.CriticalError; level >= (int)this.FailureThreshold; level--) { failed = CodeItRightTask.CheckReportForSeverity(document, (Severity)level); if (failed) { break; } } } } return !failed; }
/// <summary> /// Run the task. /// </summary> /// <param name="result"></param> protected override bool Execute(IIntegrationResult result) { result.BuildProgressInformation.SignalStartRunTask(!string.IsNullOrEmpty(Description) ? Description : "Running NCover reporting"); // Make sure there is a root directory rootPath = BaseDirectory; if (string.IsNullOrEmpty(rootPath)) rootPath = result.WorkingDirectory; // Take a before snapshot of all the files var outputDirectory = new DirectoryInfo(RootPath(OutputDir, false)); var oldFiles = GenerateOriginalFileList(outputDirectory); // Run the executable var processResult = TryToRun(CreateProcessInfo(result), result); result.AddTaskResult(new ProcessTaskResult(processResult)); // Check for any new files and copy them to the artefact folder if (!processResult.Failed) { outputDirectory.Refresh(); var newFiles = ListFileDifferences(oldFiles, outputDirectory); if (newFiles.Length > 0) { // Copy all the new files over var publishDir = Path.Combine(result.BaseFromArtifactsDirectory(result.Label), "NCover"); Log.Debug(string.Format("Copying {0} files to {1}", newFiles.Length, publishDir)); var index = outputDirectory.FullName.Length + 1; foreach (FileInfo newFile in newFiles) { var fileInfo = new FileInfo(Path.Combine(publishDir, newFile.FullName.Substring(index))); if (!fileInfo.Directory.Exists) fileInfo.Directory.Create(); newFile.CopyTo(fileInfo.FullName, true); } } } return !processResult.Failed; }
/// <summary> /// Execute the actual task functionality. /// </summary> /// <param name="result">The result to use.</param> /// <returns> /// <c>true</c> if the task was successful; <c>false</c> otherwise. /// </returns> protected override bool Execute(IIntegrationResult result) { result.BuildProgressInformation.SignalStartRunTask(!string.IsNullOrEmpty(Description) ? Description : "Updating configuration"); var fileSystem = this.FileSystem ?? new SystemIoFileSystem(); // Check if the config file exists var configFile = this.FindConfigFile(result, fileSystem); if (configFile == null) { return true; } // Check for any differences var currentFile = PathUtils.ConfigFileLocation; var updateFile = this.AlwaysUpdate || HasDifferences(fileSystem, configFile, currentFile); if (!updateFile) { Log.Info("Skipping validation and copy - nothing has changed"); return true; } // Validate the file if (this.ValidateFile) { this.fileToValidate = configFile; this.validationLogFile = Path.GetTempFileName(); Log.Info("Executing CCValidator"); var info = this.CreateProcessInfo(result); var processResult = this.TryToRun(info, result); if (processResult.TimedOut) { Log.Warning("CCValidator timed out"); result.AddTaskResult(MakeTimeoutBuildResult(info)); return false; } // Check the results result.AddTaskResult(new ProcessTaskResult(processResult, false)); result.AddTaskResult(fileSystem.GenerateTaskResultFromFile(this.validationLogFile, true)); if (processResult.Failed) { Log.Warning("CCValidator failed"); return false; } } // Update the file Log.Info("Copying config file to '{0}'", currentFile); fileSystem.Copy(configFile, currentFile); return true; }