Snapshot Dependency Setup

I'm in the process of switching from CruiseControl to  TeamCity, and I have everything up and running but there's a behavior I  would like to ideally implement.  Basically I have 3 environments: dev  (not built in team city), staging, and production.  Currently and  previously, I use svn tagging to mark releases to staging and  production, and staging pulls from trunk while production pulls from the  staging tag.

I am very interested in the Snapshot Dependency feature in TeamCity,  but it has a blocking limitation for me if I understand it correctly.   What I would like to do is run staging builds from team city for the QA  team to test, and have a snapshot dependency on staging from production.

The problem, as I see it, is that if they are both linked to my svn  trunk, as is required for snapshot dependencies, then if I try to run a  production build, it will build on the head of trunk and force a staging  build if there isn't one for the head revision first.  What I would  LIKE it to do is to run a production build on the most recent successful  staging build.

The reasoning is that I might complete my development for a given  release cycle, move on to other things during testing, and then do a  release once testing is done.  I know I have other options, such as a  stable-trunk/feature-branch svn strategy, or do a manual teamcity  revision build for production, but I'd like to make this as simple on  myself as possible.

Thanks in advance,
Luke

5 comments
Comment actions Permalink

Is there no solution to this?  I can see two feasible solutions, but I don't think either are possible.  If someone could just confirm this, that'd be great.

Solution 1: No snapshot dependency, but have a dynamic url in the the VCS for production.  (i.e. svn://myserver/repository/tags/Staging_{buildNumber})
Solution 2: Set up snapshot dependencies, but tell teamcity to *not* force a build on staging for the head of the trunk, but instead use the most recent successful staging build revision number.

Help, please?

0
Comment actions Permalink

If production build have to be started manually, you can set snapshot dependency from prod to staging and start build using custom build dialog. In custom build you can set last change to include to last change included into the last successful staging build.

Running such a build automatically is a bit tricky and may require custom plugin for TeamCity. You can run custom build by HTTP request (from another build): http://www.jetbrains.net/confluence/display/TCD5/Accessing+Server+by+HTTP  The problem is - if you need to run build on a specific change you'll need to know TeamCity internal id of this change, which is not easy to obtain without plugin.

0
Comment actions Permalink

Well, this is at least a step in the right direction.  Not sure if this will be useful to anyone, but here is a powershell script that will get the internal change id of the latest staging build, and then will trigger a build on production for that change id.

$serverURL = "http://yourserver.com:yourport"
$stagingBuildTypeID = "bt2"
$prodBuildTypeID = "bt3"

if ([System.String]::IsNullOrEmpty($args[0])) {
    $TCUsername = Read-Host "Team City Username"
} else {
    $TCUsername = $args[0]
}

if ([System.String]::IsNullOrEmpty($args[1])) {
    $TCPasswordEnc = Read-Host "Team City Password" –AsSecureString
    $TCPassword = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($TCPasswordEnc))
} else {
    $TCPassword = $args[1]
}

$buildFeedURL = "$serverURL/httpAuth/app/rest/buildTypes/id:$stagingBuildTypeID/builds?status=SUCCESS"
$changeFeedURL = "$serverURL/httpAuth/app/rest/changes?build="
$buildUrl = "$serverURL/httpAuth/action.html?add2Queue=$prodBuildTypeID&modificationId="

$webClient = new-object System.Net.WebClient
$credential = new-object System.Net.NetworkCredential($TCUsername, $TCPassword)
$webClient.Credentials = $credential
$xml = [xml]$webClient.DownloadString($buildFeedURL)

$buildID = $xml.builds.build[0].id
$xml = [xml]$webClient.DownloadString($changeFeedURL + $buildID)

$stats = $xml.changes.change | measure id -max
$changeID = $stats.Maximum

$webClient.DownloadString($buildUrl + $changeID)

0
Comment actions Permalink

To the teamcity crew: has there been any improvement on the ability to run a build based on the svn revision of a previous successfull build (other than from the custom build dialogue?)

0
Comment actions Permalink

Not yet, I would recommend to submit feature request for this.

0

Please sign in to leave a comment.