CI using Teamcity

Reading Time: 3 minutes

Hello everyone, In this blog, we are going to how we can create a CI-pipeline in TeamCity using the kotlin DSL script.

So before directly moving to the CI part lets see a little about teamcity.

What is Teamcity

  • TC- teamcity is a ci server

With the help of teamcity you can

  • Run parallel builds simultaneously on different platforms and environments
  • Optimize the code integration cycle
  • Review on-the-fly test results reporting with intelligent tests re-ordering
  • Run code coverage and duplicates finder for Java and .NET
  • and much more.

You need to setup the teamcity first on your machine . For knowing the teamcity more in detail you can Refere

Steps to follow for creating CI pipeline in teamcity :

Note: If you are creating pipeline for scala project you can refere this I have created for my project.

  1. Go to Administration -> Create project
  2. Provide the URL of your project(i.e SCM it may be Github, Gitlab or bitbucket any)
  3. If your repo is private you need to specify the “username and password” Value otherwise no need . Cick on create.
  4. If you VCS root connection happen successfully you get the following o/p

5. Click on Procces -> You wiill get some auto detected steps for your project.

6. You can add those steps by clicking on checkbox. Or you can create your own steps that you need add in your pipe by clicking on “Build Steps” option present on the left-hand side.

7. Click on the button “Add build step”

8. You will get a drop-down list of differant runner type. Slect the runner type you required for your project.

9. Lets suppose i selected “Simple Build Tool” for my project . You will see the following window

10. And you need to fill the details for your step. Provide step name(i.e compile ,test, packaging …etc) whatever you are going to perform . Provide SBT commands “lets suppose sbt command is ‘sbt compile’ in that case you only need to pass the arg i.e test in this field” As we already using sbt runner.

11. You can also provide the condition when you want execute the given steps in the execute step field and the directory in which you need to execute the command.

12. Click on “Save”.

One you saved. You can see the build step you added. But this is through WEB-UI right ?

How to Create the Kotlin-DSL

So here are the steps you can create script for your project conf whatever you have done through web-ui.

  1. Go to Administartion ->Select your project ->Go to the vesrioned setting option of the general setting present on left hand side.
  2. Select radio button in front of the “Synchronization enabled” -> Select the Project setting VCS root.
  3. Click on “use setting from VCS”
  4. Select “Store secure values (like passwords or API tokens) outside of VCS”
  5. change the versioned setting format from xml to kotlin. -> click on apply and you can see

Onec you get this o/p means .teamcity folder get generated in your repository which contains .settings.kts and pom.xml file.

.setting.kts is the dsl script for your project. Onec you got those file it means you web-ui become read only for you.

Now you can download those file in you project and can edit and modify this file as per your requirement.

I means whenever you are going to build your pipeline using teamcity it will execute those steps mentioned in the .setting.kts file (i.e your kotlin-dsl script). After the successfull execution will result in green signal as follows

Referances:

https://www.jetbrains.com/help/teamcity/teamcity-documentation.html
https://www.lambdatest.com/blog/teamcity-vs-jenkins-picking-the-right-ci-cd-tool/

Leave a Reply