Creating and using the import file
How to generate the import file and use it with the snyk-api-import tool
This feature only works with Bitbucket and Azure.
snyk-scm-contributors-counttool connects both to your Snyk account and your SCM account, the tools finds out which repos/projects are monitored by Snyk and which are not.
When you apply the
importFileRepoTypeflags to the command, the tool generates an import file populated with the unmonitored repo data, to be used with the snyk-api-import tool to import the missing repos to your Snyk account.
- If the Snyk token was exported and the related Snyk account has an integration set for the specific SCM that is being scanned by the tool, the tool will try to find and match the OrgID and IntegrationID from Snyk as needed by the
snyk-api-importtool and automatically add it to the import file.
- If a Snyk token was not exported or the user has no Snyk account yet, this feature can be used to map all repos in the SCM and create the import file to be later used by the
snyk-api-importtool. In this case or if the tool can not find an OrgID or IntegrationID, the tool prompts the user to supply these IDs (once) and automatically adds them to the import file.
importConfDir- This flag indicates that a query for unmonitored repos should be made and expects a path to a folder (with write privileges) in which to create the json import files, for example :
snyk-scm-contributors-count <command> --token TOKEN -- importConfDir /snyk/import/
By default, this command populates the json import files with all types of unmonitored repos found when scanning the SCM.
importFileRepoType- This flag can be set with the values of
public(case insensitive) to fill the import file with only data from the given repo type, for example:
snyk-scm-contributors-count <command> --token TOKEN -- importConfDir /snyk/import/ --importFileRepoType 'private'
The import file requires an OrgID and IntegrationID from the user in order to import them to the right organization and integration at Snyk.
The tool will try to find these two values from Snyk (provided that a SNYK_TOKEN was exported and that the org mapping at Snyk is mirrored to that of the SCM) and if the tool can not find those values, the user will be prompted to supply them in the command line.
Once the user has stated the values for OrgID and IntegrationID once, these values will be set for ALL the entries in the import file (meaning that all the imported repos will be under the same org in Snyk).
The snyk-api-import tool helps users import new repos in their Snyk account in a secure and robust way.
This tool requires a json file with the repos data to be imported. This file can be auto-generated by the snyk-contributors-count tool as described in the preceding sections.
For more information about the snyk-api-import tool see: