TeamCity and calendar versioning - teamcity

I recently got introduced to the concept of CalVer. I thought I'd play with the concept on a little test build, to see if I could get a meta-runner extracted to be used for other builds, should we decide to take this forward.
I'm looking to:
Have a build step that runs on Linux and Windows agents
Have a build number in the format: YY.MM.BC (2 digit year, 2 digit month and the build counter).
Have the build counter reflect the number of builds in a given month
I'm happy to play with the format more as time goes on.
I have the first parts done. To make this compatible with both our linux and Windows build agents, I've leveraged the Docker support and run the script in this step in an alpine container. It only adds on 1 second and makes it cross-platform. I then use a script like this to update the build number to a CalVer looking build.
date_portion=$(date +"%%y.%%m")
build_number=$BUILD_NUMBER
combined="${date_portion}.${build_number}"
echo "##teamcity[buildNumber '$combined']"
Results in build numbers like: 18.11.1
My question is: How would I go about making it so that builds I do in December have a build counter starting off at 1? I'd rather not have to run a build once a month to reset it if I can help it. Are there any cleaner ways?

Related

Get Current Sprint/Iteration in a Build Process Template?

How can the current TFS sprint/iteration number be included in the build number for a TFS 2012 build template?
i.e. If current iteration is Release 1/Sprint 5, would like to have build number be: 1.5.(rev number).
Currently using ReleaseDefaultTemplate.11.1.xaml (Release Management for Visual Studio 2013 build process template).
Very cool!
You would need to run something prior to the "BuildNumber" task in the workflow (that's the first activity) to go retrieve and build that data. There is no OOB help, and i would suggest that you use PowerShell to retrieve the data and set the builddetails. I say PowerShell as this will be able to be reused when you move to TFS 2015 and the new build system.
An alternative that i have used is to set the build number to "mybuild_1.5.{build}.{revission}" and use PowerShell to parse out that number. This is easy as you can use existing PowerShell to achieve it. It does however require that at the end of the sprint that you go increment the number. Not ideal, but only seconds to achieve.
https://github.com/tfsbuildextensions/CustomActivities/blob/master/Source/Scripts/ApplyVersionToAssemblies.ps1

Run a pre-script to determine if a Jenkins matrix job should be run

I have a Jenkins job consisting of a matrix style configuration. I want to run a script that determines whether that combination should be run (similar to the combination filter, but dynamic). Thus setting the job to 'No Run' (grey) or running the rest of the scripts over it and producing a result.
Is there a way (or a plugin) to do this? In the event there isn't is there a way to set a job to 'No Run' once it has started running?
Cheers,
Stu
Edit: Discussion at:
http://groups.google.com/group/jenkinsci-users/browse_thread/thread/d99e865b17575e92/6c83ee0f894980fb?lnk=gst&q=dynamic#6c83ee0f894980fb
Suggests two plugins, but perhaps a pre script looking at the previous build is just as easy.
I've done the same things.
I can't do that in matrix filter feature because it's not dynamic.
So what I've done is to add to my build script 2 groovy (pre and post) which determinate if the build should be done or not.
The first script look for a old build execution log file to determine if the current build should be done or not and save the state in a file named disabled at the root of the workspace.
The build process only continue if disabled file is not present.
The second groovy script is to store that a particular build is done and store it for further execution and remove the file.
With this method, I can do a round-robin build of 50 configuration, 6 per day.
The only problem I add is that all build are launched so all are green, and we can't quickly see which build have been really done.
Regards,
Ludovic SMADJA
JALIOS - R&D
http://www.jalios.com

CDash client setup

I'm trying to create a C++ CI environment by using CDash.
I've got CDash running on my computer and I can send some results to it from the CDash clients, by running the ctest manually.
I'm a bit lost on how to setup a client to automatically compile and test the code when the source code changes in the version control system (subversion), or at specific times.
I have the Mastering CMake book, but it doesn't seem to say much on that topic.
Is there any way to do the continuous build without hacking around with scheduled tasks / cron?
Is there any good example that would be useful to check out?
Can I somehow order to run a build on some site from the Dashboard? I kinda remember seeing this somewhere but I'm unable to find it now.
Is CDash any good for CI environments? (use comments to answer this one)
CDas#Home might be the solution. Generally I have my continuous machines run a script on a nightly cron job that polls the repository every couple of minutes for ~24 hours.

How would I hook into rake's tasks to time how long each takes, to try to eliminate slow bits of build script?

I'm interested in knowing which parts of my rake-based build (running within TeamCity) is slow. Is there an MVC-filter-style way I can wrap rake-tasks so that each one runs within a timer, and I output a breakdown of
time-spent on task including prerequisites (I guess the time between invoke starting and execute finishing)
time-spent on task excluding prerequisites (I guess the time between execute starting and finishing)
so that I can analyse which parts of my build are taking the most time, to target my optimisation efforts?
Does TeamCity have any features baked in that would do this for me? (I know I'll be able to chart the results of my performance-logging with custom-charts; I just wondered whether it could do this out of the box already.)
First, in TeamCity 6.0 there is a tree view of the build log. In this tree view you can see duration times spent for different blocks of your build.
Also, in TeamCity's rake runner, there is "Track invoke/execute stages" option, which can be enabled to get more information in your build log (and there is timing information for each record).
You can also try adding rake parameters like -t or -v in TeamCity rake settings to get more verbose output.
TeamCity also allows you to use custom service messages to provide more information to your log and to your build.
Hope this helps,
KIR

What is the initial cost of setting up CruiseControl?

What is the initial cost of setting up CruiseControl?
The key point here is not the time you have to invest in setting up CruiseControl. You can do this in an hour or so. The question is weather do you have a code repository (SVN, TFS) and a build script ready (something - MSBuild script or so - that will clean, rebuild, test and deploy your app). If not you will have to invest some time in that - depending on how complicated your project is - but surely it will take a lot more time than setting up a CruiseControl server.
Not more than two to three hours worth if you're new to it. The first time I used it I had something that checked out the latest version from subversion, compiled it using MSBuild and then upload it in less than that time.
I'd recommend Hudson over CruiseControl any day of the week. I can't think of anything CruiseControl can do which Hudson doesn't do (better). Especially the web-based frontend is far superior. You can run Hudson directly on your machine (using JNLP) and have your project setup in minutes.
It takes a little while to get it up and running - but you can get a solution to build using the task to build you .sln file in less than a day if you're a complete newbie on the subject.
It gets a little more complicated when you add unit testing in various frameworks, costumizing the dashboard, labelling your builds etc but it's a matter of days, not weeks to get anything up and running.
Software - free.
Hardware - cost depends. If you only want to run nightly it can probably share server space with something else. We use a dedicated server with builds every 15 mins.
Set up time - Once learnt you're looking at a few hours to set up a new server. If you're new to CC allow a day or two.
If you've never used an integration server before you're going to have a learning curve for the entire team - allow a few weeks.
We've recently moved to a new server and we set up a fresh installation - it took a few hours. That's for four projects, two different source control providers, and includes custom tasks like reporting and building help files.
I'd recoccomend a dedicated machine for cruise control, it doesn't have to be amazingly powerful but bear in mind it had to be able to compile your code.
We used an old developer's machine, which was put aside after an upgrade.
As far as the cost in time a day should have you up and running.
How do you define 'cost'? It's free to download so there's no monetary cost.
In terms of time it should take between 1/2 - 1 day, depending on how complicated your configuration is.
If you have a simple project with no dependencies then a couple of hours. If you are actually doing 'integration' of many projects with many dependencies then several weeks and possibly code changes. IMHO CC.Net doesn't scale well to large numbers of projects...
You should be able to set it up in about 3 hours and it's totally free.
Still you can spend money on external tools like Simian etc, but that's totally optional. Setting up CCnet really is a matter of going through the configuration documentation and that's it.
I blogged about my experiences with CCnet before: http://www.tigraine.at/2008/10/08/another-take-on-contiuous-integration/
Jay Flowers runs a project called CI Factory which enables you to put together a CruiseControl.NET installation with optional modules in no time at all.
http://jayflowers.com/joomla/
Also, you might wish to listen to the .NET rocks podcast interview with him:
http://www.dnrtv.com/default.aspx?showID=64

Resources