When using Team City snapshot dependencies, are you using snapshot post-build files or just the SVN version number?

I have 2 build configurations in one project:

  • Build and Test Code
  • Expand code

I want Deploy Code to run only if Build and Test Code were successfully created, so I configured the snapshot dependency.

Does snapshot dependency mean that Deploy Code checks the same version of SVN as Build and Test Code, and then runs an NAnt script against this check, which will not contain post-build files created by the compiler? Or will a snapshot's dependency on build and testing code on Deploy Code mean that NAnt will work against build files after build, build work files, and test code in the build agent?

UPDATE:

It seems that I have set the snapshot dependency in Build and Test Code for Deploy Code, and I have the latest build for the assembly and test code, my NAnt script will deploy the post assembly files for this Build and Test Code assembly.

Still, I would like to confirm that I understand the concept, since I really do not understand the Team City document. I think that I should probably make sure that Deploy Code works in the same build agent as Build and Test Code, otherwise I might run into a situation where Deploy Code checks the version of SVN and then just expands the preliminary code files assembly. Is it correct?

My confusion is mainly due to the fact that it seems you need to install VCS for Deploy Code. Is it because he needs to compare version numbers with snapshot dependencies?

+7
source share
2 answers

In the Snapshot Dependence section of the Doco dependent constructions page :

The dependence of the snapshot on the configuration of assembly A for assembly configuration B provides that each assembly A has an “appropriate” assembly from B, so that both assemblies use the same source of snapshots (the revision sources used correspond to the same moment).

So, the idea of ​​depending on the snapshot is that you can run the assembly from the same code base as another assembly that successfully works against it.

If you want the "deploy code" assembly to start only after the "assembly and test code" has completed successfully, create a snapshot dependency in the second assembly and make sure that it is set to "Use only successful assemblies from suitable ones".

Keep in mind that this has nothing to do with artifacts; the second assembly will simply pull out the same code base and recompile it again and again. If you want to deploy artifacts created from the first build, then you want to look at the dependencies of the artifact. This is what Paul wrote about in his answer, and this is the right approach.

As for your update, it looks like these post-build files are only available because they are still in the build agent after the first build. Try to run the first assembly, then “clean up the sources” on the agent and run the second assembly. You will see that the original compilation result no longer exists and it will not work. This is important because if you have multiple assembly agents or the time between two assemblies, you simply cannot rely on a result that is not saved because artifacts still exist.

And yes, TeamCity documentation is confusing :)

+7
source

I have a very similar setup in TeamCity, except that I use MSBuild, not NAnt, but I use the same two-step process, and if I explain how I set it up, I hope this will let you know what you need to do.

So, in my setup, Build 1 pulls the code from the source control, compiles it, and runs unit tests. He then publishes all the files necessary for deployment as artifacts.

In assembly 2, there is a snapshot and dependencies of the artifact on assembly 1, which means that it does not pull the code, it just takes artifacts from assembly 1 and deploys them.

In practice, this means that I can run Build 2, and one of two things will happen. If Build 1 is updated, it simply deploys artifacts from the last successful Build 1 build. However, if Build 1 is not updated, TeamCity automatically launches Build 1, and then starts Build 2 immediately after using the artifacts to build from.

+6
source

All Articles