Trigger Executable/HTTP Request from CC.Net - cruisecontrol.net

I'm in the process of moving build projects from CC.Net to Jenkins. However, I need to run a few projects from CC.Net for a while until the migration is complete. Simply put, I want the CC.Net project to do nothing but trigger a job in Jenkins, by using a HTTP request as remote trigger.
I've already set up everything in Jenkins. All I need to do is add the project to CC.Net and have this project trigger my Jenkins job.
I have been unsuccessful in triggering the Jenkins job. I've tried using a HTTP Request as well as an Executable (created a small console application which does the HTTP request). Whenever I try to force the build from my CCTray, the build server tells me "Exception Caught: Input string was not in a correct format.". This should give an idea about what I've tried:
<project name="Test32" queue="venus-02">
<tasks>
<exec>
<executable>C:\key\TestRemoteTrigger.exe</executable>
</exec>
</tasks>
</project>
I don't need any fancy stuff. I just want the CC.Net project to run my executable. Or even better, to simply perform the HTTP Request. But I can't get it to work, and I've come up empty using Google - mostly because every topic I find is about something much more complex which is the opposite of what I need.

Okay, after some stabbing at the keyboard I figured out it was not what I was, or was not, putting inside the section... it was what I was missing outside it. And was apparently not needed.
This will work:
<project name="Test32" queue="venus-02">
<publishers>
<exec>
<executable>C:\key\TestRemoteTrigger.exe</executable>
</exec>
</publishers>
</project>

Related

Is is possible to pass parameters between CC.NET projects?

I have CC.NET configured with 2 projects like this
BuildApp
RunSmokeTests
RunSmokeTests uses project trigger to start whenever BuildApp project finishes with Success.
When smoke tests fail I want to be able to send e-mails containing version number of our app (${CCNetLabel} from BuildApp project).
I can't find a way to do it. I thought this should be built in in CC.NET. I want to make sure that there is no such functionality in CC.NET before I come up with my own solution.
You can use a remoteProjectLabeller to label the SmokeTests project with the same label as the BuildApp project.
Otherwise you could use a ForceBuildPublisher in the publishers section of the BuildApp project, where you can pass custom parameters.
If I were to suggest an option, I'd go for the latter as there is a underlying issue with the remoteProjectTrigger which can mean that your RunSmokeTests project can fire when BuildApp fails. It is also less efficient than the ForceBuildPublisher
For example
<forcebuild>
<project>RunSmokeTests</project>
<serverUri>tcp://buildserver:21234/CruiseManager.rem</serverUri>
<integrationStatus>Success</integrationStatus>
<!-- <enforcerName>BuildApp has finished </enforcerName> -->
<parameters>
<namedValue name="$BuildAppLabel" value="$Label" />
</parameters>
</forcebuild>
There is a bug where but the enforcerName won't be passed, so don't rely on that property.
In the RunSmokeTests project you should be able to read out the $BuildAppLabel for the email.

Does ccnet.config support changing an attribute value inside an xml file?

I'm using cruisecontrol.net to do CI, but the test type is configured in an xml file is not what I want. The xml file looks like:
<config>
<Test type="A"/>
</config>
Is there any way to change it from A to B?
I would switch mentality a bit.
Think of CC.NET as a "super fancy msbuild.exe executor".
Write most of your logic in msbuild files. Then you can easily find XmlPeek and XmlPoke (XmlUpdate) "extension tasks" that are tried and true.
This has some advantages. If you ever switch from CC.NET to something else (TFS for example), having most of your logic in an msbuild (.proj) file will make that transition very easy.
The more "proprietary" tasks you write that is CC.NET specific, the deeper you get in.
I go with this:
Have CC.NET download your .proj file.
Have CC.NET excecute msbuild.exe yourfile.proj.
Have CC.NET "merge" all resulting xml.
Have CC.NET run its "publishers" (email being the most popular)
Your .proj file will have the majority of logic.
It will pull down the rest of your code.
It will build the code.
It will zip up files or create installers or whatever.
This will serve you better than trying to get CC.NET to do everything.
I don't think there is CC.NET xml-update task.
Msbuild Community Tasks has ~lots of extra tasks to get done what you want to get done.
Yes there is with parameters. See this page:
http://cruisecontrolnet.org/projects/ccnet/wiki/Parameters
When someone forces a build a dialog pops up allowing them to choose between test type A and test type B.

