VCS Root OR Artifact Dependencies

Answered

Hi,

I have a number of build chains that look like

A -> B -> C

For projects where I have a git vcs root, my first build config A is one to generate the short git hash for the latest commit. The next build B (usually "compile code/package") uses this for version/build numbers. C is "Deploy".

Both A and B have the same vcs root in their configurations (although A doesn't check anything out). C has no vcs root but has a snapshot dependency on B and a vcs trigger with "trigger on changes in snapshot dependencies" checked. B has a snapshot dependency on A.

This means the whole chain is triggered on any changes to the vcs root.

My question is: Is it better practice to only use the VCS Root in A, check everything out and provide the source as artifact dependencies to B?

 

Cheers :)

0
7 comments

Hello Pete,

The recommended approach is to attach VCS root to the build configuration B and checkout out sources in this build configuration. As far as you configured snapshot dependencies, all builds in chain will use the same revision of the sources.

Build artifacts are files produced by a build and stored on the TeamCity server. Please do not use artifact dependencies to share VCS sources.

0
Avatar
Permanently deleted user

Many thanks Alina.

Just to be clear, both A and B will have the VCS root attached?

Cheers, Pete

0

If you do not need any sources to be checked out for the build configuration A, then there is no need to attach VCS root to this build configuration.

If in C you have "trigger on changes in snapshot dependencies" configured and a commit is made in the VCS root attached to B build configuration, then the [whole build chain](https://confluence.jetbrains.com/display/TCD9/Build+Dependencies+Setup#BuildDependenciesSetup-SnapshotDependencies) will be added to the queue.

If you want build A to be always started, then disable "Do not run new build if there is a suitable one" in snapshot dependency in build configuration B.

0
Avatar
Permanently deleted user

I don't need to check anything out, but I _do_ need to access the %build.vcs.number% parameter so I can generate a short hash from it.

If I don't have the vcs root attached to A, then the %build.vcs.number% parameter is not available to the build configuration. I guess this is another situation where the vcs root needs to be attached, regardless of whether anything is being checked out. 

0

In this case you can attach VCS root to build configuration A, or generate a short hash as a first build step in build configuration B.

1
Avatar
Permanently deleted user

I'll take the former option thank you. I wish to use the build number in the Assembly Info Patcher which, I believe, runs before any of the build steps.

0

Yes, Assembly Info Patcher runs before all the step, so the first approach is suitable in your case.

Happy building!

0

Please sign in to leave a comment.