Frage

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?

War es hilfreich?

Lösung 2

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

Andere Tipps

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.

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.

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

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.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top