Install Go agent in a pipeline
Using the Agent Wizard is the simplest way to deploy a new agent by selecting Language-specific > Go > Install in a pipeline.
Select the installation method
Select GitHub or Bitbucket.
Configure the agent
A connection token is the recommended method. Set CONTRAST__API__TOKEN in the environment where you run your application.
Install the agent in GitHub
The Go agent is installed by replacing go with contrast-go in the command that builds your application. The contrast-go build command builds an executable with Contrast embedded in it. Command line arguments for Go are also available.
If you use GitHub pipelines, add the following step to your GitHub Action to install
contrast-go:- name: Install contrast-go shell: bash run: | go run github.com/contrast-security-oss/contrast-go-installer@latest latestReplace
go buildwithcontrast-go buildin your build step with the following code:- name: Build instrumented app run: contrast-go build -o output-name-of-application
Add the following environment variables to the step running your application:
env: CONTRAST__API__TOKEN: ${{ secrets.ContrastAPIToken }} CONTRAST__APPLICATION__NAME: ${{ secrets.ContrastApplicationName }} CONTRAST__APPLICATION__METADATA: ${{ secrets.ContrastApplicationMetadata }}
Install the agent in Bitbucket
If you use Bitbucket Pipelines, add the following step to your pipeline to install the agent:
- step: script: - go run github.com/contrast-security-oss/contrast-go-installer@latest latestBuild the application by replacing your normal go build command with contrast-go build. This builds an executable with Contrast embedded in it:
contrast-go build -o output-name-of-application
Store the API token in a Bitbucket secured variable named
CONTRAST__API__TOKENso the agent can read it from the environment when the application runs.
Verify the agent deployment
Interact with your application as you normally would. For example, interact with your application's web interface or send API commands.
In the Agent Wizard, select View agent activity to verify that your agent appears in the agents list.
Verify that you see the name of your application in the applications list.
In Northstar, select Applications from the left navigation.
In Contrast, select Applications from the header.
Verify that you see the name of your local server in the servers list.
In Northstar, select Servers from the left navigation.
In Contrast, select Servers from the header.