With an Azure project, when managing multiple service configurations, where are the current configuration choice saved

I'm wondering about this because i'd like to find a way to create a post-build event that is different whether I'm trying to compile and run in the emulator or wheter I'm compiling and publishing to the cloud.
I don't know if there is an easier way, but I thought that If I could find where the current setting (cloud or local) is saved I could branch my post-build event based on that
thx
It is in a variable TargetProfile so you should be able to do something similar to this (which is for after publish, but you get the idea):
<Target Name="AfterPublish">
<ItemGroup Condition="'$(TargetProfile)' == 'Cloud'">
<-- Do you thing here -->
</ItemGroup>
</Target>

CruiseControl.NET issue when multiple projects use shared projects

I have CruiseControl.NET configured to monitor 10+ .NET projects. All of these projects (web apps, windows services, wcf services, etc...) use shared class library projects so in the ccnet.config I had to set the svn path for each project to the root of the svn repo. If I didn't do it this way then a change to a shared assembly wouldn't trigger projects that depend on it to rebuild.
The issue is that because I've set the svn path for each project to the root of the repo then that means that any change at all triggers a rebuild of every single project, which takes a really long time. How do you get around this issue with using shared assemblies in multiple projects without having every single project rebuild every time a little change is made??
Here's another way to see the issue:
CC Project #1 = svn://repo/WebApps/WebsiteA (references svn://repo/Shared/ClassLibraryA)
CC Project #2 = svn://repo/WebApps/WebsiteB (references svn://repo/Shared/ClassLibraryB)
For CC Project #1, you can't set the svn path to svn://repo/WebApps/WebSiteA, as if you did and ClassLibraryA changed then it wouldn't trigger a build. However if you set the path to svn://repo, then it'll pick up the changes to the ClassLibraryA, but then it'd also trigger CC Project #2.
Any suggestions would be greatly appreciated...
You may want to use the Project Trigger to start a build :
http://confluence.public.thoughtworks.org/display/CCNET/Project+Trigger
If your ClassLibraryA has a project on CruiseControl (whose svnpath is svn://repo/Shared/ClassLibraryA) then your WebsiteA would look like :
<project name="WebSiteA">
<triggers>
<projectTrigger project="ClassLibraryA">
<triggerStatus>Success</triggerStatus>
<innerTrigger name="ClassLibraryA" type="intervalTrigger" seconds="60" buildCondition="ForceBuild" />
</projectTrigger>
<intervalTrigger seconds="300"/>
</triggers>
<cb:svn-block svnpath="repo/WebApps/WebsiteA" />
<tasks>
<...>
</tasks>
<publishers>
<...>
</publishers>
</project>
The answer was to use the sourcecontrol multi block in CruiseControl.NET, which allows you to specify multiple svn paths for each project:
http://ccnet.sourceforge.net/CCNET/Multi%20Source%20Control%20Block.html

How to set nant target for CCnet nightly build?

I have a default nant build that runs on every checkin in CC.net. What I would like to do is on a nightly schedule run a different nant task under the same build that would do a clean checkout of the codebase for the next day.
Is this possible with cc.net? I've done it with TeamCity and I'm rusty with cc.net as I haven't used it in awhile.
CruiseControl.Net will pass the build trigger condition to you NAnt script. So your build can invoke different targets based on property CCNetBuildCondition being set either to "IfModificationExists" or "ForceBuild".
Yes. You can create a new project in CruiseControl that runs your normal build or you can have it run a separate build (per your needs). Then schedule this project to run at a specific time (morning).
Try this: http://cruisecontrol.sourceforge.net/main/configxml.html
Or this: http://confluence.public.thoughtworks.org/display/CCNET/Schedule+Trigger
I think what you're looking for is setting up the triggers to a preset time. There is this settings. Example below from the CC.NET site.
<scheduleTrigger time="23:30" buildCondition="ForceBuild" name="Scheduled">
<weekDays>
<weekDay>Monday</weekDay>
</weekDays>
</scheduleTrigger>
You can do a build when you want, if you didn't want to do the whole thing at once you could make projects with that trigger that focused on smaller aspects of your code. That is how you make CC.NET start a build at a given time.
More info on Schedule Triggers at confluence's site

Resources