In your IDEA, File
- Open
, select .teamcity/pom.xml
, import as project
, and you'll have a Maven project.
Mostly a standard Maven project structure. The entry point settings.kts
defines the TeamCity project.
There are 3 subprojects in the TeamCity project hierarchy: Check
for Gradle builds, Promotion
for releasing Gradle versions, Util
for miscellaneous utilities.
After you make a change, you can run mvn clean teamcity-configs:generate
to generate and verify the generated TeamCity configuration XMLs.
You also need to run mvn clean verify
with Java 8 before committing changes.
If you have ktlint errors, you can automatically fix them by running mvn com.github.gantsign.maven:ktlint-maven-plugin:1.1.1:format
.
We use Kotlin portable DSL to store TeamCity configuration, which means you can easily create a new pipeline
based on a specific branch. Currently, we have two pipelines: master
and release
, but you can easily create
and test another isolated pipeline from any branch.
We'll explain everything via an example. Let's say you make some changes on your branch myTestBranch
(we highly recommend to name this branch without prefix and hypen (-
) because it's used to generated build type ID) and want to
test these change without affecting master
/release
pipeline, here are the instructions.
- Click the left side bar "VCS Roots" here and create a VCS root here
- Suppose the VCS root you just create is
MyNewVcsRoot
. Set "default branch" tomyTestBranch
where your code exists.
- Suppose the VCS root you just create is
- Click
Create subproject
button at the bottom of "Subprojects" region of this page- Select
Manually
. - Give it a name. The name will be displayed on TeamCity web UI, we highly recommend it to be capitalized from branch name, i.e.
MyTestBranch
. - The project ID will be auto generated as
Gradle_MyTestBranch
. If not, you probably selected wrong parent, the "Parent project" should beGradle
.
- Select
- Now click into the new project you just created. The url should be
https://builds.gradle.org/admin/editProject.html?projectId=Gradle_<MyTestBranch>
. - Click
Versioned Settings
on the left side bar.- Select
Synchronization enabled
-use settings from VCS
-MyNewVcsRoot
(the one you just created) -Settings format: Kotlin
, thenApply
.
- Select
- At the popup window, click
Import Settings from VCS
. Wait a few seconds.- If the error says "Context Parameter 'Branch' missing", it's ok. Click into the error and add a context parameter
Branch
with valuemyTestBranch
. Go back and it automatically reloads. - If there're any errors, read the error and fix your code.
- IMPORTANT NOTE: if the first import fails, you have to select and apply
Synchronization disabled
, then repeat the step above. Otherwise, TeamCity complains "Can't find the previous revision, please commit current settings first". - If anything bad happens, feel free to delete the project you created and retry (you may need to apply
Synchronization disabled
before deleting it).
- If the error says "Context Parameter 'Branch' missing", it's ok. Click into the error and add a context parameter
If no errors, your new pipeline will be displayed on TeamCity web UI:
Gradle
|------ Master
| |--------- ...
|
|------ Release
| |--------- ...
|
|------ MyTestBranch
|---------- Check
| |--------- QuickFeedbackLinux
| |--------- QuickFeedback
| |--------- ...
| |--------- ReadyForRelease
|
|---------- Promotion
| |--------- Publish Nightly Snapshot
| |--------- Publish Branch Snapshot
| |--------- ...
|
|---------- Util
|--------- ...