Skip to content

Latest commit

 

History

History

samples

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Sample TeamCity plugins using the Gradle TeamCity plugin.

The following projects demonstrate the features of the Gradle TeamCity plugin.

  • server-plugin - A simple server-side only plugin.

  • agent-server-plugin - A simple plugin with an agent-side and a server-side component. This example uses external TeamCity plugin descriptor files.

  • multi-project-plugin - A plugin with agent-side and server-side built from multiple Gradle projects.

  • agent-tool-plugin - A simple tool plugin that repackages Apache Maven.

  • kotlin-plugin - A simple plugin with an agent-side and a server-side component written in Kotlin and built with scripts written in Kotlin using Gradle Kotlin DSL.

  • multiple-plugins - A sample demonstrating building and deploying multiple plugins to a TeamCity environment.

  • reloadable-plugin - A sample demonstrating reloading of a modified plugin without restarting the TeamCity environment.

  • sakura-ui-plugin - A sample demonstrating building a Sakura UI plugin.

  • docker-environment - A sample that uses Docker to run the server and agent containers.

Each sample has a project with Gradle build scripts using the Groovy DSL and the Kotlin DSL, found in the groovy and kotlin directories, except multi-project-plugin and kotlin-plugin that are equivalent projects.

To build the plugins

To build a sample plugin change into the plugin’s directory then execute the following Gradle task

    ../../gradlew build

To download and install a TeamCity distribution to test the plugin execute the following Gradle task

    ../../gradlew installTeamCity2020.1

This command will take some time but only needs to be executed once. To have the samples use the same TeamCity installation set the teamcity.environments.baseHomeDir Gradle property in a gradle.properties file for each project.

To deploy the plugin to TeamCity execute the following task, the deploy task is also executed when starting the server.

    ../../gradlew deployToTeamCity2020.1

To start the TeamCity Server and Build Agent execute the following tasks

    ../../gradlew startTeamcity2020.1Server
    ../../gradlew startTeamcity2020.1Agent

or you can start both with the following task

    ../../gradlew startTeamcity2020.1

To stop the TeamCity Server and Build Agent execute the following tasks

    ../../gradlew stopTeamcity2020.1Agent
    ../../gradlew stopTeamcity2020.1Server

or you can stop both with the following task

    ../../gradlew stopTeamcity2020.1

There are also tasks for TeamCity 2021.1, to use these versions replace the number 2020.1 in the tasks above with 2021.1.

To try the plugins

After building the plugins and starting the TeamCity Server, login to the server as an Administrator and view the installed plugins on the Administration page. The sample plugin or plugins should appear in External Plugins list.

The server-plugin only outputs a log message when it starts, check the teamcity-server.log for entries from the ExampleServerPlugin.

The agent-server-plugin, multi-project-plugin and kotlin-plugin samples create a Build Feature plugin. Create a project and a build configuration, on the Build Features page of the build configuration select the 'Example Build Feature'. Running the build will output the message ExampleBuildFeature enabled for build to the teamcity-agent.log file.

The multiple-plugins sample builds two plugins that output a log message to the teamcity-server.log when they are started, search for Example1ServerPlugin and Example2ServerPlugin.

The agent-tool-plugin sample creates a tool that can be used in a Maven build step. Create a build configuration and add a Maven build step, set the Maven selection to Custom and the Custom path to %teamcity.tool.maven3_5%. Running the build will show the version of Maven used in the Maven Build Info tab.

The reloadable-plugin outputs a log message with a descriptor parameter, build-time, when it starts, check the teamcity-server.log for entries from the ExampleServerPlugin. Executing the Gradle deploy task updates the plugin descriptor and reloads the plugin without restarting the TeamCity server.

The sakura-ui-plugin creates a plugin using the new Sakura UI built by webpack. The plugin adds a simple message to the top of the side-bar. Building the plugin requires Docker to be installed to run the webpack task. The webpack task is also configured to support the Gradle build cache, building the plugin with the --build-cache option will allow the webpack task to reuse the output from a previous build.

The docker-environment sample configures an environment to run the server and agent using Docker. The sample deploys a plugin that has server-side and agent-side components that can be used to try debugging a plugin deployed to a container. A build configuration with no VCS root and a build step using the command line runner is all that is required to execute the plugin code.