public void GenerateFullManifest()
 {
     ManifestGenerator generator = new ManifestGenerator();
     IntegrationRequest request = new IntegrationRequest(BuildCondition.ForceBuild, "Somewhere", null);
     IntegrationSummary summary = new IntegrationSummary(IntegrationStatus.Success, "A Label", "Another Label", new DateTime(2009, 1, 1));
     IntegrationResult result = new IntegrationResult("Test project", "Working directory", "Artifact directory", request, summary);
     Modification modification1 = GenerateModification("first file", "Add");
     Modification modification2 = GenerateModification("second file", "Modify");
     result.Modifications = new Modification[] { modification1, modification2 };
     List<string> files = new List<string>();
     files.Add("first file");
     XmlDocument manifest = generator.Generate(result, files.ToArray());
     Assert.IsNotNull(manifest);
     string actualManifest = manifest.OuterXml;
     string expectedManifest = "<manifest>"  +
             "<header project=\"Test project\" label=\"A Label\" build=\"ForceBuild\" status=\"Unknown\">" +
                 "<modification user=\"johnDoe\" changeNumber=\"1\" time=\"2009-01-01T00:00:00\">" +
                     "<comment>A comment</comment>" +
                     "<file name=\"first file\" type=\"Add\" />" +
                     "<file name=\"second file\" type=\"Modify\" />" +
                 "</modification>" +
             "</header>" +
             "<file name=\"first file\" />" +
         "</manifest>";
     Assert.AreEqual(expectedManifest, actualManifest);
 }
		public void SetUp()
		{
			integrationQueues = new IntegrationQueueSet();
            integrationQueues.Add(TestQueueName, new DefaultQueueConfiguration(TestQueueName));
            integrationQueues.Add(TestQueueName2, new DefaultQueueConfiguration(TestQueueName2));
			integrationQueue1 = integrationQueues[TestQueueName];
			integrationQueue2 = integrationQueues[TestQueueName2];

            integrationRequest = new IntegrationRequest(BuildCondition.ForceBuild, "Test", null);

			project1Mock = new LatchMock(typeof (IProject));
			project1Mock.Strict = true;
			project1Mock.SetupResult("Name", "ProjectOne");
			project1Mock.SetupResult("QueueName", TestQueueName);
			project1Mock.SetupResult("QueuePriority", 0);

			project2Mock = new LatchMock(typeof (IProject));
			project2Mock.Strict = true;
			project2Mock.SetupResult("Name", "ProjectTwo");
			project2Mock.SetupResult("QueueName", TestQueueName2);
			project2Mock.SetupResult("QueuePriority", 0);

			queueNotifier1Mock = new LatchMock(typeof (IIntegrationQueueNotifier));
			queueNotifier1Mock.Strict = true;

			queueNotifier2Mock = new LatchMock(typeof (IIntegrationQueueNotifier));
			queueNotifier2Mock.Strict = true;

			integrationQueueItem1 = new IntegrationQueueItem((IProject) project1Mock.MockInstance,
			                                                 integrationRequest, (IIntegrationQueueNotifier) queueNotifier1Mock.MockInstance);

			integrationQueueItem2 = new IntegrationQueueItem((IProject) project2Mock.MockInstance,
			                                                 integrationRequest, (IIntegrationQueueNotifier) queueNotifier2Mock.MockInstance);
		}
        public void Setup()
        {
            this.mocks = new MockRepository();

            mockery = new Mockery();
            targetMock = mockery.NewDynamicMock(typeof(IIntegrationRunnerTarget));
            resultManagerMock = mockery.NewDynamicMock(typeof(IIntegrationResultManager));
            quietPeriodMock = mockery.NewDynamicMock(typeof(IQuietPeriod));

            runner = new IntegrationRunner((IIntegrationResultManager)resultManagerMock.MockInstance,
                                           (IIntegrationRunnerTarget)targetMock.MockInstance,
                                           (IQuietPeriod)quietPeriodMock.MockInstance);


            request = ModificationExistRequest();
            endTime = new DateTime(2005, 2, 1);
            modifications = new Modification[] { new Modification() };

            resultMock = mockery.NewDynamicMock(typeof(IIntegrationResult));
            resultMock.SetupResult("WorkingDirectory", TempFileUtil.GetTempPath("workingDir"));
            resultMock.SetupResult("ArtifactDirectory", TempFileUtil.GetTempPath("artifactDir"));
            resultMock.SetupResult("BuildProgressInformation", new ThoughtWorks.CruiseControl.Core.Util.BuildProgressInformation("",string.Empty));
            resultMock.SetupResult("IntegrationProperties", new Dictionary<string, string>());
            result = (IIntegrationResult)resultMock.MockInstance;

            lastResultMock = mockery.NewDynamicMock(typeof(IIntegrationResult));
            lastResult = (IIntegrationResult)lastResultMock.MockInstance;
        }
        public IntegrationRequest Fire()
        {
            IntegrationRequest request = null;
            if (this.lastChanged.HasValue)
            {
                if (this.InnerTrigger.Fire() != null)
                {
                    var changeTime = File.GetLastWriteTime(this.MonitorFile);
                    if (changeTime > this.lastChanged.Value)
                    {
                        request = new IntegrationRequest(
                            this.BuildCondition,
                            this.GetType().Name,
                            null);
                        this.lastChanged = changeTime;
                    }
                }
            }
            else
            {
                this.lastChanged = File.GetLastWriteTime(this.MonitorFile);
            }

            return request;
        }
 public void GetHashCodeReturnsAValidHasCode()
 {
     IntegrationRequest request = new IntegrationRequest(BuildCondition.ForceBuild, 
         "Me",
         null);
     int expected = request.ToString().GetHashCode();
     int actual = request.GetHashCode();
     Assert.AreEqual(expected, actual);
 }
		public void HasAttributesAssignedCorrectly()
		{
			IProject project = new Project();
			IntegrationRequest integrationRequest = new IntegrationRequest(BuildCondition.NoBuild, "Test", null);
			IIntegrationQueueNotifier integrationQueueNotifier = new TestIntegrationQueueCallback();

			IIntegrationQueueItem integrationQueueItem = new IntegrationQueueItem(project, integrationRequest, integrationQueueNotifier);

			Assert.AreEqual(project, integrationQueueItem.Project);
			Assert.AreEqual(integrationRequest, integrationQueueItem.IntegrationRequest);
			Assert.AreEqual(integrationQueueNotifier, integrationQueueItem.IntegrationQueueNotifier);
		}
        public void VerifyNewGetSourceProcessInfoWithAttributes()
        {
            IntegrationRequest request = new IntegrationRequest(BuildCondition.ForceBuild, "source", null);
            IntegrationSummary lastSummary = new IntegrationSummary(IntegrationStatus.Success, "label", "lastlabel", DateTime.Now);
            IntegrationResult result = new IntegrationResult("test", @"c:\workspace", @"c:\artifacts", request, lastSummary);

            PlasticSCM plasticscm = new PlasticSCM();
            NetReflector.Read(PLASTICSCM_XML, plasticscm);
            string expected = @"c:\plastic\client\cm.exe stb br:/main -repository=mainrep";
            ProcessInfo info = plasticscm.GoToBranchProcessInfo(result);
            Assert.AreEqual(expected, info.FileName + " " + info.Arguments);

        }
		public void VerifyNewGetSourceProcessInfoBasic()
		{
            IntegrationRequest request = new IntegrationRequest(BuildCondition.ForceBuild, "source", null);
		    IntegrationSummary lastSummary =
		        new IntegrationSummary(IntegrationStatus.Success, "label", "lastlabel", DateTime.Now);
		    IntegrationResult result = new IntegrationResult("test", @"c:\workspace", @"c:\artifacts", request, lastSummary);

		    PlasticSCM plasticscm = new PlasticSCM();
		    NetReflector.Read(PLASTICSCM_BASIC_XML, plasticscm);
		    string expected = @"cm update c:\workspace";
		    ProcessInfo info = plasticscm.NewGetSourceProcessInfo(result);
		    Assert.AreEqual(expected, info.FileName + " " + info.Arguments);
		}
        public void VerifyCreateLabelProcessInfoWithAttributes()
        {
            IntegrationRequest request = new IntegrationRequest(BuildCondition.ForceBuild, "source", null);
            IntegrationSummary lastSummary = new IntegrationSummary(IntegrationStatus.Success, "label", "lastlabel", DateTime.Now);
            IntegrationResult result = new IntegrationResult("test", @"c:\workspace", @"c:\artifacts", request, lastSummary);
            result.Label = "1";

            //check with attributes
            PlasticSCM plasticscm = new PlasticSCM();
            NetReflector.Read(PLASTICSCM_XML, plasticscm);
            string expected = @"c:\plastic\client\cm.exe mklb BL1";
            ProcessInfo info = plasticscm.CreateLabelProcessInfo(result);
            Assert.AreEqual (expected, info.FileName + " " + info.Arguments);
        }
        /// <summary>
        /// Starts a new integration result.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <returns>
        /// The new <see cref="IIntegrationResult"/>.
        /// </returns>
        public IIntegrationResult StartNewIntegration(IntegrationRequest request)
        {
            var result = resultManager.StartNewIntegration(request);

            // Copy any parameters to the result
            if ((request.BuildValues != null) && (request.BuildValues.Count > 0))
            {
                result.Parameters.AddRange(
                    NameValuePair.FromDictionary(request.BuildValues));
            }

            result.MarkStartTime();
            this.GenerateSystemParameterValues(result);
            return result;
        }
        /// <summary>
        /// Sends a build request to the server.
        /// </summary>
        /// <param name="projectName">The name of the project to use.</param>
        /// <param name="integrationRequest"></param>
        public override void Request(string projectName, IntegrationRequest integrationRequest)
        {
            if (string.IsNullOrEmpty(projectName))
            {
                throw new ArgumentNullException("projectName");
            }

            BuildIntegrationRequest request = new BuildIntegrationRequest(SessionToken, projectName);

            request.BuildCondition = integrationRequest.BuildCondition;
            request.ServerName     = TargetServer;
            var resp = this.connection.SendMessage("ForceBuild", request);

            ValidateResponse(resp);
        }
        public IntegrationResult(string projectName, string workingDirectory, string artifactDirectory, IntegrationRequest request, IntegrationSummary lastIntegration)
        {
            ProjectName = projectName;
            WorkingDirectory = workingDirectory;
            ArtifactDirectory = artifactDirectory;
            this.request = (lastIntegration.IsInitial()) ? new IntegrationRequest(BuildCondition.ForceBuild, request.Source, request.UserName) : request;
            this.lastIntegration = lastIntegration;
            if ((lastIntegration.Status == IntegrationStatus.Exception)
                || (lastIntegration.Status == IntegrationStatus.Failure))
                failureUsers = lastIntegration.FailureUsers;       // Inherit the previous build's failureUser list if it failed.

            buildProgressInformation = new BuildProgressInformation(artifactDirectory, projectName);

            this.label = this.LastIntegration.Label;
        }
 public void FireFiresAfterTimePeriodHasExpired()
 {
     var innerTrigger = this.mocks.StrictMock<ITrigger>();
     Expect.Call(() => { innerTrigger.IntegrationCompleted(); });
     var expected = new IntegrationRequest(BuildCondition.IfModificationExists, "Test", null);
     Expect.Call(innerTrigger.Fire()).Return(expected);
     var clock = new TestClock { Now = DateTime.Now };
     var trigger = new RollUpTrigger(clock);
     trigger.MinimumTime = new Timeout(10, TimeUnits.MINUTES);
     trigger.InnerTrigger = innerTrigger;
     mocks.ReplayAll();
     trigger.IntegrationCompleted();
     clock.TimePasses(new TimeSpan(0, 11, 0));
     var actual = trigger.Fire();
     Assert.AreSame(expected, actual);
     mocks.VerifyAll();
 }
        public void CancellingAPendingRequestWhileBuildingIgnoresState()
        {
            IProject project = (IProject) projectMock.MockInstance;

            IntegrationRequest request1 = new IntegrationRequest(BuildCondition.IfModificationExists, "intervalTrigger", null);
            projectMock.Expect("NotifyPendingState");

            IntegrationRequest request2 = new IntegrationRequest(BuildCondition.IfModificationExists, "intervalTrigger", null);
            // As pending build is cancelled we should not alter state
            projectMock.ExpectNoCall("NotifyPendingState");
            projectMock.ExpectNoCall("NotifySleepingState");
            integrationTriggerMock.Expect("IntegrationCompleted");

            integrationQueue.Enqueue(new IntegrationQueueItem(project, request1, integrator));
            integrationQueue.Enqueue(new IntegrationQueueItem(project, request2, integrator));
            // Cancel second build project on queue
            integrator.CancelPendingRequest();

            VerifyAll();
        }
        public void ImportAbsoluteBasedManifest()
        {
            string sourceFile = Path.Combine(Path.GetTempPath(), "ImportManifest.xml");
            string expectedManifest = "<manifest>" +
                    "From a file" +
                "</manifest>";
            if (File.Exists(sourceFile)) File.Delete(sourceFile);
            File.WriteAllText(sourceFile, expectedManifest);

            ManifestImporter generator = new ManifestImporter();
            generator.FileName = sourceFile;
            IntegrationRequest request = new IntegrationRequest(BuildCondition.ForceBuild, "Somewhere", null);
            IntegrationSummary summary = new IntegrationSummary(IntegrationStatus.Success, "A Label", "Another Label", new DateTime(2009, 1, 1));
            IntegrationResult result = new IntegrationResult("Test project", "Working directory", "Artifact directory", request, summary);
            List<string> files = new List<string>();
            XmlDocument manifest = generator.Generate(result, files.ToArray());

            Assert.IsNotNull(manifest);
            string actualManifest = manifest.OuterXml;
            Assert.AreEqual(expectedManifest, actualManifest);
        }
        public void FirePassesOnParameters()
        {
            var parameters = new[] 
                {
                    new NameValuePair("test", "testValue")
                };
            var request = new IntegrationRequest(BuildCondition.IfModificationExists, "test", null);
            var innerTriggerMock = this.mocks.StrictMock<ITrigger>();
            Expect.Call(innerTriggerMock.Fire()).Return(request);
            var trigger = new ParameterTrigger
                {
                    InnerTrigger = innerTriggerMock,
                    Parameters = parameters
                };
            mocks.ReplayAll();
            var actual = trigger.Fire();

            mocks.VerifyAll();
            Assert.AreSame(request, actual);
            Assert.AreEqual(1, request.BuildValues.Count);
            Assert.AreEqual(parameters[0].Value,
                request.BuildValues[parameters[0].Name]);
        }
        private void WriteRequest(IntegrationRequest request)
        {
            if (request == null) return;
            writer.WriteStartElement(Elements.Request);
            writer.WriteAttributeString("source", request.Source);
            writer.WriteAttributeString("buildCondition", request.BuildCondition.ToString());
            writer.WriteString(request.ToString());
            writer.WriteEndElement();

            // Output the parameters
            if ((request.BuildValues != null) && (request.BuildValues.Count > 0))
            {
                writer.WriteStartElement(Elements.Parameters);
                foreach (string key in request.BuildValues.Keys)
                {
                    writer.WriteStartElement(Elements.Parameter);
                    writer.WriteAttributeString("name", key);
                    writer.WriteAttributeString("value", request.BuildValues[key]);
                    writer.WriteEndElement();
                }
                writer.WriteEndElement();
            }
        }
        /// <summary>
        /// Sends a build request to the server.
        /// </summary>
        /// <param name="projectName">The name of the project to use.</param>
        /// <param name="integrationRequest"></param>
        public override void Request(string projectName, IntegrationRequest integrationRequest)
        {
            if (string.IsNullOrEmpty(projectName)) throw new ArgumentNullException("projectName");

            BuildIntegrationRequest request = new BuildIntegrationRequest(SessionToken, projectName);
            request.BuildCondition = integrationRequest.BuildCondition;
            request.ServerName = TargetServer;
            Response resp = connection.SendMessage("ForceBuild", request);
            ValidateResponse(resp);
        }
