Scan a git repository, pipeline
Updated:2023-07-03
Here is an example of how to run the MAIA git scanning in an existing pipeline, as a job in conjunction with other commands e.g. in preparation for the maia build command.
Summary
- suitable when integrating MAIA Agent into an existing build pipeline.
- the command must be executed from the directory of an already cloned repository.
- execute maia git_scan prior to the maia build command.
- no git scan core command repo options should be used.
- git scan Activities options may be used.
Prepare
On a host where scanning is to be done:
- A git repository exists (cloned). The component name in MAIA is assumed to be equal to the repository name. A component will be created in MAIA if it doesn't exist.
- MAIA web app can be reached via HTTP + Kafka is setup and can be reached.
- An API user exists in the MAIA web app, having the permissions:
- The user has created an API token (referred to from the environment file).
- MAIA Agent is installed.
- The environment variable BUNDLE_GEMFILE points to the MAIA Agent Gemfile.
- The environment variable BLT_ENV points to the environment.yml file (the parameter SRC_ROOT is not used here).
Example 1
- You have an existing build pipeline which has already cloned the repo to be scanned.
- Your existing build pipeline is now calling the MAIA Agent git_scan command to transfer information to MAIA web app contributing to the full traceability (with no activities created here).
:
:
bundle exec maia git_scan
:
:
Note that calling this command creates the file:
- GIT_SCAN_TRACKED_FILE, usually called 'tracked_commits'.
Example 2
- You have an existing build pipeline which has already cloned the repo to be scanned.
- Your existing build pipeline is now calling the MAIA Agent git_scan command to transfer information to MAIA web app contributing to the full traceability, here creating an activity in MAIA.
:
echo "Activity label: $label"
uuid=$(cat /proc/sys/kernel/random/uuid)
bundle exec maia git_scan --activity-uuid $uuid $label
:
:
Note that calling this command creates the file:
- GIT_SCAN_TRACKED_FILE, usually called 'tracked_commits'.