Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Skip step in personal builds in TeamCity

on my CI server running TeamCity 8.0 I have a build configuration whose last steps are the creation and the push of a new version of a NuGet package.

I wonder if there is a way to inhibit these two steps if the current build is a personal one.

Any clue?

like image 431
Kralizek Avatar asked Sep 18 '13 08:09

Kralizek


People also ask

How do I disable build step in TeamCity?

You can disable a build step temporarily or permanently, even if it is inherited from a build configuration template, using the corresponding option in the last column of the Build Steps list.

What is personal build in TeamCity?

A personal build is a build-out of the common build sequence which typically uses the changes not yet committed into the version control. Personal builds are usually initiated from one of the supported IDEs via the Remote Run procedure.

How do I pause TeamCity build?

Pausing Build Configuration To pause a single build configuration, open its Build Configuration Settings or Home page. In the Actions menu, click Pause and enter your comment in the Pause dialog (optional).


1 Answers

There's an environmental variable thats exposed in teamcity that can tell you if this is a personal build BUILD_IS_PERSONAL :

See http://confluence.jetbrains.com/display/TCD7/Predefined+Build+Parameters

E.g. using the msbuild runner (you just need to supply the nuget path)

<Project DefaultTargets="Pack" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

  <Target Name="Pack" Condition="$(BUILD_IS_PERSONAL)!='True'">
    <Message Text="Personal: $(BUILD_IS_PERSONAL)"/>
    <Exec Command="$(NUGETPATH)\nuget pack $(NugetProject)"/>
  </Target>
</Project>

Alternatively, you could halt the condition of build steps using an extra build step. thereby making them conditional:

Add an extra build step that uses the powershell-

if (([environment]::GetEnvironmentVariable("BUILD_IS_PERSONAL","Process")) -eq "True")
{ 
  throw
}

On each build step there is the option:Execute step If you choose the option "If all previous build successfully" then the step will be passed If you choose: "Even if some of the previous build steps failed" it will execute.

like image 81
James Woolfenden Avatar answered Oct 11 '22 08:10

James Woolfenden