Unable to render embedded object: File (TeamCity48.png) not found.

TeamCity 9.x Documentation

Documentation for Previous Versions


You are viewing the documentation of TeamCity 9.x, which is not the most recently released version of TeamCity.
View this page in the latest documentation or refer to the listing to choose the documentation corresponding to your TeamCity version.

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

The use of plugins allows you to extend the TeamCity functionality. See the existing TeamCity plugins written by JetBrains developers and community.

This document provides information on how to develop and publish a server-side plugin for TeamCity using Maven. The plugin will display the Hello World page when using a specific URL to the TeamCity Web UI.

A plugin in TeamCity is a zip archive containing a number of classes packed into a JAR file.

Set up the environment

To get started writing a plugin for TeamCity, set up the plugin development environment.

  1. Download and install TeamCity on your development machine. Since you are going to use this machine to test your plugin, it is recommended that this TeamCity server is of the same version as your production server. We are using TeamCity 9.0.2 installed on on Windows 8 Pro in our setup.
  2. Download and install a Java IDE; we are using Intellij IDEA 14.0.3 Community Edition, which has a built-in Maven integration.
  3. Download and install Oracle Java. Set Java_Home on your system. We are using Java 1.7.0_25.
  4. Download and install Apache Maven. Set M2_HOME. Run mvn -version to verify your setup. We are using Maven 3.2.5. in our setup.

Generate a Maven project

  1. Generate a Maven project from an archetype residing in JetBrains Maven repository; executing the following command will produce a project for a server-side-only plugin depending on 9.0 TeamCity version:
    You will be asked to enter the Maven groudId, artifactId, version and packaging for your plugin. The artifactId will be used as the internal name of your plugin.

We used the following settings:
groudId- teamcity.plugin.demo
artifactId - demo-plugin
version - 1.0
packaging - pom
When the build finishes, you'll see that the demo-plugin directory (the same name as the artifactId) was created.

Project structure

The root of the demo-plugin directory contains the following:

  • the readme.txt file with minimal instructions to develop a server-side plugin
  • the pom.xml file which is your Project Object Model
  • the teamcity-plugin.xml file which is your plugin descriptor containing meta information about the plugin.
  • the demo-plugin-server directory contains the plugin sources:
    • \src\main\java\pom contains the App.Java file
    • src\main\resources\META-INF folder contains bean definition files. TeamCity plugins are initialized in their own Spring containers and every plugin needs a Spring bean definition file describing the main services of the plugin. The build-server-plugin-demo-plugin.xml is a bean definition file for our plugin.
  • the build directory contains the xml files which define how the project output is aggregated into a single distributable archive.

Edit the plugin descriptor

Edit the teamcity-plugin.xml file in the project root folder and add the plugin display name and description by modifying the corresponding
attributes in the file. You can also specify additional information, such as the plugin author, email and etc.

  • создаём класс с определённым содержимым - контроллер выдающий строку Hello world
  • билдим проект мавеном
  • копируем зип побилженного плагина в <TeamCity data directory>/plugins
  • стартуем сервер и убеждаемся что плагин работает

Можем по ходу дела ещё порекомендовать использовать IntelliJ IDEA Community Edition, потому как бесплатно и Мавен интеграция есть.
Понятно, что тут тебе нужен кто-то из девелоперов в помощь, хотя бы для ревью. По Мавену может помочь Никита (но с 19-го он в отпуске) или Андрей Титов, он пользовался Мавеном для Sonar плагина, я тоже могу помочь, поревьювить текст.

  • No labels