How to trigger TeamCity on Git push?
Tags: teamcity, devops, automation, jira
Published: 2021-07-23 08:10:01

---
title: How to trigger TeamCity on Git push?
published: true
description: This piece of my DevOps automation series is a practical guide for automating TeamCity builds for Jira users. With the help of Automation for Jira and Better DevOps Automation for Jira, we are looking at automating a TeamCity build configuration. Follow this guide to cut on manual tasks and automate TeamCity from the convenience of the commit message!
tags: teamcity, devops, automation, jira

---
![Trigger Teamcity automatically from commit messages](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xwfrggjiz2zw7hwruoi6.png)

Previously in this series of Jira DevOps automation tutorials, we discussed [how to trigger a Jenkins build](https://midori-global.com/blog/2021/05/18/how-to-trigger-a-jenkins-build-on-commit) and [how to trigger a Bamboo build](https://midori-global.com/blog/2021/05/03/how-to-trigger-a-bamboo-build-on-commit) on successful Git commit.

Now we are looking at a Jira automation for TeamCity. We will walk through how you can automatically trigger a TeamCity build on Git push by using a specific command in your Git commit message.

_Do you prefer a tutorial video? Watch this quick YouTube video on how to create an automation rule for triggering a TeamCity build:_
https://www.youtube.com/watch?v=SeEoYukc8Fc

#### Extending Automation for Jira with DevOps triggers
     
The below DevOps automation solution is based on Automation for Jira (Data Center and Server) and [Better DevOps Automation for Jira](https://marketplace.atlassian.com/apps/1224574/better-devops-automation-for-jira?hosting=server&tab=overview&utm_source=devto&utm_medium=jdoa-series-teamcity&utm_campaign=content-marketing) to automate a TeamCity build.

Better DevOps Automation for Jira extends Automation for Jira with DevOps triggers that you can use in any no-code, low-code automation rule in Jira.

You can freely combine the [DevOps automation triggers](https://midori-global.com/products/better-devops-automation-for-jira/server/documentation/automation-triggers?utm_source=devto&utm_medium=jdoa-series-teamcity&utm_campaign=content-marketing) by Better DevOps Automation with the built-in Automation for Jira actions, and implement a wide range of custom DevOps workflows.
If you are new to Better DevOps Automation, don't skip the introductory blog on this [DevOps automation solution for Jira Data Center (and Server)](https://midori-global.com/blog/2021/02/28/devops-automation-for-jira-data-center-and-server?utm_source=devto&utm_medium=jdoa-series-teamcity&utm_campaign=content-marketing).

#### Trigger a TeamCity build on Git push

This Jira automation rule for TeamCity will trigger on Git push if your developers used the @build command in the Git commit message.
They can control if a TeamCity build should trigger after every successful push of code changes.

Better DevOps Automation introduces so-called Genius Commits, which are commits containing custom commands in the commit message.
This gives them a seamless way to change the @build command to something else, and control other CI/CD actions without switching context.

Steps to trigger TeamCity on Git push:

1. Create a new Automation for Jira rule and choose the [Genius Commit created trigger](https://midori-global.com/products/better-devops-automation-for-jira/server/documentation/automation-triggers?utm_source=devto&utm_medium=jdoa-series-teamcity&utm_campaign=content-marketing#genius-commit-created-trigger) from the DevOps category!

    ![Choosing the Automation for Jira DevOps trigger for triggering TeamCity](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bj5gs4ej7ehlqgcc2u1n.png)

2. Choose the command *"Build (@build)"* from the list of commands!

    ![Selecting the build Genius Command for triggering TeamCity](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/384suvhedrk3b2fancvc.png)

3. Select the [Send web request](https://confluence.atlassian.com/automation/actions-993924834.html?utm_source=devto&utm_medium=jdoa-series-teamcity&utm_campaign=content-marketing#Actions-sendwebrequestSendoutgoingwebrequest) automation action!

    Supply your Webhook URL for TeamCity:
    
    `<YOUR_TEAMCITY_SERVER_BASE_URL>/app/rest/latest/buildQueue`
     
    Replace the placeholders with your actual TeamCity base URL. If you are using a modern version of TeamCity which supports CSRF protection, check [the documentation for further instructions](https://midori-global.com/products/better-devops-automation-for-jira/server/documentation/continuous-integration/teamcity?utm_source=devto&utm_medium=jdoa-series-teamcity&utm_campaign=content-marketing#with-command-configuration). 

4. Add a header with the name _"Authorization"_ and with the value of _"Bearer <YOUR_TEAMCITY_ACCESS_TOKEN>"_. Replace the placeholder with the actual TeamCity Access Token. (Watch the tutorial video above if unsure how to create an access token!)

5. Add a header with the name _"Content-Type"_ and with the value _"application/xml"_.

6. Leave the HTTP method selector on _POST_!

7. For Webhook body, choose _Custom data_ and enter the following: 

    `<build> <buildType id="BUILD_CONFIGURATION_ID"/> </build>`
    
    Replace the actual value of your TeamCity build configuration ID, located at your build settings in TeamCity. 

    ![Setting up the Automation for Jira action to trigger TeamCity on Git push](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/31m021sxb4384zcxky5f.png)

8. Save and turn on your automation rule!

You can control more than one build configuration in TeamCity with commands!
Read further on [how to define the TeamCity build configuration](https://midori-global.com/products/better-devops-automation-for-jira/server/documentation/continuous-integration/teamcity?utm_source=devto&utm_medium=jdoa-series-teamcity&utm_campaign=content-marketing#with-command-and-build-config-id) in the commit message.

You can control more than one build configuration in TeamCity with commands! Read further on how to define the TeamCity build configuration in the commit message.

Give this TeamCity Jira DevOps integration a try for free now!

[Trigger TeamCity builds on Git push!](https://marketplace.atlassian.com/apps/1224574/better-devops-automation-for-jira?hosting=server&tab=overview&utm_source=devto&utm_medium=jdoa-series-teamcity&utm_campaign=content-marketing&utm_content=cta)