示例#1
0
 /// <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);
     }
 }
示例#2
0
        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);
            }
        }
示例#3
0
        private static DeployAgentData CreateDeployAgentData(string directory, Mapping mapping, BuildInformation buildInfo)
        {
            var data = new DeployAgentData
            {
                NewQuality             = mapping.NewQuality,
                OriginalQuality        = mapping.OriginalQuality,
                DeployServer           = mapping.Computer,
                DeployScriptFile       = mapping.Script,
                DeployScriptRoot       = directory,
                DeployScriptParameters = CreateParameters(mapping.ScriptParameters),
                Tfs2005BuildData       = buildInfo.Data,
                Tfs2008BuildDetail     = buildInfo.Detail
            };

            return(data);
        }