Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

Introduction

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

Before you begin, do as follows:

1. Install TeamCity on your machine.

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

Setup via Windows PowerShell 

1. In TeamCity, click Administration.

Image Modified

2. Click Create Project.

Image Modified

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.

Image Modified

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

Image Modified

5.On the left pane, click the 'Build Steps' section, and then click '+Add build step':

Image Modified


6. Select  'PowerShell' as 'Runner type' 'Source code' as the 'Script':

Image Modified

Enter the following PowerShell commands and fill in the relevant 'apiKey', configuration path and project path for the machine that you want to scan:

Info
titleNotice 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.

...

No Format
powershell bitsadmin /transfer mydownload /dynamic /download /priority FOREGROUND https://github.com/whitesource/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/whitesource/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]


The first command downloads the latest version of the WhiteSource Unified Agent Jar file to the job folder.
The second command downloads the latest version of the WhiteSource 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.

7. Save and run the job.

TeamCity Using Shell Scripts

1. Download CURL, add it to your PATH environment variable. If the following message is displayed ''curl' is not recognized as an internal or external command', then add it to the parameters as displayed in in the following screenshot:

Image Modified

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: 

...