Skip step in personal builds in TeamCity
Asked Answered
K

5

8

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?

Kumquat answered 18/9, 2013 at 8:29 Comment(0)
C
0

TeamCity 2020.1 has added support for conditional build steps, and there is a quick shortcut to skip the build step for personal builds.

Caporal answered 21/5, 2020 at 15:21 Comment(0)
A
7

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.

Antiphon answered 14/10, 2013 at 9:59 Comment(2)
So bad the default runners don't use this to be able to prevent the execution of a step.Kumquat
I guess this is the best way to go. They could have added this option in the "Execute step if" dropdown :(Kumquat
L
0

You could create a new build configuration - leaving out those 2 steps. Then - install the TeamCity Visual Studio plugin (assuming you are using VS) and then run a personal build, choosing the build configuration you'd like to use.

Lamrouex answered 19/9, 2013 at 20:58 Comment(1)
This solution could work if I had only few configurations with this problem. Unlucky I have a template used by around 40 different configurations and it's quite unmantainable to have twice the number of configurations :( In addition I would lose the stats for the real configurationKumquat
I
0

Similar to Jordan's response I think the best approach is to separate compilation from packaging / deployment build configurations. In fact if you use Octopus to deploy then you have to keep the TeamCity Octopus deployment steps in a separate build configuration from the compilation as the NuGet feed doesn't get populated until after the build configuration has been completed successfully.

If make your packaging / deployment build configuration a dependency of the compilation build configuration and set the build trigger to only trigger after a successful build of the compilation build configuration, then it will not trigger after a personal build even if that is successful : -

TeamCity packaging / deployment build trigger

This way you are always calling the same build configuration for compilation, whether via Developers on VS using the AddIn or Release Team via the Web UI

Hope this helps

Isagoge answered 19/3, 2014 at 10:53 Comment(0)
B
0

We have a similar issue where we only wanted to build-and-deploy our local Apache Maven repository when it has changed.

One possible solution: If your build step is a Command Line (or can be), create a tiny shell script to decide if these step should be run or not.

Bowerbird answered 13/10, 2015 at 5:12 Comment(0)
C
0

TeamCity 2020.1 has added support for conditional build steps, and there is a quick shortcut to skip the build step for personal builds.

Caporal answered 21/5, 2020 at 15:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.