guylabs / teamcity-build-scan-plugin

TeamCity plugin that integrates with build scans.

Home Page:https://gradle.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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 Build Scan for Gradle and Maven. 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 instrument Gradle and Maven with Gradle Enterprise.

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.

Version compatibility

<=0.22

These plugin versions require that you use at least Gradle Enterprise Gradle plugin 3.0 or Gradle Build Scan plugin 1.8 in your Gradle builds, or Gradle Enterprise Maven extension 1.0 in your Maven builds.

>=0.23

These plugin versions require that you use at least Gradle Enterprise Gradle plugin 3.0 or Gradle Build Scan plugin 1.8 in your Gradle builds, or Gradle Enterprise Maven extension 1.11 in your Maven builds.

It is recommended that you use the latest Gradle Enterprise Gradle plugin version or latest Gradle Build Scan plugin version and the latest Gradle Enterprise Maven extension version at all times to get the most insights from your builds.

TeamCity build runner requirements

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 using the buildScanPlugin.log-parsing.enabled configuration paramter.

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 using the buildScanPlugin.log-parsing.enabled configuration paramter.

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.

  4. Trigger your Gradle builds with build scans enabled.

  5. Find the links of the published build scans in the Overview section of each TeamCity build.

Integrations

Gradle Enterprise

You can have the Gradle Enterprise Gradle plugin and the Gradle Enterprise Maven extension automatically injected into your Gradle and Maven builds when the 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. 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 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 Gradle Enterprise connection, as explained below.

Creating a Gradle Enterprise Connection

A Gradle Enterprise connection is 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, any plugin or extension versions to be applied, and any other fields in the dialog 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.

Note: For Gradle, the Common Custom User Data Gradle plugin must be at least version 1.7 or newer.

Note: For Maven, the Gradle Enterprise Maven extension and the Common Custom User Data Maven extension are currently hard-coded to versions 1.15.4 and 1.11.1, respectively.

Example Configuration

gradle-enterprise-connection-dialog

Injecting Gradle Enterprise via Configuration Parameters

It is possible to inject Gradle Enterprise by manually setting configuration parameters. Click for more details.

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
    • buildScanPlugin.log-parsing.enabled - use log parsing to extract Build Scan urls (if the default mechanism for capturing Build Scan links is not working)
  3. Trigger your Gradle build.

  4. Find the links of the published build scans in the Overview section of each TeamCity build.

Note: For Gradle, the Common Custom User Data Gradle plugin must be at least version 1.7 or newer.

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.maven-version-check.enabled - enable a Maven version check to ensure that the Gradle Enterprise Maven Extension is not applied to Maven builds lower than version 3.3.1
    • 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
    • buildScanPlugin.log-parsing.enabled - use log parsing to extract Build Scan urls (if the default mechanism for capturing Build Scan links is not working)
  3. Trigger your Maven build.

  4. Find the links of the published build scans in the Overview section of each TeamCity build.

Note: For Maven, the Gradle Enterprise Maven extension and the Common Custom User Data Maven extension are currently hard-coded to versions 1.15.4 and 1.11.1, respectively.

Example Maven Configuration
image

Slack

  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.

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

About

TeamCity plugin that integrates with build scans.

https://gradle.com

License:Apache License 2.0


Languages

Language:Java 49.0%Language:Groovy 45.1%Language:Shell 3.3%Language:Batchfile 2.3%Language:JavaScript 0.3%