Skip to content

CruiseControl.NET: PowerShell tasks

March 18, 2011

Sometimes before you start building you need to perform some more additional actions on build server(e.g. clean up some folder or replace config files). The way out is to use PowerShell. You can easily specify tag in CruiseControl.NET project configuration file and add PowerShell task.

<powershell>
<scriptsDirectory>C:\project1\scripts</scriptsDirectory><!--Scrips folder-->
 <script>delLogs.ps1</script>
 <buildArgs>-workingDir C:\project1\working</buildArgs><!-- Project working folder-->
 <executable>C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe</executable><!--PowerShell exe file path-->
 <buildTimeoutSeconds>30</buildTimeoutSeconds>
 <description>Deleted previous build test result files</description>
 </powershell>

So using this task you can do lots of after and before tasks.
If you have problems with PowerShell launching on your build machine read the following article: http://technet.microsoft.com/en-us/library/ee176949.aspx

Advertisements
3 Comments
  1. Great post, thx!
    Wasn´t aware that there are PowerShell-Tasks in CC.Net, before that I tried to use via the Exec-Task.

    One additional question: Any idea on how to execute PowerShell-Scripts from CC.Net if there´s a blank in the scriptpath? (Have a look here for what I mean: http://arcware.net/running-a-powershell-script-with-a-space-in-the-path/ )

    Thx & Regards,
    Christian

  2. Hi,
    I’ ve never met the problem like that… and currently have no change to test it…
    The easiest way out try to avoid using white spaces…

Trackbacks & Pingbacks

  1. CruiseControl.NET: PowerShell tasks II « QA Questions

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 )

Google+ photo

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

Connecting to %s

%d bloggers like this: