TeamCity Console
From Evgeny Goldin
Contents |
Introduction
This TeamCity plugin provides two additional tabs in Administration => Diagnostics area:
- Console - Web console to execute any arbitrary Groovy code in the context of TeamCity server, similarly to Jenkins Script Console and Groovy Web Console.
- Context - Detailed report of all existing beans in server Spring contexts with links to TeamCity Open API Javadocs.
Installation
Download plugin's archive and copy it to TeamCity plugins directory, ~/.BuildServer/plugins by default. The plugin was tested with TeamCity 7.1.
Console
This tab allows you to evaluate a Groovy expression in the context of TeamCity server, similarly to Jenkins Script Console and Groovy Web Console.
- Click
Evaluateor pressAlt+RorTaband thenEnterto run the script. - Lines starting with
#are ignored. - Use
o.propertiesando.dump()to see internal details of any object. - If evaluation results in an object from TeamCity domain - its Open API super-classes and interfaces are also displayed, try evaluating
server.
Script Context
There are a number of variables and helper functions available in the script context.
| Name | Type | Description | Example |
|---|---|---|---|
| request | HttpServletRequest
| Current HTTP request | request.headerNames.toList()
|
| context | ApplicationContext
| Plugin's Spring context. | context.getBean( 'buildServer' )
|
| server | SBuildServer
| TeamCity server instance. | server.projectManager.activeProjects
|
| c | Method accepting a String
| ClassLoader.loadClass( 'className' ) wrapper.
| c( 'web.util.SessionUser' ).getUser( request )
|
| b | Method accepting a String (bean name) or Class (bean type)
| Attempts to retrieve Spring bean or beans specified in all contexts | b( 'buildServer' ).properties
|
Examples
Feel free to send me your scripts, which I'll make available here. Here are some examples to get you started:
server [ request, context, server ] request.request.dump() new String( request.request.postData ) request.headerNames.collect{ [ it, request.getHeader( it )] } server.projectManager.activeProjects server.history.getEntries( true ).join( '\n' ) assert server == context.getBean( 'buildServer' ) c( 'web.util.SessionUser' ).getUser( request ).associatedUser.descriptiveName b( 'buildServer' ).properties b( c( 'web.openapi.SimplePageExtension' )).values()
Context
This tab provides you a detailed report of all existing beans in plugin and server Spring contexts with links to TeamCity Open API Javadocs.
Details
| Provided By | ||
|---|---|---|
| Source Code | GitHub | |
| Build Server | Gradle TeamCity | |
| Download | Artifactory Online |


