Allow project run on master only in teamcity - continuous-integration

I'm setting up teamcity and I have 2 Projects using the same VCS root, Build and Deploy.
Is there a way I can:
Trigger the build project on all branches except master
Trigger the deploy project only on master
I have it set to automatically trigger but both projects still show pending changes and a user can still manually run deploy on any branch they wish.
Build Trigger Branch filter:
+:*
-:<default>
Deploy Trigger Branch filter:
+:<default>
-:*
Do I need to configure the VCS root twice with different branch specifications?
Please let me know if I need anything else.
Thanks for your help.
Kurtis

unfortunately, you can't.
But you have to do the follows:
Delete ability to run Build and Deploy configuration from users.
Set trigger +:*; -:<default> for a Build
I hope the Deploy has dependencies from a Build.
create the new Deploy configuration, let's say Deploy only master
Add snapshot dependency from Deploy
define hidden variable reverse.dep.*.teamcity.build.branch with value <default>
So, nobody cannot run Build, and Deploy. If someone runs Deploy only master and select another branch it will not work because you will replace the teamcity.build.branch to master

Related

Get the sources from the branch that triggered the build in Team Services

I would like to create an integration build in VS Team Services, that is triggered when a commit is done to any branch (develop/feature xy) except master.
I am able to create a trigger for this:
but how do i checkout the sources of the branch that triggered the build?
In the task tab, the first step is 'Get Sources' and here i'm only able to choose one branch (the * wildcard is not possible here):
Otherwise for example a build is triggered by a feature branch, but the sources are taken from the develop branch. How can i do this?
You filter is perfectly fine if you want to build anything but master branch.
The branch you select in build definition is just the default branch used when you Queue New Build manually.
OTOH the build trigger establish which branch to download, e.g. if the build has been triggered by a git push on branch develop then that is the one checkout'ed and built.
When you queue a new build manually, you also have the chance to change the default value to whatever branch you would like to build.

TeamCity - Listen to changes in specific directory on multiple branches

I've configured vcs trigger to monitor only specific directory like this "+:SomeDirectory/**" and it was working fine when my VCS root had 1 branch configured. Recently I've made a change and configured VCS root to listen on multiple branches.
I've got feature branches based on main develop branch and i wanted to trigger build only if specific directory has been changed. Unfortunately with this configuration teamcity triggers additional build for every brand new feature branch (it assumes that it's new branch thus there are changes in directory). So i have 2 builds: if anything changed in this directory and build if branch is new.
Is it possible to trigger build on feature branches only if something changed in "someDirectory" according to my main development branch?
Yes, you do this by adding a VCS Trigger at the Trigger configuration page, where you can specify, among others, the "Branch Filter". Here you can also create VCS Trigger Rules, where you can specify which "VCS root" will trigger the build, for which directories.
Please note that the VCS Checkout Rules might influence the paths used in the VCS Trigger Rule!
E.g. consider having two VCS Roots attached to the build configuration, with checkout rules:
master-vcs-root +:. => master
feature-vcs-root +:. => feature
So the master-vcs-root checks out into [agentpath]/master, and the feature-vcs-root checks out into [agentpath]/feature.
If we only want the trigger fired based on changes made in a specific directory on the feature-vcs-root, the Trigger Rule should take the checkout directory into account:
+:root=feature-vcs-root:feature/someDirectory/*
and not
+:root=feature-vcs-root:someDirectory/*
This was found working on TeamCity Professional 2017.2.2 (build 50909).

Build and Deploy using TeamCity for DEV/UAT/LIVE

I am trying to setup TeamCity to build/deploy the site to DEV/UAT. I am not able to get or dont know how to set up TeamCity to build and deploy to remote servers after commit to a certain branch. So basically we have three branches in GIT DEV/Staging/Master and I want TeamCity to trigger build and deploy after commit to each branch separately. So if user commit/merge to dev branch then TeamCity should build and deploy to dev server and if user commit/merge to staging branch then it should build/deploy to UAT.
Is this even possible? If yes then please let me know how?
Thanks
Bruce
I believe your build server is separate from your deploy server. You can try 2 approaches
Have teamcity agents running on the deployed servers. Create artefacts in the build process and download these artefacts using the agents in the deploy steps
In case you want all your agents to run on the same server as Teamcity, Have a SSH (or similar ) functionality copy over your build artefats onto the deploy box.

Can TeamCity trigger builds for new Git branches/tags?

I only managed to get TeamCity trigger builds for new changes in branches, but not when a branch or tag is created. I'd like to automatically trigger a build when I create a version tag.
#stevechapman, thanks
Sorry, I understood this question wrong. If you want to run a build as soon as your tag is created, teamcity currently does not have a feature that runs out of the box. You can:
Configure a git post commit hook that runs a build target after you create your tag
Or you can have a custom teamcity target that scans git repo for newly created tags and run if you find any.
In case you are creating the tag in a build target in teamcity, you can create a dependent target that will run after your original target and work on the tag that you just created.

Personal build with dependencies

I've started using TeamCity personal builds, via the new Git remote run feature in TeamCity 6.5. Doing a single build works fine; I have a project that compiles from source, and I gave it a Branch Remote Run trigger.
However, it looks like TeamCity only triggers the one project that has the Branch Remote Run trigger applied. I have several unit test projects, set up in a chain with Finish Build triggers, and none of these get run. Furthermore, if I try to start a custom build of one of these unit test projects, I can't use the artifacts from my personal build: I can only pick artifacts from one of the 'official' builds.
Can I get TeamCity personal builds to work with build chains?
With the setup that you have (snapshot dependencies and finish build triggers), you can achieve build chaining by submitted your personal changes to the builds you are looking to trigger. For example, if you have projects A and B where B depends on A - run the remote build against project B and A will be triggered first and B will be added to the queue. Both of these builds will have your personal changes.
If you are using the TeamCity Visual Studio plugin you can select which builds you want to send your changes to and you just need to tick the box for B instead of A.
The finished build trigger won't be fired, but the build chaining means that A must be built first.
More info - http://confluence.jetbrains.net/display/TCD7/Build+Chain
(You have tagged TeamCity 6.5, but 7 has now been released so I have included the documentation for the newer version)
I suppose you should setup your chain not with Finish Build trigger, but with "Snapshot dependencies" feature of TeamCity. And, setup artifacts dependency basing on the snapshots.
Please read about snapshot dependencies in TeamCity here.

Resources