1. Home
  2. Docs
  3. Code Review (previously A...
  4. How to use ACR
  5. Automatically scanning commits

Automatically scanning commits

Please note that this option is only available through our CI/CD, currently in preview.

Code review is an essential part of software development. We recommend, even implore you, to never put code in production that hasn’t been reviewed, whether it is your colleague or ACR. You do not always have time to initiate reviews in ACR and wait for the results. But what about automation?

We are a developer-first product. Hence we firmly believe tools like ACR must be flexible enough to accommodate the developers’ preferences that use them. Not everybody works the same way, so in this document, we will explain two ways you can automate the reviews of various branches in your Mendix application.

  • Scanning each commit on the branch. Especially, helpful if you want to tackle the results straight away.
  • Scanning the branch on a given time each day. If you prefer to fine tune your code on specific moments.

General

Before you can automate anything in ACR, you need to set up the following:

  • Connect your ACR app with CI/CD.
  • Your Mendix Cloud account.

Connect your ACR app to CI/CD

  1. Navigate to your application in ACR.
  2. Open the App Settings, and click on the API keys tab.
  3. Click new to generate a new API key and give it a suitable name such as Automatic scan. Now copy the API key and click Save.
  1. Now navigate to CI/CD via the topbar.
  2. Click App settings. Here we connect ACR to CI/CD.
  3. Click New, to create a new API account to use in a pipelin.
  4. Give your API account a fitting name so you know where it is used.
  5. Select ACR.
  6. Select an API host, in this case ACR Production.
  7. Pase your API key here and click Save.

You use this API account in your pipeline in the following steps.

Set up your Mendix Cloud Account

To automatic scan, ACR needs access to the Mendix Team Server. This is done via the Mendix Cloud account. You must link your Mendix account in the CI/CD so that your account can be used to leverage the APIs. All you need to do is select your account from the dropdown.

Setting up an automated review

Setting up the review

Setting up the pipeline is the same whether you want to review each commit or only scan at given times.

  1. Navigate to your application in CI/CD.
  2. Select create New Pipeline.
  • Select create Empty Pipeline.
  • Give it a fitting name such as “Automatically scan each commit on branch – XXX”.
  • Click new job and select Code Review.
  • Select the branch you want to automatically review.
  • Select the API account you want to use (you created it in the previous steps).
  • Now click Save.

Configuring the notification

You might want to get some notification when ACR is finished reviewing.

  1. Click new job.
  2. Select Notify, and you can create a message that CI/CD will email when done. See an example below.
    1. You can choose various recipients.
  3. Click Save.

Setting the automation

Open the Automation tab.

Option 1: Review each commit

  1. For automatic execution select On Commit.
  2. For on commit of branch, select the branch you want to automatically review. Please note that this should be the same branch as set in the review.
  3. Now click Save.

Option 2: Review on a given time

  1. For automatic execution select On Time.
  2. For time1 select the time you want ACR to review the branch. For example, 22:00 for every evening. It will execute every day.
  3. Now click Save.

Congratulations, you now set up an automated review in ACR! Now go get yourself a cup of coffee after each commit (but take it easy on the caffeine😉).