1

I have a git repo which contains a single .Net solution with several web applications (public site, internal site, public services) and a shared class library project. I want to deploy some of the projects based on the changes that were made. For example if I fixed a bug in public site I want to only deploy that site, if I fixed bug in public site and api I want to deploy both of them and so on. I can achieve it by creating different build configurations and using trigger rule and filter by Ant_like_wildcard folder path and deploy corresponding project.

The tricky case in when I make a change only in a shared class library but not in any of the web apps. In that case I have the following options:

  • Make a dummy change in the web apps which must be deployed

  • Include web projects which must be deployed in commit message and use VCS_comment_regexp for filtering triggers

  • Parse git commit message, set parameters using setParameter in build script and use those parameters in following steps.

I don't like any of the options because they seem hacky. Is there any better option for this case?

Giorgi
  • 30,270
  • 13
  • 89
  • 125
  • Can you change the filter on the trigger rule for each build configuration to include both the web application and the shared library folders? – tspauld Jan 26 '15 at 20:19
  • @tspauld That won't work because making a change in shared library does not necessarily mean that I want to deploy all web apps. – Giorgi Jan 26 '15 at 20:25
  • @tspauld said what I was thinking. So, what does determine which web apps should be deployed if only the shared library changes? You haven't told us that. – CoderDennis Feb 03 '15 at 22:52

2 Answers2

1

If the shared class library project is referenced as a submodule of the three other webapps, that means each webapp can chose to update to the latest commit of that shared lib project repo.

That would cause the gitlink (the special entry in the index of a parent repo) to change, which would in turn make the parent repo register a new commit (referencing the new gitlink SHA1 of the submodule repo)
That would no longer be a "dummy change".
And that would be picked up by TeamCity as a webapp new change triggering the job.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • I guess this is the correct approach but will it complicate day to day workflow for developers? For example if I work on a new feature which needs changes in web app and shared library will I need to a separate branch in both repos? – Giorgi Jan 30 '15 at 10:23
  • @Giorgi no, no separate branch needed. But if any change is made in webapp, you need to make sure that a `git add && git commit` is done at the parent repo level (which would be done anyway if the feature changes also the parent repo files): the gitlink needs to be recorded. – VonC Jan 30 '15 at 10:26
  • So I would need to create a branch only in the parent repo? – Giorgi Jan 30 '15 at 10:45
  • @Giorgi my bad: you do need to create two branches, one for each repo. I was thinking initially about two different *names*: you can call those two branches with the same name here. – VonC Jan 30 '15 at 10:48
  • @Giorgi don't forget you can set up a submodule to follow a branch: http://stackoverflow.com/a/20016830/6309 – VonC Jan 30 '15 at 10:49
0

There are few options:

  1. As mentioned above use submodule or subtree.

  2. Use git hooks to "capture" the desired branch (folder/file/path whatever you need) and execute any build/deploy script that you want to execute. If you use git hub there are much more options. Git hub named those: webhooks

for example: git diff-tree -r --name-only HEAD^1 will give you list of all modified files in the current commit. use it with grep to search for your required path.

Hope it helped you to solve your problem.

CodeWizard
  • 128,036
  • 21
  • 144
  • 167