Integrating with CI (Basic)

The AppMap Analysis CLI provides a ci subcommand as an all-in-one solution for running a scan on the CI server.

This guide describes how to use the ci command in a basic, non-parallelized build job.

The steps performed are:

  1. Run the test cases to generate AppMaps.
  2. Run the ci command to:
    1. Scan the AppMaps.
    2. Upload scan results to your AppMap account (optional, enabled by default).
    3. Update GitHub commit status with findings info (optional, disabled by default).
    4. Exit with status 1 if there are any new (non-deferred) findings. Otherwise, exit status 0 (optional, disabled by default).

Run the test cases to generate AppMaps

Modify your build step that runs test cases to generate AppMaps. The specifics of this depend on your language and framework. See the recording test cases reference for details.

Run the scanner ci command

We recommend using npx to run AppMap Analysis in CI.

Basic usage:

$ npx @appland/scanner ci -c appmap-analysis-config.yml -d tmp/appmap
..!.......!..........!..........!..........!..........!....................!!...
....!..........!..........!..........!.....................!..........!.........
...
Creating mapset in app mycorp/myapp-server with 2 AppMaps
Uploading findings
Uploaded 2 findings to https://app.land/scanner_jobs/121    

Uploading scan results

By default, the ci command will upload scan results to your AppMap account.

To configure AppMap Analysis to upload scan results, you’ll need an AppMap API key. You can generate a new API key via your account settings page. The API key should be securely added to the CI job configuration, as the environment variable APPLAND_API_KEY.

This feature is enabled by default. To disable it, use the --no-upload command flag.

Updating GitHub commit status

When using AppMap Analysis in CI you can post findings summary as a commit status and/or a PR comment (currently only GitHub is supported). In order to allow access to your repo you need to create a personal token with following privileges and add it as a GH_TOKEN env variable to your CI:

  • repo for posting PR comments
  • repo:status for posting commit statuses

This feature is disabled by default. To enable it, use the --update-commit-status command flag.

Failing the build job

Pass the --fail flag to fail the build job if there are any new findings.


Was this page helpful? thumb_up Yes thumb_down No
Thank you for your feedback!