To foster automation between systems, integrate with Azure DevOps to execute operations in Snyk API & Web triggered from Azure pipelines using the Snyk API & Web API.
The integration involves two steps:
Get the integration information from Snyk API & Web.
Configure Azure to integrate with Snyk API & Web.
This article describes these steps in detail.
Step 1: Get integration information from Snyk API & Web
Before configuring the integration in Azure, get the necessary information from Snyk API & Web:
Get the Target Identifier (Target ID):
Generate the API Key and save it so Azure is able to do actions in Snyk API & Web. Learn how to generate an API Key.
Step 2: Configure Azure to integrate with Snyk API & Web
With the information from Snyk API & Web, it’s time to do the configuration in Azure:
Log in to the Azure DevOps (https://dev.azure.com) account and go to pipelines.
Click on the pipeline to select it and then on the Edit button on the top-right corner of the screen.
In the list of Agent Jobs, click on the plus ('+') button to add a new task.
Select Command Line from the list and click on Add.
Select the newly added Command Line Script.
Fill out the form with the command line configuration:
Set the Display name with the name of the script.
Set the Script field to:
curl -k -X POST 'https://api.probely.com/targets/<TARGET_ID>/scan_now/' -H 'Authorization: JWT <API_KEY>' -H 'Content-type: application/json' -d '{"scan_profile": "normal"}'
NOTES:In this example, we trigger a target scan using this API endpoint.
Explore the API for other operations to trigger from your Azure pipelines.In the curl command:
Replace <TARGET_ID> and <API_KEY> with the corresponding values obtained in Step 1: Get the integration information from Snyk API & Web.
If you notice, there is also a parameter defining the scan profile to be used in the scan:
-d {"scan_profile": "normal"}
. You can remove it, and the scan profile will be the one defined in the target settings.
Click on the Save & queue dropdown menu and select the Save & queue option from the list.
A Run pipeline dialog is displayed. Click on the Save and run button to manually run the pipeline and test the integration.
From now on, every time this Azure pipeline runs, it triggers the scan of the target in Snyk API & Web.