Example #19
0
 /// <summary>
 /// Sends a build request to the server.
 /// </summary>
 /// <param name="projectName">The name of the project to use.</param>
 /// <param name="integrationRequest"></param>
 public override void Request(string projectName, IntegrationRequest integrationRequest)
 {
     ForceBuild(projectName);
 }
        /// <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;
        }
 /// <summary>
 /// Fires the IntegrationStarted event.
 /// </summary>
 /// <param name="request">The integration request.</param>
 protected virtual IntegrationStartedEventArgs.EventResult FireIntegrationStarted(IntegrationRequest request)
 {
     IntegrationStartedEventArgs.EventResult result = IntegrationStartedEventArgs.EventResult.Continue;
     if (IntegrationStarted != null)
     {
         IntegrationStartedEventArgs args = new IntegrationStartedEventArgs(request,
             project.Name);
         IntegrationStarted(this, args);
         result = args.Result;
     }
     return result;
 }
 private void AddToQueue(IntegrationRequest request)
 {
     integrationQueue.Enqueue(new IntegrationQueueItem(project, request, this));
 }
		public void SetUp()
		{
			integrationQueues = new IntegrationQueueSet();
            integrationQueues.Add(TestQueueName, new DefaultQueueConfiguration(TestQueueName));
			integrationQueueUseFirst = integrationQueues[TestQueueName];

            // Generate a queue to test re-adding
            string secondQueueName = "Test Queue #2";
            IQueueConfiguration readConfig = new DefaultQueueConfiguration(secondQueueName);
            readConfig.HandlingMode = QueueDuplicateHandlingMode.ApplyForceBuildsReAdd;
            integrationQueues.Add(secondQueueName, readConfig);
            integrationQueueReAdd = integrationQueues[secondQueueName];

            // Generate a queue to test re-adding to top
            var fourthQueueName = "Test Queue #4";
            var raddTopConfig = new DefaultQueueConfiguration(fourthQueueName);
            raddTopConfig.HandlingMode = QueueDuplicateHandlingMode.ApplyForceBuildsReAddTop;
            integrationQueues.Add(fourthQueueName, raddTopConfig);
            integrationQueueReAddTop = integrationQueues[fourthQueueName];

            // Generate a queue to test replacing
            string thirdQueueName = "Test Queue #3";
            IQueueConfiguration replaceConfig = new DefaultQueueConfiguration(thirdQueueName);
            replaceConfig.HandlingMode = QueueDuplicateHandlingMode.ApplyForceBuildsReplace;
            integrationQueues.Add(thirdQueueName, replaceConfig);
            integrationQueueReplace = integrationQueues[thirdQueueName];

            integrationRequestForceBuild = new IntegrationRequest(BuildCondition.ForceBuild, "Test", null);
            integrationRequestIfModificationExists = new IntegrationRequest(BuildCondition.IfModificationExists, "Test", null);
			
			project1Mock = new LatchMock(typeof (IProject));
			project1Mock.Strict = true;
			project1Mock.SetupResult("Name", "ProjectOne");
			project1Mock.SetupResult("QueueName", TestQueueName);
			project1Mock.SetupResult("QueuePriority", 0);
			
			project2Mock = new LatchMock(typeof (IProject));
			project2Mock.Strict = true;
			project2Mock.SetupResult("Name", "ProjectTwo");
			project2Mock.SetupResult("QueueName", TestQueueName);
			project2Mock.SetupResult("QueuePriority", 0);
			
			project3Mock = new LatchMock(typeof (IProject));
			project3Mock.Strict = true;
			project3Mock.SetupResult("Name", "ProjectThree");
			project3Mock.SetupResult("QueueName", TestQueueName);
			project3Mock.SetupResult("QueuePriority", 1);

			queueNotifier1Mock = new LatchMock(typeof(IIntegrationQueueNotifier));
			queueNotifier1Mock.Strict = true;

			queueNotifier2Mock = new LatchMock(typeof(IIntegrationQueueNotifier));
			queueNotifier2Mock.Strict = true;

            queueNotifier3Mock = new LatchMock(typeof(IIntegrationQueueNotifier));
            queueNotifier3Mock.Strict = true;

            integrationQueueItem1 = new IntegrationQueueItem((IProject)project1Mock.MockInstance, 
				integrationRequestForceBuild, (IIntegrationQueueNotifier)queueNotifier1Mock.MockInstance);

			integrationQueueItem2 = new IntegrationQueueItem((IProject)project2Mock.MockInstance, 
				integrationRequestForceBuild, (IIntegrationQueueNotifier)queueNotifier2Mock.MockInstance);

			integrationQueueItem3 = new IntegrationQueueItem((IProject)project3Mock.MockInstance, 
				integrationRequestForceBuild, (IIntegrationQueueNotifier)queueNotifier3Mock.MockInstance);

            integrationQueueItem4 = new IntegrationQueueItem((IProject)project2Mock.MockInstance,
                integrationRequestIfModificationExists, (IIntegrationQueueNotifier)queueNotifier2Mock.MockInstance);
        }
 /// <summary>
 /// Fires the IntegrationCompleted event.
 /// </summary>
 /// <param name="request">The integration request.</param>
 /// <param name="status">The outcome of the integration.</param>
 protected virtual void FireIntegrationCompleted(IntegrationRequest request, IntegrationStatus status)
 {
     if (IntegrationCompleted != null)
     {
         IntegrationCompletedEventArgs args = new IntegrationCompletedEventArgs(request,
             project.Name,
             status);
         IntegrationCompleted(this, args);
     }
 }
 private IntegrationResult GenerateResult(int numberOfModifications)
 {
     IntegrationRequest request = new IntegrationRequest(BuildCondition.ForceBuild, "Somewhere", null);
     IntegrationSummary summary = new IntegrationSummary(IntegrationStatus.Success, "A Label", "Another Label", new DateTime(2009, 1, 1));
     IntegrationResult result = new IntegrationResult("Test project", "Working directory", "Artifact directory", request, summary);
     List<Modification> modifications = new List<Modification>();
     for (int loop = 0; loop < numberOfModifications; loop++)
     {
         modifications.Add(GenerateModification(string.Format(System.Globalization.CultureInfo.CurrentCulture,"modification #{0}", loop + 1), "Add"));
     }
     result.Modifications = modifications.ToArray();
     result.ArtifactDirectory = Path.GetTempPath();
     return result;
 }
        public void ForceBuild(string enforcerName, Dictionary<string, string> buildValues)
        {
            Log.Info(string.Format("{0} forced Build for project: {1}", enforcerName, project.Name));
            IntegrationRequest request = new IntegrationRequest(BuildCondition.ForceBuild, enforcerName, enforcerName);
            request.BuildValues = buildValues;
            AddToQueue(request);

            Start();
        }
