Github Enterprise - Examples
The list of options and some examples
Available options:
1
--version Show version number [boolean]
2
--help Show help [boolean]
3
--token Github Enterprise token [required]
4
--url Your Github host custom URL.
5
e.g https://ghe.prod.company.org/ [required]
6
--orgs [Optional] A list of Github Enterprise organizations, separeted by comma,
7
to fetch and count contributors for their repositories
8
--repo [Optional] Specific repo to count only for
9
--fetchAllOrgs [Optional] When enabled, will fetch all orgs that the token has access to
10
rather than fetching only the orgs your authorized to operate in.
11
--exclusionFilePath [Optional] Exclusion list filepath
12
--json [Optional] JSON output, requiered when using the "consolidateResults" command
13
--skipSnykMonitoredRepos [Optional] Skip Snyk monitored repos and count contributors for all repos
14
--importConfDir [Optional] Generate an import file with the unmonitored repos: A path to a valid folder for the generated import files
15
--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 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 Github Enterprise 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 repos in all my orgs in Github Enterprise: provide the Github Enterprise token:
    1
    snyk-scm-contributors-count github-enterprise --token TOKEN --url HOST_URL
    Copied!
  • To get commits for some orgs and their repos in Github Enterprise: provide the Github Enterprise token and the org names, separated by a comma:
    1
    snyk-scm-contributors-count github-enterprise --token TOKEN --url HOST_URL --orgs ORG_ONE,ORG_TWO,ORG_THREE
    Copied!
  • To get commits for only one repo in Github Enterprise: provide the Github Enterprise token, one org name and one repo name:
    1
    snyk-scm-contributors-count github-enterprise --token TOKEN --url HOST_URL --orgs ORG --repo REPO
    Copied!

Options:

  • To get all the commits from Github Enterprise regardless of the repos that are already monitored by Snyk (You might have repos in Github Enterprise that are not monitored in Snyk, using this flag will skip checking for Snyk monitored repos and will go directly to Github Enterprise to fetch the commits): add the --skipSnykMonitoredRepos flag:
    1
    snyk-scm-contributors-count github-enterprise --token TOKEN --url HOST_URL --skipSnykMonitoredRepos
    Copied!
  • To map all the orgs in Github Enterprise and not only the ones I have operate rights to => add the --fetchAllOrgs flag:
    1
    snyk-scm-contributors-count github-enterprise --token TOKEN --url HOST_URL --fetchAllOrgs
    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 github-enterprise --token TOKEN --url HOST_URL --orgs ORG_ONE,ORG_TWO --exclusionFilePath PATH_TO_FILE
    Copied!
  • To set the output to json format: add the --json flag:
    1
    snyk-scm-contributors-count github-enterprise --token TOKEN --url HOST_URL --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 github-enterprise --token TOKEN --url HOST_URL --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 with DEBUG=snyk* :
    1
    DEBUG=snyk* snyk-scm-contributors-count github-enterprise --token TOKEN --url HOST_URL --orgs ORG --repo REPO --exclusionFilePath PATH_TO_FILE --json
    Copied!
Last modified 2d ago
Export as PDF
Copy link
Edit on GitHub