/// <summary> /// The main execution method for TFS Deployer it is this /// method that does all the work /// </summary> /// <param name="statusChanged"></param> public void ExecuteDeploymentProcess(BuildStatusChangeEvent statusChanged) { try { TraceHelper.TraceInformation(TraceSwitches.TfsDeployer, "Build Status Changed: Team Project {0} Team Build Version: {1} From {2} : {3}", statusChanged.TeamProject, statusChanged.Id, statusChanged.StatusChange.OldValue, statusChanged.StatusChange.NewValue); var info = new BuildInformation(GetBuildDetail(statusChanged)); DeploymentMappings mappings = ConfigurationReader.Read(statusChanged.TeamProject, info.Data); if (mappings != null) { foreach (Mapping mapping in mappings.Mappings) { TraceHelper.TraceInformation(TraceSwitches.TfsDeployer, "Processing Mapping: Computer:{0}, Script:{1}", mapping.Computer, mapping.Script); if (IsInterestedStatusChange(statusChanged, mapping, statusChanged.StatusChange)) { IRunner runner = DetermineRunner(mapping); runner.Execute(ConfigurationReader.WorkingDirectory, mapping, info); ApplyRetainBuild(mapping, runner, info.Detail); Alerter.Alert(mapping, info.Data, runner); } } } } catch (Exception ex) { TraceHelper.TraceError(TraceSwitches.TfsDeployer, ex); } }
public void MappingProcessor_should_record_mapped_event_for_applicable_mappings() { // Arrange const int eventId = 7; var mappingEvaluator = MockRepository.GenerateStub <IMappingEvaluator>(); var deploymentEventRecorder = MockRepository.GenerateStub <IDeploymentEventRecorder>(); var mappingExecutor = MockRepository.GenerateStub <IMappingExecutor>(); Func <IMappingExecutor> executorFactory = () => mappingExecutor; var mappingProcessor = new MappingProcessor(mappingEvaluator, deploymentEventRecorder, executorFactory); var postDeployAction = MockRepository.GenerateStub <IPostDeployAction>(); var buildDetail = new BuildDetail(); var mappings = new[] { new Mapping { Script = "AScript.ps1", Queue = "AQueue" } }; mappingEvaluator.Stub(o => o.DoesMappingApply(null, null, null)) .IgnoreArguments() .Return(true); var statusChanged = new BuildStatusChangeEvent { StatusChange = new Change() }; // Act mappingProcessor.ProcessMappings(mappings, statusChanged, buildDetail, postDeployAction, eventId); // Assert deploymentEventRecorder.AssertWasCalled(o => o.RecordQueued(eventId, mappings[0].Script, mappings[0].Queue)); }
private void ProcessMapping(BuildStatusChangeEvent statusChanged, BuildDetail buildDetail, Mapping mapping, IPostDeployAction postDeployAction) { lock (GetLockObject(mapping)) { var deployAgent = _deployAgentProvider.GetDeployAgent(mapping); // default to "happy; did nothing" if there's no deployment agent. var deployResult = new DeployAgentResult { HasErrors = false, Output = string.Empty }; if (deployAgent != null) { using (var workingDirectory = new WorkingDirectory()) { var deployAgentDataFactory = new DeployAgentDataFactory(); var deployData = deployAgentDataFactory.Create(workingDirectory.DirectoryInfo.FullName, mapping, buildDetail, statusChanged); _deploymentFolderSource.DownloadDeploymentFolder(deployData.TfsBuildDetail, workingDirectory.DirectoryInfo.FullName); deployResult = deployAgent.Deploy(deployData); } } postDeployAction.DeploymentFinished(mapping, deployResult); } }
public void Execute(BuildStatusChangeEvent statusChanged, BuildDetail buildDetail, Mapping mapping, IPostDeployAction postDeployAction, int deploymentId) { lock (_namedLockSet.GetLockObject(mapping.Queue)) { _deploymentEventRecorder.RecordStarted(deploymentId); var deployAgent = _deployAgentProvider.GetDeployAgent(mapping); // default to "happy; did nothing" if there's no deployment agent. var deployResult = new DeployAgentResult { HasErrors = false, Output = string.Empty }; if (deployAgent != null) { using (var workingDirectory = new WorkingDirectory()) { var deployAgentDataFactory = new DeployAgentDataFactory(); var deployData = deployAgentDataFactory.Create(workingDirectory.DirectoryInfo.FullName, mapping, buildDetail, statusChanged); deployData.DeploymentId = deploymentId; _deploymentFolderSource.DownloadDeploymentFolder(deployData.TfsBuildDetail, workingDirectory.DirectoryInfo.FullName); deployResult = deployAgent.Deploy(deployData); } } postDeployAction.DeploymentFinished(mapping, deployResult); _deploymentEventRecorder.RecordFinished(deploymentId, deployResult.HasErrors, deployResult.Output); } }
public void ExecuteDeploymentProcess(BuildStatusChangeEvent statusChanged) { try { TraceHelper.TraceInformation(TraceSwitches.TfsDeployer, "Build Status Changed: Team Project {0} Team Build Version: {1} From {2} : {3}", statusChanged.TeamProject, statusChanged.Id, statusChanged.StatusChange.OldValue, statusChanged.StatusChange.NewValue); var tfsBuildDetail = GetBuildDetail(statusChanged); var buildDetail = Mapper.Map <IBuildDetail, BuildDetail>(tfsBuildDetail); var postDeployAction = new PostDeployAction(buildDetail, tfsBuildDetail, _alerter); var mappings = _configurationReader.ReadMappings(buildDetail); _mappingProcessor.ProcessMappings(mappings, statusChanged, buildDetail, postDeployAction); } catch (Exception ex) { TraceHelper.TraceError(TraceSwitches.TfsDeployer, ex); } }
private IBuildDetail GetBuildDetail(BuildStatusChangeEvent statusChanged) { var buildSpec = _buildServer.CreateBuildDefinitionSpec(statusChanged.TeamProject); var detail = _buildServer.GetBuild(buildSpec, statusChanged.Id, null, QueryOptions.All); return(detail); }
public void MappingExecutor_should_record_started_time() { // Arrange const int eventId = 7; const int deploymentId = 23; var deployAgentProvider = MockRepository.GenerateStub <IDeployAgentProvider>(); var deploymentFolderSource = MockRepository.GenerateStub <IDeploymentFolderSource>(); var mapping = new Mapping(); var deploymentEventRecorder = MockRepository.GenerateStub <IDeploymentEventRecorder>(); deploymentEventRecorder.Stub(o => o.RecordQueued(eventId, mapping.Script, mapping.Queue)) .Return(deploymentId); var namedLockSet = new NamedLockSet(); var postDeployAction = MockRepository.GenerateStub <IPostDeployAction>(); var buildDetail = new BuildDetail(); var statusChanged = new BuildStatusChangeEvent { StatusChange = new Change() }; var mappingExecutor = new MappingExecutor(deploymentEventRecorder, deployAgentProvider, deploymentFolderSource, namedLockSet); // Act mappingExecutor.Execute(statusChanged, buildDetail, mapping, postDeployAction, deploymentId); // Assert deploymentEventRecorder.AssertWasCalled(o => o.RecordStarted(deploymentId)); }
public void MappingProcessor_should_call_post_deploy_action_when_script_not_specified() { // Arrange var deployAgentProvider = new DeployAgentProvider(); var deploymentFolderSource = MockRepository.GenerateStub <IDeploymentFolderSource>(); var mappingEvaluator = MockRepository.GenerateStub <IMappingEvaluator>(); var mappingProcessor = new MappingProcessor(deployAgentProvider, deploymentFolderSource, mappingEvaluator); var postDeployAction = MockRepository.GenerateStub <IPostDeployAction>(); var buildDetail = new BuildDetail(); var mappings = new[] { new Mapping { RetainBuildSpecified = true, RetainBuild = true } }; mappingEvaluator.Stub(o => o.DoesMappingApply(null, null, null)) .IgnoreArguments() .Return(true); var statusChanged = new BuildStatusChangeEvent { StatusChange = new Change() }; // Act mappingProcessor.ProcessMappings(mappings, statusChanged, buildDetail, postDeployAction); // Assert postDeployAction.AssertWasCalled(o => o.DeploymentFinished( Arg <Mapping> .Is.Equal(mappings[0]), Arg <DeployAgentResult> .Matches(result => !result.HasErrors)) ); }
public void LocalPowerShellDeployAgent_should_marshal_build_detail_across_AppDomains() { // Arrange var deploymentEventRecorder = MockRepository.GenerateStub <IDeploymentEventRecorder>(); DeployAgentResult result; using (var scriptFile = new TemporaryFile(".ps1", "$TfsDeployerBuildDetail | Format-List")) { var buildDetail = new BuildDetail(); var mapping = new Mapping { NewQuality = "Released", OriginalQuality = null, ScriptParameters = new ScriptParameter[0], Script = scriptFile.FileInfo.Name }; var buildStatusChangeEvent = new BuildStatusChangeEvent { StatusChange = new Change() }; var testDeployData = (new DeployAgentDataFactory()).Create(scriptFile.FileInfo.DirectoryName, mapping, buildDetail, buildStatusChangeEvent); var agent = new LocalPowerShellDeployAgent(deploymentEventRecorder); // Act result = agent.Deploy(testDeployData); } // Assert Assert.IsFalse(result.HasErrors, "Test script failed."); }
public void Deployer_should_pass_build_status_to_mapping_processor() { // Arrange BuildDetail buildDetail = null; var statusChanged = new BuildStatusChangeEvent { StatusChange = new Change() }; var reader = MockRepository.GenerateStub <IConfigurationReader>(); var tfsBuildDetail = new StubBuildDetail { Status = Microsoft.TeamFoundation.Build.Client.BuildStatus.PartiallySucceeded }; var buildServer = MockRepository.GenerateStub <IBuildServer>(); buildServer.Stub(o => o.GetBuild(null, null, null, QueryOptions.None)) .IgnoreArguments() .Return(tfsBuildDetail); var mappingProcessor = MockRepository.GenerateStub <IMappingProcessor>(); mappingProcessor.Stub(o => o.ProcessMappings(null, null, null, null, 0)) .IgnoreArguments() .WhenCalled(m => buildDetail = (BuildDetail)m.Arguments[2]); Func <BuildDetail, IBuildDetail, IPostDeployAction> postDeployActionFactory = (a, b) => MockRepository.GenerateStub <IPostDeployAction>(); var deployer = new Deployer(reader, buildServer, mappingProcessor, postDeployActionFactory); // Act deployer.ExecuteDeploymentProcess(statusChanged, 0); // Assert Assert.AreEqual(global::TfsDeployer.TeamFoundation.BuildStatus.PartiallySucceeded, buildDetail.Status); }
public void OutOfProcessPowerShellDeployAgent_should_serialize_build_detail_across_processes() { DeployAgentResult result; using (var scriptFile = new TemporaryFile(".ps1", "'Description:' + $TfsDeployerBuildDetail.BuildDefinition.Process.Description")) { var buildDetail = new BuildDetail { BuildDefinition = { Process = { Description = "My Process Template" } } }; var mapping = new Mapping { NewQuality = "Released", OriginalQuality = null, ScriptParameters = new ScriptParameter[0], Script = scriptFile.FileInfo.Name }; var buildStatusChangeEvent = new BuildStatusChangeEvent { StatusChange = new Change() }; var testDeployData = (new DeployAgentDataFactory()).Create(scriptFile.FileInfo.DirectoryName, mapping, buildDetail, buildStatusChangeEvent); var agent = new OutOfProcessPowerShellDeployAgent(null, ClrVersion.Version2); // Act result = agent.Deploy(testDeployData); } // Assert StringAssert.Contains(result.Output, "Description:My Process Template"); }
public virtual void Setup() { _tfsListener = MockRepository.GenerateStub <ITfsListener>(); // configure deployer var deployer = MockRepository.GenerateStub <IDeployer>(); deployer.Stub(o => o.ExecuteDeploymentProcess(null, 0)) .IgnoreArguments() .WhenCalled(mi => _deployerExecuteCount++) .Repeat.Any(); _tfsListener.BuildStatusChangeEventReceived += null; _eventRaiser = _tfsListener.GetEventRaiser(mo => mo.BuildStatusChangeEventReceived += null); // we're using a real DuplicateEventDetector _duplicateEventDetector = new DuplicateEventDetector(); _statusChanged = new BuildStatusChangeEvent { StatusChange = new Change() }; var deploymentEventRecorder = MockRepository.GenerateStub <IDeploymentEventRecorder>(); _deployerExecuteCount = 0; _buildStatusTrigger = new TfsBuildStatusTrigger(_tfsListener, () => deployer, _duplicateEventDetector, deploymentEventRecorder); _buildStatusTrigger.Start(); }
public void ShouldRejectUnchangedQuality() { const string TestWildcard = "*"; var changeEvent = new BuildStatusChangeEvent(); var mapping = new Mapping { Computer = Environment.MachineName, NewQuality = "SomeNewQuality", PermittedUsers = null, OriginalQuality = TestWildcard }; changeEvent.StatusChange = new Change { NewValue = "SomeNewQuality", OldValue = "SomeNewQuality" }; var mappingEvaluator = new MappingEvaluator(); var result = mappingEvaluator.DoesMappingApply(mapping, changeEvent, BuildStatus.Succeeded.ToString()); Assert.IsFalse(result); }
public void ShouldMatchOriginalQualityWhenNullInConfigButEmptyInTfs() { const string TestNewQuality = "Pass"; var changeEvent = new BuildStatusChangeEvent(); var mapping = new Mapping { Computer = Environment.MachineName, NewQuality = TestNewQuality, PermittedUsers = null, OriginalQuality = null }; changeEvent.StatusChange = new Change { NewValue = TestNewQuality, OldValue = string.Empty }; var mappingEvaluator = new MappingEvaluator(); var result = mappingEvaluator.DoesMappingApply(mapping, changeEvent, BuildStatus.Succeeded.ToString()); Assert.IsTrue(result); }
public void DeployAgentDataFactory_should_expose_event_qualities() { const string oldQuality = "QA"; const string newQuality = "Production"; // Arrange var deployScriptRoot = Path.GetTempPath(); var mapping = new Mapping(); var buildDetail = new BuildDetail(); var changeEvent = new BuildStatusChangeEvent { StatusChange = new Change { OldValue = oldQuality, NewValue = newQuality } }; var factory = new DeployAgentDataFactory(); // Act var data = factory.Create(deployScriptRoot, mapping, buildDetail, changeEvent); // Assert Assert.AreEqual(oldQuality, data.OriginalQuality, "OriginalQuality"); Assert.AreEqual(newQuality, data.NewQuality, "NewQuality"); }
public void ShouldMatchOriginalQualityWhenNullInConfigButEmptyInTfs() { const string TestNewQuality = "Pass"; var changeEvent = new BuildStatusChangeEvent(); var mapping = new Mapping() { Computer = Environment.MachineName, NewQuality = TestNewQuality, PermittedUsers = null, OriginalQuality = null }; var statusChange = new Change() { NewValue = TestNewQuality, OldValue = string.Empty }; var deployer = new Deployer(); var result = deployer.IsInterestedStatusChange(changeEvent, mapping, statusChange); Assert.IsTrue(result, "IsInterestedStatusChange()"); }
public void MappingExecutor_should_call_post_deploy_action_when_script_not_specified() { // Arrange var deployAgentProvider = MockRepository.GenerateStub <IDeployAgentProvider>(); var deploymentFolderSource = MockRepository.GenerateStub <IDeploymentFolderSource>(); var deploymentEventRecorder = MockRepository.GenerateStub <IDeploymentEventRecorder>(); var namedLockSet = new NamedLockSet(); var mappingExecutor = new MappingExecutor(deploymentEventRecorder, deployAgentProvider, deploymentFolderSource, namedLockSet); var postDeployAction = MockRepository.GenerateStub <IPostDeployAction>(); var buildDetail = new BuildDetail(); var mapping = new Mapping { RetainBuildSpecified = true, RetainBuild = true }; var statusChanged = new BuildStatusChangeEvent { StatusChange = new Change() }; // Act mappingExecutor.Execute(statusChanged, buildDetail, mapping, postDeployAction, 0); // Assert postDeployAction.AssertWasCalled(o => o.DeploymentFinished( Arg <Mapping> .Is.Equal(mapping), Arg <DeployAgentResult> .Matches(result => !result.HasErrors)) ); }
public void Deployer_should_pass_build_definition_name_to_configuration_reader() { // Arrange BuildDetail buildDetail = null; var statusChanged = new BuildStatusChangeEvent { StatusChange = new Change() }; var mappingProcessor = MockRepository.GenerateStub <IMappingProcessor>(); var tfsBuildDetail = new StubBuildDetail { BuildDefinition = { Name = "foo" } }; var buildServer = MockRepository.GenerateStub <IBuildServer>(); buildServer.Stub(o => o.GetBuild(null, null, null, QueryOptions.None)) .IgnoreArguments() .Return(tfsBuildDetail); var reader = MockRepository.GenerateStub <IConfigurationReader>(); reader.Stub(o => o.ReadMappings(Arg <BuildDetail> .Is.Anything)).WhenCalled(m => buildDetail = (BuildDetail)m.Arguments[0]); Func <BuildDetail, IBuildDetail, IPostDeployAction> postDeployActionFactory = (a, b) => MockRepository.GenerateStub <IPostDeployAction>(); var deployer = new Deployer(reader, buildServer, mappingProcessor, postDeployActionFactory); // Act deployer.ExecuteDeploymentProcess(statusChanged, 0); // Assert Assert.AreEqual("foo", buildDetail.BuildDefinition.Name); }
public void ShouldMatchOriginalQualityOnWildcard() { const string TestWildcard = "*"; var changeEvent = new BuildStatusChangeEvent(); var mapping = new Mapping() { Computer = Environment.MachineName, NewQuality = "SomeNewQuality", PermittedUsers = null, OriginalQuality = TestWildcard }; var statusChange = new Change() { NewValue = "SomeNewQuality", OldValue = "DefinitelyNotTheWildCard" }; var deployer = new Deployer(); var result = deployer.IsInterestedStatusChange(changeEvent, mapping, statusChange); Assert.IsTrue(result, "IsInterestedStatusChange()"); }
public bool IsInterestedStatusChange(BuildStatusChangeEvent changeEvent, Mapping mapping, Change statusChange) { bool isComputerMatch = string.Compare(Environment.MachineName, mapping.Computer, true) == 0; bool isOldValueMatch = string.Compare(mapping.OriginalQuality, statusChange.OldValue, true) == 0; bool isNewValueMatch = string.Compare(mapping.NewQuality, statusChange.NewValue) == 0; bool isUserPermitted = this.IsUserPermitted(changeEvent, mapping); return(isComputerMatch && isOldValueMatch && isNewValueMatch && isUserPermitted); }
public void Setup() { _evaluator = new MappingEvaluator(); _mapping = new MappingBuilder().Mapping; _changeEvent = new BuildStatusChangeEventBuilder { OriginalQuality = "BoringQuality", NewQuality = "BoringQuality", } .BuildStatusChangeEvent; }
public bool IsInterestedStatusChange(BuildStatusChangeEvent changeEvent, Mapping mapping, Change statusChange) { bool isComputerMatch = string.Compare(Environment.MachineName, mapping.Computer, true) == 0; string wildcardQuality = Properties.Settings.Default.BuildQualityWildcard; bool isOldValueMatch = IsQualityMatch(statusChange.OldValue, mapping.OriginalQuality, wildcardQuality); bool isNewValueMatch = IsQualityMatch(statusChange.NewValue, mapping.NewQuality, wildcardQuality); bool isUserPermitted = IsUserPermitted(changeEvent, mapping); return(isComputerMatch && isOldValueMatch && isNewValueMatch && isUserPermitted); }
private DeployAgentData CreateDeployAgentData() { var mapping = CreateMapping(); var buildInfo = CreateBuildDetail(); var buildStatusChangeEvent = new BuildStatusChangeEvent { StatusChange = new Change() }; var factory = new DeployAgentDataFactory(); return(factory.Create(DeployScriptRoot, mapping, buildInfo, buildStatusChangeEvent)); }
private bool AreTooSimilar(BuildStatusChangeEvent a, BuildStatusChangeEvent b) { bool areTooSimilar = (a.ChangedBy == b.ChangedBy && a.Id == b.Id && a.StatusChange.FieldName == b.StatusChange.FieldName && a.StatusChange.OldValue == b.StatusChange.OldValue && a.StatusChange.NewValue == b.StatusChange.NewValue && a.TeamProject == b.TeamProject && a.Title == b.Title); return(areTooSimilar); }
private void OnListenerBuildStatusChangeEventReceived(object sender, BuildStatusChangeEventArgs e) { BuildStatusChangeEvent changeEvent = e.EventRaised; if (_duplicateEventDetector.IsUnique(changeEvent)) { var deployer = _deployerFactory.Create(); ExecuteDeploymentProcessDelegate edpd = deployer.ExecuteDeploymentProcess; edpd.BeginInvoke(changeEvent, null, null); } else { TraceHelper.TraceWarning(TraceSwitches.TfsDeployer, "Received duplicate event '{0}' from TFS.", changeEvent.Title); } }
public void ProcessMappings(IEnumerable <Mapping> mappings, BuildStatusChangeEvent statusChanged, BuildDetail buildDetail, IPostDeployAction postDeployAction) { var applicableMappings = from mapping in mappings where _mappingEvaluator.DoesMappingApply(mapping, statusChanged, buildDetail.Status.ToString()) select mapping; foreach (var mapping in applicableMappings) { TraceHelper.TraceInformation(TraceSwitches.TfsDeployer, "Matching mapping found, executing, Computer:{0}, Script:{1}", mapping.Computer, mapping.Script); ((ProcessMappingDelegate)ProcessMapping).BeginInvoke(statusChanged, buildDetail, mapping, postDeployAction, null, null); } }
private bool IsUserPermitted(BuildStatusChangeEvent changeEvent, Mapping mapping) { if (mapping.PermittedUsers == null) { return(true); } bool isUserPermitted; string[] permittedUsers = mapping.PermittedUsers.Split(';'); List <string> permittedUsersList = new List <string>(permittedUsers); isUserPermitted = permittedUsersList.Exists( delegate(string value) { return(string.Compare(changeEvent.ChangedBy, value, true) == 0); } ); return(isUserPermitted); }
public BuildStatusChangeEventBuilder() { _event = new BuildStatusChangeEvent { TeamFoundationServerUrl = "https://tfs.example.com/tfs", TeamProject = "Test Project", Title = "Test Project Build Test_Project_20101024.2 Quality Changed To NewStatus", Id = "Test_Project_20101024.2", Url = "http://tfs.example.com/Build/Build.aspx", TimeZoneOffset = "+10:00:00", ChangedTime = DateTime.Now.ToString(), ChangedBy = "EXAMPLE\\CaramelloKoala", StatusChange = new Change { OldValue = "OriginalQuality", NewValue = "NewQuality" }, }; }
public void MappingExecutor_should_pass_deployment_id_to_deploy_agent_via_deploy_agent_data() { // Arrange const int deploymentId = 23; DeployAgentData deployData = null; var deployAgent = MockRepository.GenerateStub <IDeployAgent>(); deployAgent.Stub(o => o.Deploy(null)) .IgnoreArguments() .Return(new DeployAgentResult()) .WhenCalled(o => deployData = (DeployAgentData)o.Arguments[0]); var deployAgentProvider = MockRepository.GenerateStub <IDeployAgentProvider>(); deployAgentProvider.Stub(o => o.GetDeployAgent(null)) .IgnoreArguments() .Return(deployAgent); var deploymentFolderSource = MockRepository.GenerateStub <IDeploymentFolderSource>(); var mapping = new Mapping(); var deploymentEventRecorder = MockRepository.GenerateStub <IDeploymentEventRecorder>(); deploymentEventRecorder.Stub(o => o.RecordQueued(0, null, null)) .IgnoreArguments() .Return(deploymentId); var namedLockSet = new NamedLockSet(); var mappingExecutor = new MappingExecutor(deploymentEventRecorder, deployAgentProvider, deploymentFolderSource, namedLockSet); var postDeployAction = MockRepository.GenerateStub <IPostDeployAction>(); var buildDetail = new BuildDetail(); var statusChanged = new BuildStatusChangeEvent { StatusChange = new Change() }; // Act mappingExecutor.Execute(statusChanged, buildDetail, mapping, postDeployAction, deploymentId); // Assert Assert.AreEqual(deploymentId, deployData.DeploymentId); }
public void ExecuteDeploymentProcess(BuildStatusChangeEvent statusChanged) { try { TraceHelper.TraceInformation(TraceSwitches.TfsDeployer, "Build Status Changed: Team Project {0} Team Build Version: {1} From {2} : {3}", statusChanged.TeamProject, statusChanged.Id, statusChanged.StatusChange.OldValue, statusChanged.StatusChange.NewValue); var info = new BuildInformation(GetBuildDetail(statusChanged)); using (var workingDirectory = new WorkingDirectory()) { var mappings = _configurationReader.ReadMappings(statusChanged.TeamProject, info.Data, workingDirectory); foreach (var mapping in mappings) { TraceHelper.TraceInformation(TraceSwitches.TfsDeployer, "Processing Mapping: Computer:{0}, Script:{1}", mapping.Computer, mapping.Script); if (_mappingEvaluator.DoesMappingApply(mapping, statusChanged, info.Detail.Status.ToString())) { TraceHelper.TraceInformation(TraceSwitches.TfsDeployer, "Matching mapping found, running script {0}", mapping.Script); var deployAgent = _deployAgentProvider.GetDeployAgent(mapping); var deployData = CreateDeployAgentData(workingDirectory.DirectoryInfo.FullName, mapping, info); var deployResult = deployAgent.Deploy(deployData); ApplyRetainBuild(mapping, deployResult, info.Detail); _alerter.Alert(mapping, info.Data, deployResult); } } } } catch (Exception ex) { TraceHelper.TraceError(TraceSwitches.TfsDeployer, ex); } }