/// <summary> /// Sends the request to a remote server. /// </summary> /// <param name="context">The context.</param> private void SendRemoteRequest(TaskExecutionContext context) { // Generate the connection var connection = this.ServerConnectionFactory.GenerateConnection(this.ServerAddress); // Resolve the URN var urn = this.ProjectName; if (!UrnHelpers.IsCCNetUrn(urn)) { urn = this.ServerConnectionFactory.GenerateUrn(this.ServerAddress, urn); } // Send the actual request logger.Debug("Sending force build on '{0}' to '{1}'", urn, this.ServerAddress); try { connection.Invoke(urn, "ForceBuild"); var message = "Force build successfully sent to '" + ProjectName + "' at '" + this.ServerAddress + "'"; logger.Info(message); context.AddEntryToBuildLog(message); } catch (RemoteServerException error) { var message = "Force build failed for '" + ProjectName + "' at '" + this.ServerAddress + "' - result code " + error.ResultCode; logger.Info(message); context.AddEntryToBuildLog(message); context.CurrentStatus = IntegrationStatus.Failure; } }
/// <summary> /// Sends the request to the local server. /// </summary> /// <param name="context">The context.</param> private void SendLocalRequest(TaskExecutionContext context) { // Resolve the URN var urn = this.ProjectName; if (!UrnHelpers.IsCCNetUrn(urn)) { urn = UrnHelpers.GenerateProjectUrn(this.Project.Server, this.ProjectName); } // Send the actual request logger.Debug("Performing local force build on '{0}'", urn); var arguments = new InvokeArguments { Action = "ForceBuild" }; var result = this.Project.Server.ActionInvoker.Invoke(urn, arguments); // Check the result if (result.ResultCode == RemoteResultCode.Success) { var message = "Force build successfully sent to '" + ProjectName + "'"; logger.Info(message); context.AddEntryToBuildLog(message); } else { var message = "Force build failed for '" + ProjectName + "' - result code " + result.ResultCode; logger.Info(message); context.AddEntryToBuildLog(message); context.CurrentStatus = IntegrationStatus.Failure; } }
public void AddEntryToBuildLogAddsElement() { var writerMock = new Mock <XmlWriter>(MockBehavior.Strict); writerMock.Setup(w => w.WriteStartElement(null, "entry", null)).Verifiable(); writerMock.MockWriteAttributeString("time", "2010-01-01T12:01:01"); writerMock.Setup(w => w.WriteString("This is a test")).Verifiable(); writerMock.Setup(w => w.WriteEndElement()).Verifiable(); var clockMock = new Mock <IClock>(MockBehavior.Strict); clockMock.Setup(c => c.Now).Returns(new DateTime(2010, 1, 1, 12, 1, 1)); var context = new TaskExecutionContext( new TaskExecutionParameters { XmlWriter = writerMock.Object, Clock = clockMock.Object }); context.AddEntryToBuildLog("This is a test"); writerMock.Verify(); }
public void AddEntryToBuildLogAddsElement() { var writerMock = new Mock<XmlWriter>(MockBehavior.Strict); writerMock.Setup(w => w.WriteStartElement(null, "entry", null)).Verifiable(); writerMock.MockWriteAttributeString("time", "2010-01-01T12:01:01"); writerMock.Setup(w => w.WriteString("This is a test")).Verifiable(); writerMock.Setup(w => w.WriteEndElement()).Verifiable(); var clockMock = new Mock<IClock>(MockBehavior.Strict); clockMock.Setup(c => c.Now).Returns(new DateTime(2010, 1, 1, 12, 1, 1)); var context = new TaskExecutionContext( new TaskExecutionParameters { XmlWriter = writerMock.Object, Clock = clockMock.Object }); context.AddEntryToBuildLog("This is a test"); writerMock.Verify(); }
/// <summary> /// Executes this task. /// </summary> /// <param name="context">The context.</param> /// <returns> /// The child tasks to execute. /// </returns> protected override IEnumerable<Task> OnRun(TaskExecutionContext context) { logger.Info("Adding comment to the build log"); context.AddEntryToBuildLog(this.Text); return null; }
/// <summary> /// Executes this task. /// </summary> /// <param name="context">The context.</param> /// <returns> /// The child tasks to execute. /// </returns> protected override IEnumerable <Task> OnRun(TaskExecutionContext context) { logger.Info("Adding comment to the build log"); context.AddEntryToBuildLog(this.Text); return(null); }