Build dependencies with TeamCity - teamcity

I have to build: Internet & Common. I would like that when I click on "Run" for the "Internet" build that the "Common" build executes first.
Is it possible ? I saw artifact dependencies, but I don't need any data to be copied, I just want to build "Common" before "Internet" every time a build for "Internet" is requested.
Thanks

If they're using the same VCS root, then configuring a snapshot dependency between the "Internet" build configuration and the "Common" build configuration will enable you to do that; this basically ensures that all the dependencies are built from the same snapshot of the VCS.
If you must have the "Common" build execute regardless of its current state, then uncheck the default 'Do not run new build if there is a suitable one' option. This will ensure "Common" is run every time you hit Run on "Internet".

Related

Moving files between build chain builds

What is the set up required to move files between builds in TC? I am needing to move both modified source files and build binaries between the build configurations of a build chain.
I have 1 project with 4 builds. The builds are
Update Version Number (This build updates 15 sources files)
Compile (This build compiles a dozen objects)
Test (This build runs a regression test)
Create Package (This build creates a setup.exe file)
Information about the TC setup and chain
I am using perforce as my VCS.
All 4 builds use the same VCS root.
On all 4 builds under version control settings I have "Clean all files before build" set to "On".
"Update Version Number" build is triggered by any check in to the VCS. (This works)
I have been able to successfully chain and trigger the builds. However each build starts with a fresh copy of files from the VCS.
The chaining is set up to use snapshot dependency.
Based off of the TC documentation it looks like I should be using snapshot dependency and not artifact dependency. If I put the build steps of all the builds into the same build everything works. However we are looking to have more flexibly and expand on this build chain in the future.
I tried setting up the configuration so only the first build is attached to the VCS root and the other builds don't have any VCS root. This didn't work.
I have been unable to find the answer googling but I have been able to find someone else who is struggling with this problem. Sadly they didn't receive an answer.
After speaking with TC customer support I learned the correct technique is to use both artifact dependency with "build from the same chain" selected and snapshot dependency.

TeamCity snapshot build configuration

I have big problem with configuring TC. It's 10.0.2 version.
I want build chain like this:
Main - Restore nuget and rebuild solution.
Code analysis - Analyse code result(do not checkout) use Main as dependency.
Publish - Publish to Azure - Use result of Main.
I set Main to:
Build numer format:%build.counter%.%build.vcs.number....%
VCS checkout dir: auto
Code analysis
Build number format:%build.counter%.%dep.<mainId>%.%build.vcs.number...%
VCS checkout dir:%dep.<mainId>.build.default.checkoutDir%
And the main dir is: 55660246e9f668c3
And Code Analysis searching in: 9ccd5731845f5aba
So it's wrong. Why?
Why?
EDIT:
What I set VCS checkout directory in "Code Analysis" build configuration to hardcoded directiory name of "Main" e.x. to 55660246e9f668c3 then it work.
So the problem is with %dep.<mainId>.build.default.checkoutDir%
You can set up a snapshot dependency, that builds from the same chain. This will ensure that the same branch, from the same root, with the same revision number (point in time) is checked out to the directory. If you use an artifact dependency, in addition to the snapshot dependency, you can achieve the same point in time consistency. So after your step 1 build runs, regardless of what new changes exist, your second build will be working with the same files your first had.

TeamCity feature branch artifact dependencies

I have a canary build (BuildA) in TeamCity (10.0.2) that builds master, develop, and all feature/* branches when commits occur.
I'd like to create another build (BuildB) that takes a small set of artifacts from BuildA, and runs FxCop on the files. And I want BuildB to have a Finish Build trigger, so that when BuildA completes for any branch, BuildB will get the artifacts from that branches build and run.
There seem to be some hurdles to setting this up:
When I open the "Edit Artifact Dependency" box, I have to specify a "Build branch", which is a logical branch name, not a wildcard or pattern match. So I don't know how to setup an artifact dependency on all builds coming out of BuildA.
The "Finish Build Trigger" has a branch filter, which looks like I can put "+:*" in to catch all branches, but how does that line up with the "Artifact Dependency" branch name value?
Why dont you just trigger BuildB, which in turn builds BuildA instead.
Then you can get artifacts from that specific build easily.

Conditionally ordering tasks in Gradle

Consider a Gradle plugin that adds three tasks to a project - a buildZip task to create a distributable zip of the project, a publishZip task to publish that zip to a shared repository, and a cleanZip task to clean up any local version of the zip. For local development, cleanZip buildZip will be used frequently, but the automated build system will be running buildZip publishZip cleanZip.
One of the projects in which this plugin is being used wants to run their build using Gradle's parallel flag to allow the different parts of the project to be built in parallel. Unfortunately, this runs into a problem with the zip tasks - buildZip depends on the project actually building, but cleanZip doesn't have any dependencies so it can run right away, leading to the automated build system not being able to clean up.
Declaring any dependencies between these tasks isn't a good idea because they should be able to be run separately. Also, I can't specify mustRunAfter (at least between buildZip and cleanZip) because sometimes clean should be first and sometimes build should be first.
How can I tell Gradle what order to run these tasks in, in a way that will be honored by --parallel and isn't hardcoded to have a particular one always run before the other?
What you can do is: detect if gradle is run with --parallel and based on this configure dependencies between tasks appropriately. It can be done in the following way:
println project.gradle.startParameter.parallelProjectExecutionEnabled

Build a TeamCity config without rebuilding dependent config

In TeamCity* I have Build Config A and Build Config B**.
Config B depends on Config A, so when I ask B to build it checks if A needs building first.
That's usually what I want - but I often want to tell it "just execute Config B's steps without checking if A needs rebuilding".
I can't seem to work out how to do that!
The dependency is both a Snapshot Dependency and Artifact Dependency - so it must be tied to a particular instance of Config A's build - I'm ok to have to specify this.
--
[*] TeamCity v8, but as I started setting this up v9 came out, so will move to that shortly - in case that makes a difference
[**] The names have been changed - and workflow simplified - to protect the innocent
'Do not run new build if there is a suitable one' will only work if there are no pending changes and it's been recently built.
Are you avert to changing the dependency to not be a snapshot dependency and linking it to a particular artifact? You can do that under artifact dependencies by selecting from the drop down "Build with specified build number" or "Latest successful build". Of course you'd have to change it back when you were done if you wanted to switch back to snapshot dependency only.

Resources