Skip to content

TeamCity (CI/CD)

TeamCity is a CI/CD server by JetBrains that supports pipelines configured via the UI or Kotlin DSL (configuration-as-code). It integrates with Git providers (GitLab, GitHub, Azure Repos), offers rich test/artifact reporting, and scales horizontally with build agents.

  • Great for .NET, Java, and Node monorepos
  • Kotlin DSL makes changes reviewable and reproducible
  • Strong caching, test history, and build chains
  • Server: orchestrates projects and build configurations
  • Build Agents: workers that execute jobs; match via agent requirements
  • Projects & Build Configurations: pipeline hierarchy and steps
  • VCS Roots: connections to repositories
  • Parameters: build-time variables (env.*) and references (%param%)
  1. VCS change triggers a build on the server
  2. Server assigns work to an available agent matching requirements
  3. Steps run (e.g., npm ci; npm run build) and artifacts are published
  4. Status is reported back (e.g., to GitLab MRs)
  1. Create a Project and set a VCS Root (GitLab/GitHub)
  2. Add a Build Configuration
  3. Choose UI steps or enable Kotlin DSL and commit settings
  4. Install build agents; tag agents (e.g., windows, linux) for targeted jobs
version = "2024.03"
project {
vcsRoot(GitVcsRoot {
id("BankyBlueprintsRepo")
name = "bankyblueprints"
url = "https://git.example.com/BankyTech/bankyblueprints.git"
branch = "refs/heads/main"
})
buildType(BuildType {
id("Build_Site")
name = "Build Astro Site"
vcs {
root(DslContext.settingsRoot)
root("BankyBlueprintsRepo")
cleanCheckout = true
}
steps {
script {
name = "Install"
scriptContent = "npm ci"
}
script {
name = "Build"
scriptContent = "npm run build"
}
}
triggers { vcs {} }
artifactRules = "dist=>site"
})
}

Tips:

  • Cache Node.js and package manager caches between builds
  • Use agent requirements to target OS/tooling
  • Use parameters for secrets; prefer secure parameters where possible
  • Use VCS Root to connect to GitLab
  • Add Commit Status Publisher to report pass/fail to Merge Requests
  • Optionally mirror pipelines by triggering from GitLab webhooks

See: ./teamcity/gitlab-integration

  • Introduction: ./teamcity/introduction
  • Build configurations: ./teamcity/build-configurations
  • GitLab integration: ./teamcity/gitlab-integration
  • Parameters: ./teamcity/parameters
  • Templates: ./teamcity/templates
  • VCS Roots: ./teamcity/vcs-roots
  • Prefer Kotlin DSL for maintainability and code review
  • Pin tool and runner versions; leverage caches
  • Use snapshot dependencies to orchestrate multi-project builds
  • Keep build steps idempotent and fast