Example #27
0
        /// <summary>
        /// Forces a build for the named project.
        /// </summary>
        /// <param name="request">A <see cref="ProjectRequest"/> containing the request details.</param>
        /// <returns>A <see cref="Response"/> containing the results of the request.</returns>
        public virtual Response ForceBuild(ProjectRequest request)
        {
            Response response = RunProjectRequest(request,
                SecurityPermission.ForceAbortBuild,
                SecurityEvent.ForceBuild,
                delegate(ProjectRequest arg, Response resp)
                {
                    // Perform the actual force build
                    string userName = securityManager.GetDisplayName(arg.SessionToken, request.DisplayName);
                    if (!FireForceBuildReceived(arg.ProjectName, userName))
                    {
                        // Build the integration request
                        IntegrationRequest integrationRequest;
                        if (request is BuildIntegrationRequest)
                        {
                            BuildIntegrationRequest actualRequest = arg as BuildIntegrationRequest;
                            integrationRequest = new IntegrationRequest(actualRequest.BuildCondition, request.SourceName, userName);
                            integrationRequest.BuildValues = NameValuePair.ToDictionary(actualRequest.BuildValues);
                        }
                        else
                        {
                            integrationRequest = new IntegrationRequest(BuildCondition.ForceBuild, request.SourceName, userName);
                        }

                        // Send the request on
                        GetIntegrator(arg.ProjectName).Request(integrationRequest);
                        FireForceBuildProcessed(arg.ProjectName, userName);
                    }
                });
            return response;
        }
        /// <summary>
        /// Requests the specified project name.	
        /// </summary>
        /// <param name="projectName">Name of the project.</param>
        /// <param name="integrationRequest">The integration request.</param>
        /// <remarks></remarks>
		public void Request(string projectName, IntegrationRequest integrationRequest)
		{
            BuildIntegrationRequest request = new BuildIntegrationRequest(null, projectName);
            request.BuildCondition = integrationRequest.BuildCondition;
            Response resp = cruiseServer.ForceBuild(request);
            ValidateResponse(resp);
		}
        public void FireMandlesMissingParameters()
        {
            var request = new IntegrationRequest(BuildCondition.IfModificationExists, "test", null);
            var innerTriggerMock = this.mocks.StrictMock<ITrigger>();
            Expect.Call(innerTriggerMock.Fire()).Return(request);
            var trigger = new ParameterTrigger
                {
                    InnerTrigger = innerTriggerMock
                };
            mocks.ReplayAll();
            var actual = trigger.Fire();

            mocks.VerifyAll();
            Assert.AreSame(request, actual);
            Assert.AreEqual(0, request.BuildValues.Count);
        }
