Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents

Overview

This page describes how to integrate TeamCity with the Unified Agent.

Prerequisites

Before you begin, do as follows:

  1. Install TeamCity on your machine.

  2. Install TeamCity Agent in order to be able to start builds.

  3. Make sure that the relevant package manager is installed. For details, see https://whitesource.atlassian.net/wiki/spaces/WD/pages/1140852201/Getting+Started+with+the+Unified+Agent#Prerequisites.

Setup via Windows PowerShell 

1. In TeamCity, click Administration.

2. Click Create Project.

3. In Create Build Configuration, select Manually for workspace on a local or a Github/repository via URL in case you have a project on GitHub. Enter the missing fields and click Create.

...

4. Click +Create Build Configuration, enter a suitable name it and click + Create build configuration. This step moves to the New VCS Root window. 

...

Info

Notice on periodically fetching the Unified Agent

It is advised to use the below powershell commands only once a week to download the latest version of the Unified Agent for performance reasons and not as part of every build. You can do this using a scheduler task, such as cron.

Code Block
powershell bitsadmin /transfer mydownload /dynamic /download /priority FOREGROUND https://github.com/Mend/unified-agent-distribution/releases/latest/download/wss-unified-agent.jar $pwd\wss-unified-agent.jar 
powershell bitsadmin /transfer mydownload /dynamic /download /priority FOREGROUND https://github.com/Mend/unified-agent-distribution/raw/master/standAlone/wss-unified-agent.config $pwd\wss-unified-agent.config 
java -jar wss-unified-agent.jar -apiKey xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx -c [path to config file] -project my-project -d [path to folder to scan]

8. Note the following:

  • Set the WS_CHECKPOLICIES environment variable to TRUE.

  • The first command downloads the latest version of the Mend Unified Agent Jar file to the job folder.

  • The second command downloads the latest version of the Mend Unified Agent configuration file to the job folder.

  • The third command runs the Jar with the default command line arguments of the Unified Agent.

  • Make sure that you have edited the Unified Agent configuration file to match your requirements.

  • Make sure that Background Intelligent Transfer Service (BITS) is enabled on your project job.

9. Save and run the job.

TeamCity Using Shell Scripts

...

2. Create a project via the same steps that were described in the previous section.

3. In the new 'Custom script' window add the following commands: 

Jira Legacy
serverSystem JIRA
serverId724b5413-de14-3029-bdc3-ec42660dfa05
keyDOC-549

Code Block
curl -LJO https://github.com/Mend/unified-agent-distribution/raw/master/standAlone/wss_agent.sh
chmod +x wss_agent.sh
wss_agent.sh -apiKey xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx -c [path to config file] -project my-project -d [path to folder to scan]

Note the following:

  • Set the WS_CHECKPOLICIES environment variable to TRUE.

  • The first command downloads the 'wss_agent.sh' script file to the job folder.

  • The third command runs the script 'wss_agent.sh'. This script downloads the latest version of Mend Unified Agent Jar file and configuration file to the TeamCity Agent work folder.  The script runs the Jar with the default command line arguments of Unified Agent.

  • Make sure to edit the Unified Agent configuration file to match your requirements.

Example screenshot of build configuration:

...

4. Save and run the build.

Adding the Policy Violations Report in the TeamCity Web Application

The TeamCity Web application enables you to create custom report tabs that are displayed on its Build pages. This tutorial demonstrates how to create the Mend Policy Violations report as a separate tab:

  1. In the TeamCity Web Application, go to Administration ><Root Project> > Specific project.

  2. In the Projects Settings pane, select the Report Tabs.

  3. Click Create new Build report tab.

  4. Enter the following in the Edit Report Tab Settings window that opens:

    1. Tab Title: Enter the title for the report (e.g., ‘Mend Policy Violations Report’)

    2. Start page: The Start page value should be the path to the Mend Policy Check Summary report (index.html). For example, ‘Mend\Mend\index.htm’

  5. Click Save.

...

is available at: https://docs.mend.io/bundle/unified_agent/page/teamcity_integration.html