/// <summary> /// Integrates the specified request. /// </summary> /// <param name="request">The request.</param> /// <returns></returns> /// <remarks></remarks> public IIntegrationResult Integrate(IntegrationRequest request) { Log.Trace(); this.target.InitialiseForBuild(request); var result = this.StartNewIntegration(request); IIntegrationResult lastResult = resultManager.LastIntegrationResult; CreateDirectoryIfItDoesntExist(result.WorkingDirectory); CreateDirectoryIfItDoesntExist(result.ArtifactDirectory); Log.Trace("Getting Modifications for project {0}", result.ProjectName); try { result.Modifications = GetModifications(lastResult, result); } catch (Exception error) { result.SourceControlError = error; result.LastBuildStatus = lastResult.HasSourceControlError ? lastResult.LastBuildStatus : lastResult.Status; Log.Warning(string.Format(System.Globalization.CultureInfo.CurrentCulture, "Source control failure (GetModifications): {0}", error.Message)); if (request.PublishOnSourceControlException) { result.ExceptionResult = error; CompleteIntegration(result); } } var runBuild = false; try { // Check whether a build should be performed runBuild = (result.SourceControlError == null) && result.ShouldRunBuild(); if (runBuild) { Log.Info("Building: " + request); target.ClearNotNeededMessages(); // hack : otherwise all labellers(CCnet and custom) should be altered, better do this in 1 place // labelers only increase version if PREVIOUS result was ok // they should also increase version if previous was exception, and the new // build got past the getmodifications Log.Trace("Creating Label for project {0}", result.ProjectName); if (result.LastIntegrationStatus == IntegrationStatus.Exception) { IntegrationSummary isExceptionFix = new IntegrationSummary(IntegrationStatus.Success, result.LastIntegration.Label, result.LastIntegration.LastSuccessfulIntegrationLabel, result.LastIntegration.StartTime); IIntegrationResult irExceptionFix = new IntegrationResult(result.ProjectName, result.WorkingDirectory, result.ArtifactDirectory, result.IntegrationRequest, isExceptionFix); irExceptionFix.Modifications = result.Modifications; target.CreateLabel(irExceptionFix); result.Label = irExceptionFix.Label; } else { target.CreateLabel(result); } Log.Trace("Running tasks of project {0}", result.ProjectName); this.GenerateSystemParameterValues(result); Build(result); } else if (lastResult.HasSourceControlError) { // Reset to the last valid status result.Status = lastResult.LastBuildStatus; resultManager.FinishIntegration(); } } catch (Exception ex) { Log.Debug("Exception caught: " + ex.Message); result.ExceptionResult = ex; } finally { if (runBuild) { CompleteIntegration(result); } } this.target.Activity = ProjectActivity.Sleeping; return(result); }