Example #30
0
 /// <summary>
 /// Sends a build request to the server.
 /// </summary>
 /// <param name="projectName">The name of the project to use.</param>
 /// <param name="integrationRequest"></param>
 public virtual void Request(string projectName, IntegrationRequest integrationRequest)
 {
     throw new NotImplementedException();
 }
 /// <summary>
 /// Creates the initial integration result.	
 /// </summary>
 /// <param name="project">The project.</param>
 /// <param name="workingDirectory">The working directory.</param>
 /// <param name="artifactDirectory">The artifact directory.</param>
 /// <returns></returns>
 /// <remarks></remarks>
 public static IntegrationResult CreateInitialIntegrationResult(string project, string workingDirectory, string artifactDirectory)
 {
     IntegrationRequest initialRequest = new IntegrationRequest(BuildCondition.ForceBuild, "Initial Build", null);
     IntegrationResult result = new IntegrationResult(project, workingDirectory, artifactDirectory, initialRequest, IntegrationSummary.Initial);
     result.StartTime = DateTime.Now.AddDays(-1);
     result.EndTime = DateTime.Now;
     return result;
 }
Example #32
0
 /// <summary>
 /// Sends a build request to the server.
 /// </summary>
 /// <param name="projectName">The name of the project to use.</param>
 /// <param name="integrationRequest"></param>
 public override void Request(string projectName, IntegrationRequest integrationRequest)
 {
     manager.Request(projectName, integrationRequest);
 }
 public void Request(IntegrationRequest request)
 {
     if (State == ProjectIntegratorState.Stopping) throw new CruiseControlException("Project is stopping - unable to start integration");
     AddToQueue(request);
     Start();
 }
        /// <summary>
        /// Starts the new integration.	
        /// </summary>
        /// <param name="request">The request.</param>
        /// <returns></returns>
        /// <remarks></remarks>
        public IIntegrationResult StartNewIntegration(IntegrationRequest request)
        {
            IntegrationResult newResult = new IntegrationResult(project.Name, project.WorkingDirectory, project.ArtifactDirectory, request, LastIntegration);
            newResult.ArtifactDirectory = project.ArtifactDirectory;
            newResult.ProjectUrl = project.WebURL;
            NameValuePair.Copy(LastIntegrationResult.SourceControlData, newResult.SourceControlData);

            return currentIntegration = newResult;
        }
        /// <summary>
        /// Checks if two <see cref="IntegrationRequest"/> instances are the same.
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public override bool Equals(object obj)
        {
            IntegrationRequest other = obj as IntegrationRequest;

            return(other != null && other.BuildCondition == BuildCondition && other.Source == Source);
        }