1
votes

I am using Teamcity 9.0.2 and IntelliJ 14.1.5. I have a Teamcity build with a maven step configured with "Deploy Maven artifacts" enabled.

When I run a personal build, the artifacts get deployed to artifactory.

How do I disable deploying artifacts for personal builds by default for each of my builds?

2

2 Answers

0
votes

Currently it's not possible to execute build steps based on condition. Vote for the related request: https://youtrack.jetbrains.com/issue/TW-17939. As of now you can:

  • Create a separate build configuration without Deploy build step (recommended). You can use templates to simplify the setup. In this case it will be easier to interpret the results and the statistics of the builds will be informative.
  • If build is personal %system.build.is.personal% parameter is set to true. So you can check a condition in the build step and skip it if needed.
0
votes

This is the workaround i found to this issue. I created two additional build steps, The first labeled "Check for Personal Build" is a Nant step that validation against the BUILD_IS_PERSONAL environmental variable, and if set, updates a teamcity env.PublishPath variable.

<project name="UpdateForPersonal" default="default">
  <target name="default">
    <if test="${environment::variable-exists('BUILD_IS_PERSONAL')}">
        <echo message="##teamcity[setParameter name='env.PublishPath' value='fake']" />
    </if>
  </target>
</project>

The second step is a simple CMD the writes as dummy "Publish" message to the logs, but the "Custom published artifacts" values is from the "Deploy Artifacts To Artifactory" section padded by %env.PublishPath%.

If the build is personal, the publish to artifactory will not find any files and log warnings into the logs, but the build passes and no artifacts are published.

The value of %env.PublishPath% is set to "" by default in the configuration build.