Team City multiple projects build - teamcity

my situation is the following,
i have 2 big projects running separately on two machines (1 for each project) sitting of course on different locations and running different build.xml files.
i want to be able to run them both in 1 click and have the product in 1 library at the end.
meaning i can build my entire product in 1 click.
what us the best way to do so?
thanks for the help.

I would set up a build dependency between the two projects. This can be set up so that both projects always build back to back automatically.
When the first project is finished building, the artifacts you are interested in can be pulled over to the second project with the build dependency. Then, in that second project, you can configure the artifacts to be a collection of both projects' results.
You can read more about build dependencies here:
http://confluence.jetbrains.net/display/TCD6/Dependent+Build
If anything I said was too confusing, just let me know and I will come back to clarify.
Good luck!

Related

Sonar refuses to analize multimodule project

I have upgraded from Sonar 5.3 to 6.2 and a project X is giving me some weird errors at the sonar stage of the jenkins job (altough build finishes as STABLE).
The project is a standard multimodule maven java project.
Entering the project dashboard a single message appears on screen:
"No analysis has been performed since creation. The only available
section is the configuration."
But in the upper-right corner the red "FAILED" tag shows up. That leads to the Background tasks of the project and there is the failed task with this error log:
The project "com.foo:bar-submodule-1" is already defined in SonarQube
but not as a module of project "com.foo:bar". If you really want to
stop directly analysing project "com.foo:bar-submodule-1", please
first delete it from SonarQube and then relaunch the analysis of
project "com.foo:bar"
I do not want to delete the project and lose the historical data.
So the question is: How can i add a project Y (that is a submodule of project X but Sonar does not recognize it) as a submodule of project X?
EDIT 1
The parent project is the only one that has been analyzed through jenkins jobs.
Your problem is not that Sonar can't figure out your submodules, but the root issue is that there is another project/module with the same name conflicting with the project you are analyzing now. It happens, for example, when you extract a submodule as a standalone library and moves it as a root project and try to analyse the new project. Since it is a new project, but sometime in the past you had another project/module with the exact same name, it won't be able to finish the process. I have found three ways to fix this:
Delete the old project, if it is possible
This is a option that I use when I have analysed mistakenly new projects (with wrong parameters for example) or when I am migrating servers and still have some wrong configuration in place. You can do this in the project's Configuration/Administration menu, 'Delete project'.
Rename the old projects keys
This is my default option, since usually what I want is just keep the old analyses data for old submodules that we are moving to other projects or promoting to root modules. You can do this in the project's Configuration/Administration menu, 'Update key' option.
Updating your current project's keys
This option I use when the submodules conflict with other valid submodules (It can happen when you have different teams creating small libraries that happen to have the same keys). You can do this in two steps. First you need to update your project's keys following the option 2. The next step is to go to your project and update the modules and submodules names using the key sonar.moduleKey. The default value for this is : similar to sonar.projectKey, as especified here. Following these steps you won't lose all your records and old analyses.
I hope it helps.

Is there deployment trigger for teamcity?

I know there are build triggers. But do deployment triggers exist in team city? I googled quite a bit and looked at the doc and cannot seem to find it. I basically want custom code to check few things before deploying. But it needs to happen from team city's deploy page.
You should be able to do this by adding a Build, Snapshot, or Artifact dependency. I'm guessing you want a snapshot dependency;
A snapshot dependency is a dependency between two build configurations
that allows launching builds from both build configurations in a
specific order and ensure they use the same sources snapshot (sources
revisions correspond to the same moment).
When you have a number of build configurations interconnected by
snapshot dependencies, they form a build chain.
You can then put your tests into that target (or another one in the chain) depending upon your needs. There's really too much to put into a brief answer here. It's best if you read the complete documentation.

How can I use build parameters from other projects in TeamCity?

