Quickstart for code monitoring
Introduction
In this tutorial, we will create a new code monitor that monitors new appearances of the word "TODO" in your codebase.
Creating a code monitor
Prerequisite: Ensure email notifications are configured in site configuration.
- On your Sourcegraph instance, click the Code monitoring menu item at the top right of your page. Alternatively, go to https://sourcegraph.example.com/code-monitoring (where sourcegraph.example.com represents your unique Sourcegraph url).
- Click the Create new code monitor button at the top right of the page.
- Fill out the Name input with: "TODOs".
- Under the Trigger section, click When there are new search results.
- In the Search query input, enter the following search query:
TODO type:diff patternType:literal
.(Note thattype:
andpatternType:
are required as part of the search query for code monitoring.) - You can click Preview results to see all previous additions or removals of TODO to your codebase.
- Back in the code monitor form, click Continue.
- Click Send email notifications under the Actions section.
- Click Done.
- Click Create code monitor.
You should now be on https://sourcegraph.example.com/code-monitoring, and be able to see the TODO code monitor on the page.
Sending a test email notification
If you want to preview the email notification alerting you of a new result with TODO, follow these steps:
- In the Send email notifications action, click "Send test email".
- Within a few minutes, you should receive a test email from Sourcegraph with a preview of the email notification.
If you want to test receiving an email with a real new result, follow these steps:
- In any repository that's on your Sourcegraph instance (for purposes of this tutorial, we recommend a dummy or test repo that's not used), add
TODO
to any file. - Commit the change, and push it to your code host.
- Within a few minutes, you should see an email from Sourcegraph with a link to the new result you just pushed.