Home > CruiseControl.Net > CruiseControl.NET and PowerShell

CruiseControl.NET and PowerShell

It’s been a while – I’m still busy with work, study and a family – not as much time to write as I would like Sad smile

I’m currently playing around with PowerShell in my job at the moment. Basically we never have enough time, so I’m trying to figure out how to automate various tasks via PowerShell. And I’ll admit, so far I like it! It is easy to use, has a lot of power and flexibility and there are limitless possibilities for what can be done. But this post isn’t about PowerShell in general – instead I’ve been playing around with building a PowerShell provider for CruiseControl.NET.

“What? But why?” you might say. A while back I built a command-line tool that allows people to interact with a CruiseControl.NET server. But it is very limited and is fairly complex for what it actually does (in terms of the code for it.) As I was playing around with PowerShell I started thinking a lot of the syntax in PowerShell would allow me to build a much better command-line tool, especially when I started seeing the extensibility options for PowerShell.

So I have started putting together a PowerShell provider for CruiseControl.NET. This allows an administrator to connect to a CruiseControl.NET server and administer it. As I’m still playing around with things the code is production quality yet, so use it at your own peril! There is no installer – you will need to grab the code off SourceForge and build it, then copy the contains of the PowerShell\Bin\Debug folder into your modules directory (see help about_modules in PowerShell.)

However if you are interested in seeing what can be done, take a look at the following screen shots:

image

Here I am:

  • Importing the module
  • Seeing the new drive that has been mapped
  • Getting the child items in the various folders
  • Starting all the projects
  • And forcing a build for all the projects

I like how I can work with multiple projects at the same time – in my previous tool we would have needed to run the tool once for each project!

I have implemented the cmdlets in the provider to use the pipeline, so we can use a lot of the functionality within PowerShell. For example if we only wanted to get the projects for a certain queue:

image

This is something that wasn’t even thought of in the command-line tool! And here it is, without any extra work on my behalf Smile

At the moment I have only implemented four cmdlets:

  • Get-Log
  • Start-Project
  • Stop-Project
  • Start-Build

Plus the provider infrastructure (i.e. you can use built-in cmdlets like Get-Item, Get-ChildItem, Set-Location, New-PSDrive, etc.) Currently I have mapped the local server to local:. It is possible to connect to other server using New-PSDrive as long as you know the address for it (this is the same address that CCTray uses.) I have implemented the provider as a hierarchy. The top level is the server itself, with two sub-folders: Queues and Projects.

My next step is to add builds in, but I think this is going to need some changes on the server side to work.

Hopefully this will be helpful to someone Winking smile

Advertisement
Categories: CruiseControl.Net Tags:
  1. Scott Walters
    2 June, 2011 at 1:50 am | #1

    I’ve looked for this on sf.net but can’t find it. Can you please post a link to the source?

    Thanks,
    Scott

  2. Lars Truijens
    2 May, 2011 at 6:42 pm | #3

    Nice initiative. Are you sure it is a good idea to use PS Drives to connect to the ccnet servers? Wouldn’t that make it more difficult to manage a lot of CCNet servers? Maybe making a cmdlet to get the projects is better? Get-CCNetProjects localhost | Stop-Project

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.