How to Use the Space Git Flow With TeamCity
Do you use feature branches or Git flow to ensure code quality?
The powerful combination of JetBrains Space Git flow with TeamCity offers a complete solution to help you achieve better code quality and keep your main branch green with stable builds.
Space provides you with Git hosting, code reviews, and quality gates, while TeamCity offers a build pipeline. The native integration between tools will save you time and effort by ensuring you have a complete and well-integrated flow with a unified UI.
Adopting the Space Git flow with TeamCity is easy and allows you to keep your main branch stable while controlling changes automatically.
In this blog post, we’ll introduce the combo of the Space Git flow and TeamCity, and guide you through the process of using it in your project.
What Is the Space Git Flow, and Why Use it?
The Space Git flow is a branching strategy that is similar to GitHub flow, but with a greater emphasis on safety when introducing changes to the
main branch and the ability to scale to large projects and teams.
Getting started with the Space Git flow is easy and doesn’t require going all-in, as you can mirror your existing Git repository without having to migrate, and you can switch back any time.
Using the Space Git flow integrated with TeamCity allows you to:
- Achieve higher-quality code and a stable main branch by configuring quality gates based on TeamCity build status for merge requests.
- Introduce a code review process your team will love, integrated with IntelliJ IDEA and available on the go with Space iOS and Android apps.
Read this article to learn more about the Space Git flow.
How to Use the Space Git Flow With TeamCity
Watch this 3-minute video to see how the combination of the Space Git flow and TeamCity works in a project:
Read on to learn about the flow in more detail.
Mirror or host your Git repository in Space
Start by creating bi-directional mirrors of your repository from GitHub or another Git service and link it to Space in a few clicks.
You can also use Space to host your source code privately. If you host it in Space, you can take advantage of the web-based interface and JetBrains IDE integration for a seamless development experience.
main branch from accidental pushes
To prevent accidental pushes to the
main branch, you can set up branch protection in Space. This helps you protect repositories from unauthenticated commits, restrict who can push or merge changes into the branch, and prevent accidental branch deletion.
Once you’ve set up branch protection, the only way a change can make it to
main is through a merge request.
To start working on a new feature, you’ll need to either clone the repository to your machine, or use remote development with the IDE hosted on a virtual machine in the Space cloud.
With the Space Git flow, you make changes in a separate
feature branch and then request a code review before merging it back to
main. From your IDE, you can make changes, add a commit message, and then push this branch back to Space.
Create a merge request
Create a merge request to begin the process of moving your new code into
main. You can do this from within your IDE using the native integration, or you can find your branch in Space and create a merge request from there.
You can create a title and description for your merge request and see the commits that will be part of it. The quality gates configured in Space require at least one person to review these changes.
Quality gates are a mandatory and customizable set of conditions that need to be fulfilled before merging. Apart from code reviewer’s approval, you can set up a Space Automation job and a TeamCity check as gates.
Space will require a review based on code ownership
In your repository, you can create a special file named
CODEOWNERS that specifies who is responsible for specific folders and files. Later, you and your colleagues will have the option to select a code owner to review your changes as a part of quality gates.
Wait for your team to review the changes
Now you wait for your colleagues to review the changes. They can add comments and suggestions, or they can simply approve the request. With turn-based code reviews, Space makes it easy for both the author and the reviewer to understand whose turn it is to take action.
Space allows you to collect your comments as drafts and send them in batches so as not to overload your colleagues with unnecessary notifications.
After you’ve agreed on changes with your reviewer, you can proceed with merging them.
Ensure your build is green
With Space and TeamCity, there are a few options that you can use to make sure your build is green before merging your changes. You can use either or both of them for extra security.
Run CI/CD checks
After you create a merge request, Space Automation and/or TeamCity CI jobs are triggered to validate the changes by building the code and running tests. As part of quality gates, the changes will be merged into
main only if a CI/CD server can successfully build the
The checks can be set and completed by both Space Automation and TeamCity.
These checks, however, only ensure the new code is valid and integrates well with the
main branch at the time of branching. With Safe Merge, validation is done by attempting to integrate the new code with the very latest code from the
Run Safe Merge
You can use Safe Merge before merging the changes directly into
main. Safe Merge acts like a time machine – it runs a preview of what your
main branch would look like with the changes.
This can be especially useful for large projects because while you were working on a
feature branch, the
main branch could have received changes that conflict with your work. Safe Merge allows you to catch these conflicts before actually merging the branches.
Space creates a temporary commit with the latest changes, which can then be used to perform the required quality checks using an Automation job or TeamCity build.
In TeamCity, you’ll see Space trigger a special build, and TeamCity will report the build status back to Space when it’s finished. The changes are merged into the
main branch only if the build succeeds. Otherwise, the merge is rejected.
Using the Space Git flow together with TeamCity ensures that changes to your code base are always reviewed. And thanks to Safe Merge, you’ll always have a
main branch that compiles and can be deployed successfully.
How to Get Started With the Space Git Flow and TeamCity
If you already use TeamCity, getting started with the Space Git flow is easy.
- Create a Space organization to get started.
- Check out this step-by-step tutorial to configure Space Git flow and integrate it with TeamCity.
- Request a demo to ask your questions or get help tuning the flow to your specific process.
What do you think about the combination of the Space Git flow and TeamCity? We’d love your feedback in the comments below.
Subscribe to Blog updates
Thanks, we've got you!
Simple Fork-Join Framework With Matrix Builds
Matrix build in TeamCity executes the same set of steps on different combinations of input parameters, producing a matrix with the result of every execution, while using the Fork-Join pattern under the hood. Let’s see how this works.
TeamCity 2023.11: Matrix Build, Build Cache, and More
TeamCity 2023.11 is out! With this release, we’re introducing a number of highly anticipated features, including matrix builds, build caches, EC2 improvements, and more. Read on to learn more about the new features.
Meet us at AWS re:Invent 2023
TeamCity is taking part in AWS re:Invent this week! Stop by our booth to say hello and meet the team.