{"id":2316,"date":"2021-11-20T13:40:58","date_gmt":"2021-11-20T13:40:58","guid":{"rendered":"https:\/\/sdf-docs.mansystems.com\/docs\/acr\/how-to-use-acr\/automatically-scan-each-commit\/"},"modified":"2021-11-23T09:11:16","modified_gmt":"2021-11-23T09:11:16","slug":"automatically-scan-each-commit","status":"publish","type":"docs","link":"https:\/\/sdf-docs.clevr.com\/?docs=acr\/how-to-use-acr\/automatically-scan-each-commit","title":{"rendered":"Automatically scanning commits"},"content":{"rendered":"\n<p><em>Please note that this option is only available through our CI\/CD,<\/em> <em>currently in preview. <\/em><\/p>\n\n\n\n<p>Code review is an essential part of software development. We recommend, even implore you, to never put code in production that hasn&#8217;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? <\/p>\n\n\n\n<p>We are a developer-first product. Hence we firmly believe tools like ACR must be flexible enough to accommodate the developers&#8217; 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. <\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Scanning each commit on the branch. Especially, helpful if you want to tackle the results straight away.<\/li><li>Scanning the branch on a given time each day. If you prefer to fine tune your code on specific moments.<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">General<\/h2>\n\n\n\n<p>Before you can automate anything in ACR, you need to set up the following:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Connect your ACR app with CI\/CD.<\/li><li>Your Mendix Cloud account.<\/li><\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Connect your ACR app to CI\/CD<\/h3>\n\n\n\n<ol class=\"wp-block-list\"><li>Navigate to your application in ACR. <\/li><li>Open the <em>App Settings, <\/em>and click on the <em>API keys tab<\/em>.<\/li><li>Click <em>new<\/em> to generate a new API key and give it a suitable name such as <em>Automatic scan<\/em>. Now copy the API key and click <em>Save<\/em>. <\/li><\/ol>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"497\" src=\"https:\/\/sdf-docs.clevr.com\/wp-content\/uploads\/2021\/11\/image-5-1024x497.png\" alt=\"\" class=\"wp-image-2321\" srcset=\"https:\/\/sdf-docs.clevr.com\/wp-content\/uploads\/2021\/11\/image-5-980x475.png 980w, https:\/\/sdf-docs.clevr.com\/wp-content\/uploads\/2021\/11\/image-5-480x233.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) and (max-width: 980px) 980px, (min-width: 981px) 1024px, 100vw\" \/><\/figure>\n\n\n\n<ol class=\"wp-block-list\"><li>Now navigate to <em>CI\/CD<\/em> via the topbar. <\/li><li>Click <em>App settings<\/em>. Here we connect ACR to CI\/CD.<\/li><li>Click <em>New<\/em>, to create a new API account to use in a pipelin. <\/li><li>Give your API account a fitting name so you know where it is used. <\/li><li>Select <em>ACR.<\/em><\/li><li>Select an API host, in this case <em>ACR Production. <\/em><\/li><li>Pase your API key here and click <em>Save<\/em>. <\/li><\/ol>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"517\" src=\"https:\/\/sdf-docs.clevr.com\/wp-content\/uploads\/2021\/11\/image-21-1024x517.png\" alt=\"\" class=\"wp-image-2352\" srcset=\"https:\/\/sdf-docs.clevr.com\/wp-content\/uploads\/2021\/11\/image-21-980x495.png 980w, https:\/\/sdf-docs.clevr.com\/wp-content\/uploads\/2021\/11\/image-21-480x242.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) and (max-width: 980px) 980px, (min-width: 981px) 1024px, 100vw\" \/><\/figure>\n\n\n\n<p>You use this API account in your pipeline in the following steps.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Set up your Mendix Cloud Account<\/h3>\n\n\n\n<p>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.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/sdf-docs.clevr.com\/wp-content\/uploads\/2021\/11\/image-3-1024x517.png\" alt=\"\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Setting up an automated review<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Setting up the review<\/h3>\n\n\n\n<p>Setting up the pipeline is the same whether you want to review each commit or only scan at given times. <\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Navigate to your application in CI\/CD. <\/li><li>Select create <em>New Pipeline<\/em>. <\/li><\/ol>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"497\" src=\"https:\/\/sdf-docs.clevr.com\/wp-content\/uploads\/2021\/11\/image-8-1024x497.png\" alt=\"\" class=\"wp-image-2324\" srcset=\"https:\/\/sdf-docs.clevr.com\/wp-content\/uploads\/2021\/11\/image-8-980x475.png 980w, https:\/\/sdf-docs.clevr.com\/wp-content\/uploads\/2021\/11\/image-8-480x233.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) and (max-width: 980px) 980px, (min-width: 981px) 1024px, 100vw\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\"><li>Select create <em>Empty Pipeline<\/em>. <\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"497\" src=\"https:\/\/sdf-docs.clevr.com\/wp-content\/uploads\/2021\/11\/image-9-1024x497.png\" alt=\"\" class=\"wp-image-2325\" srcset=\"https:\/\/sdf-docs.clevr.com\/wp-content\/uploads\/2021\/11\/image-9-980x475.png 980w, https:\/\/sdf-docs.clevr.com\/wp-content\/uploads\/2021\/11\/image-9-480x233.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) and (max-width: 980px) 980px, (min-width: 981px) 1024px, 100vw\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\"><li>Give it a fitting name such as <em>&#8220;Automatically scan each commit on branch &#8211; XXX&#8221;<\/em>. <\/li><li>Click <em>new job<\/em> and select <em>Code Review<\/em>. <\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"497\" src=\"https:\/\/sdf-docs.clevr.com\/wp-content\/uploads\/2021\/11\/image-10-1024x497.png\" alt=\"\" class=\"wp-image-2326\" srcset=\"https:\/\/sdf-docs.clevr.com\/wp-content\/uploads\/2021\/11\/image-10-980x475.png 980w, https:\/\/sdf-docs.clevr.com\/wp-content\/uploads\/2021\/11\/image-10-480x233.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) and (max-width: 980px) 980px, (min-width: 981px) 1024px, 100vw\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\"><li>Select the branch you want to automatically review. <\/li><li>Select the API account you want to use (you created it in the previous steps). <\/li><li>Now click <em>Save.<\/em><\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"497\" src=\"https:\/\/sdf-docs.clevr.com\/wp-content\/uploads\/2021\/11\/image-22-1024x497.png\" alt=\"\" class=\"wp-image-2353\" srcset=\"https:\/\/sdf-docs.clevr.com\/wp-content\/uploads\/2021\/11\/image-22-980x475.png 980w, https:\/\/sdf-docs.clevr.com\/wp-content\/uploads\/2021\/11\/image-22-480x233.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) and (max-width: 980px) 980px, (min-width: 981px) 1024px, 100vw\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Configuring the notification<\/h3>\n\n\n\n<p>You might want to get some notification when ACR is finished reviewing. <\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Click <em>new job<\/em>. <\/li><li>Select <em>Notify<\/em>, and you can create a message that CI\/CD will email when done. See an example below.<ol><li>You can choose various recipients. <\/li><\/ol><\/li><li>Click <em>Save<\/em>.<\/li><\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">Setting the automation<\/h3>\n\n\n\n<p>Open the <em>Automation tab<\/em>. <\/p>\n\n\n\n<p><strong>Option 1: Review each commit<\/strong><\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>For automatic execution select <em>On Commit<\/em>.<\/li><li>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. <\/li><li>Now click <em>Save<\/em>.<\/li><\/ol>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"497\" src=\"https:\/\/sdf-docs.clevr.com\/wp-content\/uploads\/2021\/11\/image-23-1024x497.png\" alt=\"\" class=\"wp-image-2354\" srcset=\"https:\/\/sdf-docs.clevr.com\/wp-content\/uploads\/2021\/11\/image-23-980x475.png 980w, https:\/\/sdf-docs.clevr.com\/wp-content\/uploads\/2021\/11\/image-23-480x233.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) and (max-width: 980px) 980px, (min-width: 981px) 1024px, 100vw\" \/><\/figure>\n\n\n\n<p><strong>Option 2: Review on a given time<\/strong><\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>For automatic execution select <em>On Time<\/em>. <\/li><li>For time1 select the time you want ACR to review the branch. For example, 22:00 for every evening. It will execute every day.<\/li><li>Now click <em>Save.<\/em><\/li><\/ol>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"497\" src=\"https:\/\/sdf-docs.clevr.com\/wp-content\/uploads\/2021\/11\/image-24-1024x497.png\" alt=\"\" class=\"wp-image-2355\" srcset=\"https:\/\/sdf-docs.clevr.com\/wp-content\/uploads\/2021\/11\/image-24-980x475.png 980w, https:\/\/sdf-docs.clevr.com\/wp-content\/uploads\/2021\/11\/image-24-480x233.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) and (max-width: 980px) 980px, (min-width: 981px) 1024px, 100vw\" \/><\/figure>\n\n\n\n<p>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\ud83d\ude09). <\/p>\n\n\n\n<p><\/p>\n","protected":false},"featured_media":0,"parent":418,"menu_order":3,"comment_status":"open","ping_status":"closed","template":"","doc_tag":[],"class_list":["post-2316","docs","type-docs","status-publish","hentry"],"comment_count":0,"_links":{"self":[{"href":"https:\/\/sdf-docs.clevr.com\/index.php?rest_route=\/wp\/v2\/docs\/2316"}],"collection":[{"href":"https:\/\/sdf-docs.clevr.com\/index.php?rest_route=\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/sdf-docs.clevr.com\/index.php?rest_route=\/wp\/v2\/types\/docs"}],"replies":[{"embeddable":true,"href":"https:\/\/sdf-docs.clevr.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2316"}],"version-history":[{"count":3,"href":"https:\/\/sdf-docs.clevr.com\/index.php?rest_route=\/wp\/v2\/docs\/2316\/revisions"}],"predecessor-version":[{"id":2356,"href":"https:\/\/sdf-docs.clevr.com\/index.php?rest_route=\/wp\/v2\/docs\/2316\/revisions\/2356"}],"up":[{"embeddable":true,"href":"https:\/\/sdf-docs.clevr.com\/index.php?rest_route=\/wp\/v2\/docs\/418"}],"next":[{"title":"Creating a single rule template to use in multiple apps","link":"https:\/\/sdf-docs.clevr.com\/?docs=acr\/how-to-use-acr\/creating-a-single-rule-template-to-use-in-multiple-apps","href":"https:\/\/sdf-docs.clevr.com\/index.php?rest_route=\/wp\/v2\/docs\/2359"}],"prev":[{"title":"Compare revisions","link":"https:\/\/sdf-docs.clevr.com\/?docs=acr\/how-to-use-acr\/compare-revisions","href":"https:\/\/sdf-docs.clevr.com\/index.php?rest_route=\/wp\/v2\/docs\/437"}],"wp:attachment":[{"href":"https:\/\/sdf-docs.clevr.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2316"}],"wp:term":[{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/sdf-docs.clevr.com\/index.php?rest_route=%2Fwp%2Fv2%2Fdoc_tag&post=2316"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}