TeamCity Build for release/* so that it picks up latest release version - teamcity

I'm trying to create teamcity build pipeline for release/* branch.I created VCS root with hardcoded value for release e.g. Default branch: refs/heads/release/1.0.0 but this is hard-coded and for each release I need to manually change the release number. Is there any way to set Default branch and Branch specification: which checks for latest release/* branch and run the build?

you can specify the branch to be build in branch specification
buildAndTestConfig.triggers {
vcs {
branchFilter = """
+:*
""".trimIndent()
groupCheckinsByCommitter = true
triggerRules = "+:release/base/*"
}
}
but a better method would be to refs/heads/release as the base branch and for each change in build number the build counter to create a folder and copy the results using the buildcounter.So you would have a base branch,when first time project is build,a new folder will be created with the build number,use that folder to copy the results .

Related

Is it possible to create a project from Git without 'master' branch?

I only have a develop branch in my repository at the moment.
When I try to create a project from it in Teamcity, I get the following error message:
Cannot find revision of the default branch 'refs/heads/master' of vcs root 'dummy VCS root (jetbrains.git)'
The question i:s how can I create a TeamCity build from repo without master branch? In Jenkins usually it makes no problem to build any branch
open attached VCS Roots of your project
Change Default branch to refs/heads/develop
Branch specification set to +:refs/heads/*
Now your default branch is develop, not a master.
Also, you able to see all branches because of the Branch specification

Change branch name when running custom build in Teamcity

Given I have Teamcity job with Git VCS root with default branch which can be changed with branch-name parameter:
When I e.g. set branch-name to develop in admin screen, go back to build configuration home and run custom build where I change branch-name parameter to master
then I get:
Why is that?
What should I change, so that I don't get this message and I can change branch when running custom build?
The reason for this is I want to build and deploy software artifacts from any feature branch
the Teamcity has an opportunity for monitoring the branches and runs built to custom branch.
Firstly, edit your VCS Root and add follows:
Default branch: refs/heads/master
Branch specification:+:refs/heads/*
now the TC will check changes by some interval.
We are sets the master as default branch. and when we run the build with default parameters, the build will start to master branch
If you are want to start build with custom branch then press Run... -> Changes -> select your custom branch from Build Branch parameter.
If you want to run build from API, or want to reverse the build branch parameter, just set Configuration parameters with key teamcity.build.branch
and value what you want

build git branch with snapshot dependency in TeamCity

Build which depends on snapshot dependency uses wrong branch.
Main VCS(for nugets, builds, code analysis):
default branch: develop, +:refs/heads/*
Environment 1 VCS:
default branch: master
And here I have snapshot dependency to build from Main VCS. And when "Environment 1 VCS" build it uses default branch from "Main VCS".
How to fix it?
build configuration has teamcity.build.branch parameter, which responsible for which branch will be used.
So, Environment 1 VCS create Configuration Parameter which will change your parent dependency configuration branch.
name = reverse.dep.*.build.branch
value = %teamcity.build.branch%
So, when you run your child configuration and select any brunch, then teamcity.build.branch=your branch
reverse.dep means Overriding Dependencies Properties for your parent configuration. It means you parent configuration will run on some branch.

How to append git short hash into Octopus release from TeamCity

Using an OctopusDeploy: Create Release runner in TeamCity, I can create a release with the build.number fairly easily.
I'd like to add a suffix of the git commit short hash.
Here is how I solved it - scraped from various internet sources
In my CI Build, I added
A parameter named system.GitHashShort
Created a Powershell runner which executes this
$hash = "%build.vcs.number%"
$shortHash = $hash.substring(0,7)
Write-Host "##teamcity[setParameter name='system.GitHashShort' value='$shortHash']"
In my Deploy build configuration which is a snapshot dependency on CI Build
For the OctopusDeploy: Create Release runner, set the release number to be
%build.number%-%dep.MyAwesomeApp.system.GitHashShort%
This then gives builds of a format like 8.3.422.34-deadbee

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.

Resources