Abort build for all projects

23 views
Skip to first unread message

Roman Müller

unread,
Jan 9, 2012, 10:39:45 AM1/9/12
to ccnet-user
Hello


I want to abort all builds for all projects programatically before
starting the build for other projects. This is the code how i try it
but that does not work.

ProjectStatusResponse psr = manager.GetProjectStatus(new
ServerRequest());

foreach (ProjectStatus p in psr.Projects)
{
projectRequest = new ProjectRequest();
projectRequest.ProjectName = p.Name;
manager.AbortBuild(projectRequest);
}

Can someone help me please?

Best regards and thanks in advance

Ruben Willems

unread,
Jan 18, 2012, 3:01:26 AM1/18/12
to ccnet...@googlegroups.com
Hi

I use the following code, it's vb.net, but easily converted to C#

the   following if may be omitted if the 'build' is delicate --> abort will give unpredicted results
    
   If p.Activity.IsBuilding Then
           cm.AbortBuild(p.Name, "General Abort")
   End If


    Public Sub StopAllProjects(ByVal serverName As String)
        Dim ServerUri As String = String.Format("tcp://{1}:21234/{0}", ThoughtWorks.CruiseControl.Core.RemoteCruiseServer.URI, serverName)

        Dim factory = New ThoughtWorks.CruiseControl.Remote.RemoteCruiseManagerFactory()
        Dim cm = factory.GetCruiseManager(ServerUri)

        Dim projects = cm.GetCruiseServerSnapshot

        For Each p In projects.ProjectStatuses
            Console.WriteLine("Stopping project : {0}", p.Name)
            cm.CancelPendingRequest(p.Name)
            If p.Activity.IsBuilding Then
                cm.AbortBuild(p.Name, "General Abort")
            End If
            cm.Stop(p.Name)

        Next

    End Sub




with kind regards
Ruben Willems
Reply all
Reply to author
Forward
0 new messages