When setting up a Snyk broker, the client access is only enabled for Open Source manifest files and dockerfile access. However, to hook up the repositories for Snyk Code and IAC, one would need to set up "code agent" as well.
Note: The broker client and code-agent MUST be present in the same network.
In this example we will set up broker + code agent with Gitab.
Step 0 - Before getting started with the following sets up ensure that:
A. The broker support for the specific integration has been enabled by your Snyk point of contact or you have created it using API
B. Your Snyk Point of contact has enabled code-agent
support.
You will find your SCM or JIRA broker token in the Snyk UI under Integration Settings. Once you have the token please proceed with the following steps.
- Pull the appropriate broker client image. Details for individual image can be found here: https://github.com/snyk/broker
docker pull snyk/broker:gitlab
- Pull the code-agent image.
docker pull snyk/code-agent
- Create a network (this network will be run both code agent and broker client).
Note: You can provide any name to the network - here I am calling it
mySnykBrokerNetwork
docker network create mySnykBrokerNetwork
-
Now ensure that you have the
accept.json
in the directory structure example; /home/private on teh host machine so that you can map it to the container. Note: Theaccept.json
would be different based on different integration(Github vs gitlab etc). Make sure you have the appropriate one copied locally. -
run the broker container:
docker run --restart=always \
-p 8000:8000 \
-e BROKER_TOKEN=<YOUR-BROKER-TOKEN> \
-e GITLAB_TOKEN=<YOUR-GITLAB-TOKEN> \
-e GITLAB=<YOUR-GITLAB-HOSTNAME> \
-e BROKER_CLIENT_URL=http://my.broker.client:8000 \
-e PORT=8000 \
-e ACCEPT=/private/accept.json -v /path/on/local/private:/private \
-e GIT_CLIENT_URL=http://code-agent:3000 \
--network mySnykBrokerNetwork \
snyk/broker:gitlab
- Run the code-agent
docker run --name code-agent \
-p 3000:3000 \
-e PORT=3000 -e SNYK_TOKEN=<token> --network mySnykBrokerNetwork \
snyk/code-agent
-
At this point your logs for
broker client
should display"msg":"successfully established a websocket connection to the broker server"
and in app.snyk.io under the integration you would see "Connected". Also, see the logs of thecode-agent
to confirm its working. -
You can now seemlessly import your repos on the UI.