0

So when I create a branch in my repo - it's either a bugfix or a feature. The thing to note is it could either branch from master or X. In team city I want to do a branch specification so that I will only build if the feature or bug fix came from X not from master, I am wondering if perhaps it is something like:

+: feature* ^X

+: bugfix* ^X

Or if there is a different way of handling this, please advise. I want to build if a bugfix or a feature came off of a specific branch.

thanks

  • try to gather some info from `http://stackoverflow.com/questions/27122891/nightly-build-for-release-branch-if-branch-exists/28448113#28448113` – Nevin Raj Victor Apr 08 '15 at 09:31

1 Answers1

0

Teamcity won't know the parent rbanch of your branch. So you can do things

  1. Give a logical name to all branches that come from "X" ,(for ex call them x-)and set a filter to only run on x-* named branches

  2. Within the teamcity target , run a git command to find the parent branch and exit silently/failure if the parent branch is not the X-branch (this feature will not work if you delete branch X. It will then point to the parent of branch X , which might well be master)

You can use the below snippet

current_branch=`git rev-parse --abbrev-ref HEAD`
parent_branch=`git show-branch -a | ack '\*' | ack -v "$current_branch" | head -n1 | sed 's/.*\[\(.*\)\].*/\1/' | sed 's/[\^~].*//'`
Biswajit_86
  • 3,661
  • 2
  • 22
  • 36
  • 1. is most logical, but the branches are from Jira types so we can only add 1 filter, and we really need 2 filters. 2. Is there any chance of getting an example of this, I think this is the route I need to go. – Megan Masanz Apr 02 '15 at 13:30