Skip to content

Latest commit

 

History

History
211 lines (125 loc) · 15.4 KB

README.md

File metadata and controls

211 lines (125 loc) · 15.4 KB

teamcity-build-scan-plugin

The work on this software project is in no way associated with my employer nor with the role I'm having at my employer. Any requests for changes will be decided upon exclusively by myself based on my personal preferences. I maintain this project as much or as little as my spare time permits.

Overview

TeamCity plugin that integrates with the Build Scan service and more generally with Gradle Enterprise for Gradle and Maven builds run via TeamCity. Build scans are available as a free service on scans.gradle.com and commercially via Gradle Enterprise.

For each Gradle and Maven build that is run from TeamCity, this plugin exposes the links to the created build scans in the TeamCity UI. The plugin can also be configured to ad-hoc connect Gradle and Maven builds to an existing Gradle Enterprise instance such that a Build Scan is published each time a build is run from TeamCity.

The plugin is available from the JetBrains Marketplace.

Build Scan

Recent Build Scan: https://gradle.com/s/yevfzaz2bvvh4

Find out more about Build Scan for Gradle and Maven at https://scans.gradle.com and https://gradle.com.

Installation

Option 1: Conveniently select plugin

  1. Go to the plugin list of your TeamCity installation at <TeamCityInstanceRootUrl>/admin/admin.html?item=plugins and browse the plugins repository.

  2. Select, install, and activate the plugin as described here.

Option 2: Manually upload plugin

  1. Download the plugin .zip file from https://plugins.jetbrains.com/plugin/9326-integration-for-gradle-and-maven-build-scans.

  2. Go to the plugin list of your TeamCity installation at <TeamCityInstanceRootUrl>/admin/admin.html?item=plugins and click on the link Upload plugin zip to install the previously downloaded plugin .zip file.

  3. Restart TeamCity.

Integrations

Build Scan links surfacing

Gradle builds

If you use TeamCity's Gradle runner to launch your Gradle builds, there is nothing special to do.

If you use TeamCity's Command Line runner to launch your Gradle builds, you can opt in to enable build scan detection using the buildScanPlugin.command-line-build-step.enabled configuration parameter.

If the first two mechanisms will not work for your Gradle build configurations, you can still get integration with build scans, but it requires your build logs being parsed for build scan links. In case of huge build logs, this can put a significant toll on the performance of your TeamCity instance. You can enable the parsing of the build logs by setting the buildScanPlugin.log-parsing.enabled configuration parameter to true.

Maven builds

If you use TeamCity's Maven runner to launch Maven builds, there is nothing special to do.

If you use TeamCity's Command Line runner to launch your Maven builds, you can opt in to enable build scan detection using the buildScanPlugin.command-line-build-step.enabled configuration parameter.

If the first two mechanisms will not work for your Maven build configurations, you can still get integration with build scans, but it requires your build logs being parsed for build scan links. In case of huge build logs, this can put a significant toll on the performance of your TeamCity instance. You can enable the parsing of the build logs by setting the buildScanPlugin.log-parsing.enabled configuration parameter to true.

Gradle Enterprise connectivity

You can ad-hoc connect Gradle and Maven builds to an existing Gradle Enterprise instance by automatically injecting the Gradle Enterprise Gradle plugin and the Gradle Enterprise Maven extension when these builds are run via TeamCity's Gradle or Maven runner. If a Gradle or Maven build is run via TeamCity's Command Line runner the auto-injection can be opted in to, too. If a given build is already connected to Gradle Enterprise, the auto-injection is skipped.

The same auto-injection behavior is available for the Common Custom User Data Gradle plugin and the Common Custom User Data Maven extension.

The higher in TeamCity's project hierarchy the required configuration parameters are applied, the more widely they apply since the configuration parameters are passed on to all child projects. Child projects can override the configuration parameters of their parent projects and even disable the auto-injection by setting the appropriate configuration parameters to empty values.

For convenience, the configuration parameter values can be defined through a form describing a Gradle Enterprise connection. Alternatively, the configuration parameter values can be defined as TeamCity configuration parameters.

Configuration via TeamCity connection

A Gradle Enterprise connection can be created in the Connections section of the configuration of a given project. In the Add Connection dropdown, select the Gradle Enterprise connection type.

Fill out the Add Connection dialog with the URL for the Gradle Enterprise instance, the plugin and extension versions to be applied, and any other fields as needed. Some values, such as the plugin and extension versions, will be pre-populated.

A Gradle Enterprise connection can be created on any project and is automatically inherited by all its child projects.

Click for an example configuration. gradle-enterprise-connection-dialog

Configuration via TeamCity configuration parameters

As an alternative to the configuration via a TeamCity connection, you can describe the configuration via TeamCity configuration parameters on a given project.

The TeamCity configuration parameters can be set on any project and are automatically inherited by all its child projects.

Click for an example configuration.