I would like to use some build parameters from Project 1 in Project 2. I know that I can make Project 1 a dependency of Project 2 and then access its build parameters as described in Dependencies Properties, but I do not want Project 1 to be built in response to a build of Project 2. For example, suppose I want Project 2 to be built nightly, while I only want Project 1 built monthly.
Is there any way Project 2 can access Project 1's build parameters under these conditions?
I would use a build configuration template that is shared between the two projects.
This means you can share properties between the projects, but also override certain ones in each individual project.
We use this for hourly builds that are not tagged and nightly ones that are tagged.
Then use a different build trigger to set one off nightly and the other monthly.
EDIT
I'll just expand slightly as a result of your comment.
In TeamCity we have 2 build configuration for the same project. One that builds on every check-in to give developers quick feedback on their contribution (build within 15 minutes). It does the following:
Builds the project in Debug
Runs all unit tests
Checks results of build into Subversion
The other configuration runs every night at midnight; it build everything and as a result takes a long time (around 45 minutes). It does the following:
Build the project in Debug and Release
Runs all unit tests
Builds Sandcastle documentaion
Checks results of build into Subversion
Grabs the Sandcastle output at an artefact so developers can easily download it.
As you pointed out this isn't as straightforward as one would like; however you can use the following to achieve it:
We use the Autoincrementer to share build numbers between the two configurations (they both increment the same build number when built).
We have a property on template that defines what artefacts to collect and is referenced from the artefacts field. The property is overridden on the second build config to define the sandcastle output to grab.
Sharing VCS Roots is mentioned on the documentation. Both our builds get the source from the same place, and tag the results to the same place. One VCS is most definitely all we need.
Bit of a long edit but I think it goes exactly on the lines of what you're trying to achieve. I appreciate I should have included this in the original answer.
HTH
Dependency is different from Build Triggering in TeamCity. If you make one project dependent on another ( artifact dependency ), it does not mean that the the latter will trigger the former.
Even when one project has been defined as dependent on another ( and also, even if not ) you have to specify explicitly the build trigger ( in this case a Finish build trigger ) for the dependent project to be triggered.

Managing internal 3rd Party Dependencies

We have a lot of different solutions/projects which are managed by different teams. Our solution needs to reference several projects that another team owns. We don't want to add these dependencies as project references because we do not intend on modifying that code, we just want to use it. Also we already have quite a bit of projects in our solution and don't want to add a bunch more since it will slow down Visual Studio. So we are building these projects in a separate solution and adding them as file references to our solution.
My question is, how do people manage these types of dependencies? Should I just have some automated process what looks for changes to those projects, builds them and checks the dlls into our source control, after which we treat them like other 3rd party dependencies? Is there a recommended way of doing this?
One solution, although it may not necessarily be what you are looking for, is to have each dependent sub-system perform a release. This release could be in the form of a MSI install, or just a network share of assemblies. When a significant change is made, that team could let you know, and you could run the install or a script to copy the files.
Once you got the release, you could put them into the GAC, that way you would not have to worry about copying them to your project bin folders.
Another solution, assuming you are using a build server or continuous integration of some kind, is to have a post build step or process stage the files. Than at any given moment, the developers of the other teams could grab the new files , or have a script or bat file pull them down locally.
EDIT - ANOTHER SOLUTION
It might be best to ask why do you have these dependencies? Do you really need them locally when building your part of the application? Could you mock out the dependencies in your solution, allowing you to code, build, and run unit tests? The the actual application would wire these up in your DEV/Test/Prod environments. Keeping your solution decoupled and dependent free may be a better solution for the individual team. Leave the integration and coupling when the application runs in a real setting.
(Not a complete answer, but still:)
Any delivery is better stored in a file/binary repository, as opposed to a VCS used to manage sources history.
We prefer managing those deliveries in a repo like Nexus, and we are using maven to get back the right dependencies.
Even if those tools can be more Java-oriented, Nexus can store anything, and maven is only there to read the pom.xml of each artifact and compute the right dependencies.

How to recombine builds in TeamCity?

We have a lot of tests. I can break these up so that they run on seperate agents after an initial compile build happens, but is there a way I can recombine these results? Having 8 build configurations that all need to be green makes it hard to see if you've got one ubergreen build.
Is there a way in TeamCity to recombine / join builds once we've split them out? TW-9990 might help - allowing ANDs in the dependencies.
We found the answer which certainly works from TeamCity 5:
One compile build,
N test only builds that take compile.zip!** and copy to where the compile output would normally be. (via a template)
Consolidated finish:
Finish Build Trigger: Wait for a successful build in: ...
Snapshot Dependencies: Do not run new build if there is a suitable one
Only use successful builds from suitable ones
This all seems to work nicely and the whole shbang is easily copied for branches etc. Am very happy - this has worked well for us for many months now.
No idea how to do that natively. Here's my first thoughts on how I would try and tackle such a thing though:
Saving test results to files
Publishing the test result files as build artifacts
Creating a 'Merge build'
Adding artifact dependency onto the individual test projects
Writing a custom 'build' script using something like (N)Ant. This would parse the individual test results and publish the results as per the TC KB
Good luck!
Thinking outside the box you could have an overall build which doesn't really do anything (or use one of your test build configs as your 'master'), with snapshot dependencies on each of your split test builds. That way if any of them fail, the 'master' will fail because one the dependent build failed.
TW-9990 looks to be concerned with build triggering rather than dependencies.

Resources