Exemplo n.º 1
0
        public void Can_read_the_changed_fields_from_alert_xml_block()
        {
            // Arrange
            var alertMessage = TestData.DummyBuildStatusChangedAlertXmlWithQualityChange();

            // act
            var actual = EventXmlHelper.GetBuildStatusChangedAlertFields(alertMessage);

            // assert
            Assert.AreEqual("vstfs:///Build/Build/49", actual.BuildUri.ToString());
            Assert.AreEqual("Helpdesk Build CallTracker Dev_20100317.2 Quality Changed To Initial Test Passed", actual.Summary);
            Assert.AreEqual("Initial Test Passed", actual.NewQuality);
        }
Exemplo n.º 2
0
        public void Notify(string eventXml, string tfsIdentityXml)
        {
            try
            {
                if (ConfigHelper.ParseOrDefault(System.Configuration.ConfigurationManager.AppSettings["LogEventsToFile"]) == true)
                {
                    var logPath = ConfigHelper.GetLoggingPath();
                    logger.Info(string.Format("TFSEventsProcessor: DslScriptService Event being logged to [{0}]", logPath));
                    LoggingHelper.DumpEventToDisk(eventXml, logPath);
                }

                // Create a new Tfs helper
                this.iTfsProvider.UnpackIdentity(tfsIdentityXml);

                // work out the event type
                string[] argItems = null;
                try
                {
                    var buildDetails = EventXmlHelper.GetBuildStatusChangedAlertFields(eventXml);
                    argItems = new[] { EventTypes.BuildEvent.ToString(), buildDetails.BuildUri.ToString() };
                    logger.Info(string.Format(
                                    "TFSEventsProcessor: DslScriptService Event being processed for Build:{0}",
                                    buildDetails.BuildUri));
                }
                catch (NullReferenceException)
                {
                    // if it not build must be work item
                    // Extract the required information out of the eventXml
                    var workItemId = EventXmlHelper.GetWorkItemValue <int>(
                        eventXml,
                        EventXmlHelper.FieldSection.CoreFields,
                        EventXmlHelper.FieldType.IntegerField,
                        EventXmlHelper.ValueType.NewValue,
                        "System.Id");
                    if (workItemId > 0)
                    {
                        argItems = new[] { EventTypes.WorkItemEvent.ToString(), workItemId.ToString() };
                        logger.Info(
                            string.Format("TFSEventsProcessor: DslScriptService Event being processed for WI:{0}", workItemId));
                    }
                    else
                    {
                        try
                        {
                            var checkInDetails = EventXmlHelper.GetCheckInDetails(eventXml);
                            argItems = new[] { EventTypes.CheckInEvent.ToString(), checkInDetails.Changeset.ToString() };
                            logger.Info(
                                string.Format(
                                    "TFSEventsProcessor: DslScriptService Event being processed for Checkin:{0}",
                                    checkInDetails.Changeset));
                        }
                        catch (NullReferenceException)
                        {
                            // other event type
                        }
                    }
                }
                var args = new Dictionary <string, object>
                {
                    { "Arguments", argItems },
                };

                var engine = new TFSEventsProcessor.Dsl.DslProcessor();
                engine.RunScript(
                    this.dslFolder,
                    this.scriptFolder,
                    GetScriptName(argItems[0], this.scriptFile),
                    args,
                    this.iTfsProvider,
                    this.iEmailProvider,
                    eventXml);
            }
            catch (Exception ex)
            {
                // using a global exception catch to make sure we don't block any threads
                this.DumpException(ex);
            }
        }