Results

Scan a git repository, periodically

Updated:2023-07-03

Here is an examples on how to run the MAIA git scanning as a periodic standalone job, making sure that the MAIA web app is synchronized with the Git repositories.

Periodic scanning may run parallel with other MAIA git scanning activities, e.g., scanning in a build pipeline for the same repositories.

Summary

  • a periodically started cyclic job running in the background, continuously providing the MAIA web app with commit information, contributing to the overall traceability.
  • the command creates a git clone before scanning. If the clone exists, it will be updated before scanning.
  • git scan core command repo options repo-name or repo-file should be used.
  • git scan Activities options may be used.

Prepare

On a host where scanning is to be done:

  1. Initialize the periodic scanning by removing an eventual existing clone before scanning the first time.

    rm -rf <repository_name>
  2. MAIA web app can be reached via HTTP + Kafka is setup and can be reached.

  3. An API user exists in the MAIA web app, having the permissions:

    • Create commits
  4. The user has created an API token (referred to from the environment file).

  5. MAIA Agent is installed.

  6. The environment variable BUNDLE_GEMFILE points to the MAIA Agent Gemfile.

  7. The environment variable BLT_ENV points to the environment.yml file.

Example

  1. Start a MAIA Agent scanner that runs a scan every 5 minutes, for 4 hours.
:
:
bundle exec maia git_scan --repo-name <repository_name> --cyclic 300:14400
:
:

Note that calling this command creates the file:

  • GIT_SCAN_TRACKED_FILE, usually called 'tracked_commits'.
  1. Restart the scanner after 4 hours.