Skip to main content
Pull request reviews through the GitHub, GitLab, or Bitbucket integration do not need a CI job. Add a CLI job only when you want scans that your pipeline controls.

How vidoc ci works

vidoc ci runs without questions. It does these steps:
  1. It uploads the new and changed files of the current folder to Vidoc, as vidoc scan does.
  2. It finds the default branch from the origin remote. If the CLI cannot read the remote, it uses origin/main, or origin/master if only that branch exists.
  3. It finds the files that the commits of the current branch changed, compared with the default branch (from the merge base). Uncommitted changes are not included.
  4. It scans only these files and waits until the scan is complete.
  5. It prints the validated issues that Vidoc has for the branch, and a summary by severity.
On the default branch, there are no changes to compare. vidoc ci prints “No scannable files matched the selected scope in the current directory.” and ends without a scan. The list in step 5 contains all validated issues of the branch, not only the issues in the changed files. The CLI does not filter the list by status.

Requirements for the CI job

  • Full Git history. vidoc ci needs the default branch and the merge base. Use a full clone (for example fetch-depth: 0 on GitHub Actions).
  • A branch name. Many CI systems check out a detached HEAD. Without a branch name, Vidoc uses the commit SHA as the branch name. Run git checkout -B "<branch name>" before vidoc ci.
  • Network access. The runner must reach the Vidoc API. On a self-hosted installation, runners that your CI provider hosts (for example GitHub-hosted runners or Bitbucket Pipelines) run outside your network.
  • Credentials. Keep the API key in the secret store of your CI system as VIDOC_TOKEN. For a self-hosted installation, also set VIDOC_API_URL to https://api.<your-domain>. On Vidoc Cloud, VIDOC_API_URL is optional. The default is https://api.vidoc.dev.
For all environment variables, refer to Configuration.

Options

vidoc ci accepts the same options as vidoc scan: -f, --only-indexing, -p, --api-url, --token, -c, and --debug. Refer to Scanning options. In CI, use environment variables for the key, not --token, so that the key does not show in the job log.

Exit codes

vidoc ci does not fail the job when it finds issues. To fail the job, refer to Fail a pipeline on issues.

Examples

The pipeline files below are examples. Change them for your pipelines and test them before you use them.
  1. Go to Settings > Secrets and variables > Actions in the repository.
  2. Add VIDOC_TOKEN as a repository secret.
  3. Self-hosted only: add VIDOC_API_URL as a repository variable.
  4. Add a workflow, for example .github/workflows/vidoc.yml:
On pull_request events, GitHub Actions checks out a detached HEAD. $GITHUB_HEAD_REF is the name of the PR source branch.
On GitHub Actions, vidoc ci can print “No Github token provided. Skipping comment.” You can ignore this message. PR comments come from the GitHub integration.

Fail a pipeline on issues

vidoc ci can return exit code 0 even when a scan fails. To enforce a rule, replace the vidoc ci step with the script below. Run the script with Bash after the checkout and CLI installation steps. Before you run it:
  • Set VIDOC_TOKEN, VIDOC_API_URL, and VIDOC_CODEBASE_ID in CI. Set the API URL explicitly for both Cloud and self-hosted jobs. Refer to API addresses.
  • Get the repository ID with GET /v1/codebase.
  • Check out the intended commit on a named branch, as in the pipeline examples above. Use a clean checkout and install curl and jq.
  • Run only one scan at a time for this repository and branch while the gate runs. Issue results are the current branch state, not an immutable snapshot of a scan.
The script captures the ID printed by this CLI run and checks that exact scan. It fails if no scan starts, if the scan is not complete, if an API request or response is invalid, or if the API reports open critical or high findings on the branch. It includes known open findings in unchanged files and respects the issue visibility policy described in List issues.
This example reads the Scan started with ID: message from CLI 0.1.21. Pin the CLI version for a required CI check, and verify this message when you upgrade. A run with no scannable changes returns no scan ID, so this gate fails. Define an explicit skip rule in your CI if your team permits that case. Manual and CLI scans can have no commit SHA in the API. The scan ID ties the completion check to this invocation; it does not certify a commit snapshot. To change the finding rule, change severity and status. Refer to List issues.

Configuration

Environment variables and precedence.

Issues API

Read and filter issues.