Gradle Builds

  1. In TeamCity, on the build configuration for which you want to apply Gradle Enterprise, create three configuration parameters:

    • buildScanPlugin.gradle-enterprise.url - the URL of the Gradle Enterprise instance to which to publish the Build Scan
    • buildScanPlugin.gradle-enterprise.plugin.version - the version of the Gradle Enterprise Gradle plugin to apply
    • buildScanPlugin.ccud.plugin.version - the version of the Common Custom User Data Gradle plugin to apply (optional)
  2. If required, provide additional configuration parameters for your environment (optional):

    • buildScanPlugin.gradle-enterprise.allow-untrusted-server - allow communication with an untrusted server; set to true if your Gradle Enterprise instance is using a self-signed certificate
    • buildScanPlugin.gradle.plugin-repository.url - the URL of the repository to use when resolving the GE and CCUD plugins; required if your TeamCity agents are not able to access the Gradle Plugin Portal
    • buildScanPlugin.command-line-build-step.enabled - enable Gradle Enterprise integration for Command Line build steps; by default only steps using the Gradle runner are enabled
Example Gradle Configuration
image

Maven Builds

  1. In TeamCity, on the build configuration for which you want to integrate Gradle Enterprise, create three configuration parameters:

  2. If required, provide additional configuration parameters for your environment (optional):

    • buildScanPlugin.gradle-enterprise.allow-untrusted-server - allow communication with an untrusted server; set to true if your Gradle Enterprise instance is using a self-signed certificate
    • buildScanPlugin.gradle-enterprise.extension.custom.coordinates - the coordinates of a custom extension that has a transitive dependency on the Gradle Enterprise Maven Extension
    • buildScanPlugin.ccud.extension.custom.coordinates - the coordinates of a custom Common Custom User Data Maven Extension or of a custom extension that has a transitive dependency on it
    • buildScanPlugin.command-line-build-step.enabled - enable Gradle Enterprise integration for Command Line build steps; by default only steps using the Maven runner are enabled
Example Maven Configuration
image

Slack notifications (experimental)

  1. In Slack, create a webhook and keep track of the created URL.

  2. In TeamCity, on the build configuration for which you want to be notified about published build scans, create a configuration parameter with name buildScanPlugin.slack-webhook.url and the value being the URL of the webhook created in step #1.

  3. Trigger your Gradle builds with build scans enabled.

  4. Find a notification about the published build scans in the Slack channel configured in the webhook.

Compatibility

Build Scan links surfacing

The version of the Gradle Enterprise Gradle plugin and the Gradle Enterprise Maven extension that are applied to a build must meet a minimum version requirement for the link surfacing to work.

TC Build Scan plugin version Minimum supported GE Maven extension version Minimum supported GE Gradle plugin version
0.23+ 1.11 3.0 (or Gradle Build Scan plugin 1.8)
0.22 1.0 3.0 (or Gradle Build Scan plugin 1.8)

Gradle Enterprise connectivity

The configured version of the Gradle Enterprise Gradle plugin and the Gradle Enterprise Maven extension that get automatically applied by the TeamCity Build Scan plugin must be compatbile with the version of the Gradle Enterprise server that the build is connecting to.

Gradle builds

The compatibility of the specified version of the Gradle Enterprise Gradle plugin with Gradle Enterprise can be found here. The compatibility of the optionally specified version of the Common Custom User Data Gradle plugin with the Gradle Enterprise Gradle plugin can be found here.

Maven builds

The compatibility of the specified version of the Gradle Enterprise Maven extension with Gradle Enterprise can be found here. The compatibility of the optionally specified version of the Common Custom User Data Maven extension with the Gradle Enterprise Maven extension can be found here.

For Maven builds, the version of the Gradle Enterprise Maven extension automatically applied by the TeamCity Build Scan plugin is currently bundled by the plugin and cannot be configured. This will change in a future version of this plugin.

Click for an overview of what Maven extension versions are bundled and injected.
TC Build Scan plugin version Injected GE Maven extension version Injected Common CCUD Maven extension version
Next 1.17 1.11.1
0.33 1.16.1 1.11.1
0.32 1.15.4 1.11.1
0.31 1.15.3 1.11.1
0.30 1.15.1 1.11
0.27 - 0.29 1.14.3 1.10.1
0.25 - 0.26 1.14.2 1.10.1
0.23 - 0.24 1.14.1 1.10.1

Feedback and Contributions

Both feedback and contributions are very welcome.

Acknowledgements

  • bigdaz (several prs related to the Gradle Enterprise integration)
  • clayburn (several prs related to the Gradle Enterprise integration)
  • marcphilipp (pr #53 that adds Gradle 4/5 compatibility to the Gradle Enterprise integration)
  • ldaley (pr #53 that adds Gradle 4/5 compatibility to the Gradle Enterprise integration)
  • madlexa (pr #47 that adds TeamCity 2022.04 compatibility)
  • facewindu (pr #21 that includes init script test coverage)
  • dmitry-treskunov (bug report and proposed fix)
  • pbielicki (pr #17 that adds a hint to the BuildScanServiceMessageMavenExtension @Component)
  • jonnybbb (pr #14 and #15 that store build scan links under artifacts and clean up legacy data)
  • davidburstromspotify (bug report and proposed fix)
  • guylabs (pr #10 that provides support for the Gradle Enterprise Gradle plugin)
  • autonomousapps (pr #9 that provides build scans for Maven builds)
  • mark-vieira (pr #6 that provides message service functionality)
  • pavelsher (several code pointers)

License

This plugin is available under the Apache License, Version 2.0.

(c) by Etienne Studer