Gitlab - Examples
The list of options and some examples
Available options:
1
--version Show version number [boolean]
2
--help Show help [boolean]
3
--token Gitlab token [required]
4
--url [Optional] Your Gitlab host custom URL. If no host was provided
5
it will default to https://gitlab.com/
6
--groups [Optional] Your Gitlab groups names to count contributors for
7
*note* for sub-level groups, please provide the lowest level group name
8
--project [Optional] Your Gitlab project path with namespaces to count contributors for
9
--exclusionFilePath [Optional] Exclusion list filepath
10
--json [Optional] JSON output, requiered when using the "consolidateResults" command
11
--skipSnykMonitoredRepos [Optional] Skip Snyk monitored projects and count contributors for all projects
12
--importConfDir [Optional] Generate an import file with the unmonitored projects: A path to a valid folder for the generated import files
13
--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 projects 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 acces, 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 Gitlab token or create a new one with this guide:
    **Note: **make sure your token has read access to the repos.

Running the command

Consider the following levels of usage and options:

Usage levels:

  • To get commits for all groups and their projects in Gitlab: provide the Gitlab token (and server url for Gitlab Enterprise):
    1
    snyk-scm-contributors-count gitlab --token TOKEN --url URL
    Copied!
  • To get commits for some groups and their projects in Gitlab: provide the Gitlab token and the group names, separated by a comma:
    1
    snyk-scm-contributors-count gitlab --token TOKEN --groups GROUP1,GROUP2
    Copied!
Please mind that for nested groups, you need to provide the lowest level group name, for example: for TopLevelGroup/MidLevelGroup/LowLevelGroup only provide "LowLevelGroup" with the --groups flag
  • To get commits for a specific project in Gitlab: provide the Gitlab token and one group name and one project name:
    1
    snyk-scm-contributors-count gitlab --token TOKEN --groups GROUP --project PROJECT
    Copied!

Options:

  • I want to get all the commits from Gitlab regardless of the projects that are already monitored by Snyk (You might have projects in Gitlab that are not monitored in Snyk, using this flag will skip checking for Snyk monitored projects and will go directly to Gitlab to fetch the commits) => add the --skipSnykMonitoredRepos flag to the command:
    1
    snyk-scm-contributors-count gitlab --token TOKEN --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 gitlab --token TOKEN --projectKeys ID1,ID2,Path1/Namespace1 --exclusionFilePath PATH_TO_FILE
    Copied!
  • To set the output to json format: add the --json flag:
    1
    snyk-scm-contributors-count gitlab --token TOKEN --json
    Copied!
  • To create an import file for me with my unmonitored projects: 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 projects types to add to the file (all/private/public, defaults to all). (Note that these flags can not be set with the --project flag):
    1
    snyk-scm-contributors-count gitlab --token TOKEN --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 withDEBUG=snyk*:
    1
    DEBUG=snyk* snyk-scm-contributors-count gitlab --token TOKEN --url URL --exclusionFilePath PATH_TO_FILE --json
    Copied!
Last modified 2d ago
Export as PDF
Copy link
Edit on GitHub