Azure - Examples
The list of options and some examples
Available options:
1
--version Show version number [boolean]
2
--help Show help [boolean]
3
--token Azure Devops token [required]
4
--org Your Org name in Azure Devops e.g. https://dev.azure.com/{OrgName} [required]
5
--projectKeys [Optional] Azure Devops project key/name to count
6
contributors for
7
--repo [Optional] Specific repo to count only for
8
--exclusionFilePath [Optional] Exclusion list filepath
9
--json [Optional] JSON output, required when using the "consolidateResults" command
10
--skipSnykMonitoredRepos [Optional] Skip Snyk monitored repos and count contributors for all repos
11
--importConfDir [Optional] Generate an import file with the unmonitored repos: A path to a valid folder for the generated import files
12
--importFileRepoType [Optional] To be used with the importConfDir flag: Specify the type of repos to be added to the import file. Options: all/private/public. Default: all
Copied!

Before running the command:

  1. 1.
    Export SNYK_TOKEN (if you want to get the contributors only for repos that are already monitored by Snyk):
    • Make sure that your token has Group level access or use a service account's token that has Group level access, to learn more on how to create a service account, please refer to this guide
    • Copy the token value
    • Export the token in your environment:
      1
      export SNYK_TOKEN=<YOUR-SNYK-TOKEN>
      Copied!
  2. 2.
    Get your Azure-Devops Token and Org:
    • Create a Token if one does not exist, using this guide
      Note: make sure your token has read access to the repos.
    • Your Org name in Azure is listed on the left pane in Azure-Devops-site

Running the command

Consider the following levels of usage and options:

Usage levels:

  • I want to get commits for all projects and their repos under my Org in Azure => Only provide the Azure token and Azure Org:
    1
    snyk-scm-contributors-count azure-devops --token AZURE-TOKEN --org AZURE-ORG
    Copied!
  • I want to get commits for some projects and their repos under my Org in Azure => Provide the Azure token, Azure Org and the project key/s separated by a comma:
    1
    snyk-scm-contributors-count azure-devops --token AZURE-TOKEN --org AZURE-ORG --projectKeys Key1,Key2...
    Copied!
  • I want to get commits for a specific repo under my Org in Azure => Provide your Azure token, Azure Org, a project key and a repo name:
    1
    snyk-scm-contributors-count azure-devops --token AZURE-TOKEN --org AZURE-ORG --projectKeys Key1 --repo Repo1
    Copied!

Options:

  • To get all the commits from Azure regardless of the repos that are already monitored by Snyk: add the --skipSnykMonitoredRepos flag.
    (You might have repos in Azure that are not monitored in Snyk, using this flag will skip checking for Snyk monitored repos and will go directly to Azure to fetch the commits)
    1
    snyk-scm-contributors-count azure-devops --token AZURE-TOKEN --org AZURE-ORG --skipSnykMonitoredRepos
    Copied!
  • To exclude some contributors from being counted in the commits: add an exclusion file with the emails to ignore (separated by commas) and apply the --exclusionFilePath with the path to that file:
    1
    snyk-scm-contributors-count azure-devops --token AZURE-TOKEN --org AZURE-ORG --projectKeys Key1,Key2 --exclusionFilePath PATH_TO_FILE
    Copied!
  • To set the output to json format: add the --json flag:
    1
    snyk-scm-contributors-count azure-devops --token AZURE-TOKEN --org AZURE-ORG --projectKeys Key1 --repo Repo1 --json
    Copied!
  • To create an import file for me with my unmonitored repos: add the --importConfDir flag with a valid (writable) path to a folder in which the import files will be stored and add the --importFileRepoType flag (optional) with the repo types to add to the file (all/private/public, defaults to all). (Note that these flags can not be set with the --repo flag):
    1
    snyk-scm-contributors-count azure-devops --token AZURE-TOKEN --org AZURE-ORG --importConfDir ValidPathToWritableFolder --importFileRepoType private/public/all
    Copied!
    For more details about these flag, refer to this page
  • To run in debug mode for verbose output: prefix the command withDEBUG=snyk*:
    1
    DEBUG=snyk* snyk-scm-contributors-count azure-devops --token AZURE-TOKEN --org AZURE-ORG --projectKeys Key1 --repo Repo1 --exclusionFilePath PATH_TO_FILE --skipSnykMonitoredRepos --json
    Copied!
Last modified 2d ago
Export as PDF
Copy link
Edit on GitHub