You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 21, 2026. It is now read-only.
Copy file name to clipboardExpand all lines: Instructions/Labs/AZ400_M10_Managing_technical_debt_with_SonarQube_and_Azure_DevOps.md
+21-59Lines changed: 21 additions & 59 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -113,26 +113,25 @@ In this task, you will install and configure the SonarCloud Azure DevOps extensi
113
113
114
114
> **Note**: In SonarCloud, you will create an organization and, within it, a new project. The organization and project you set up in SonarCloud will mirror the organization and project that you set up in Azure DevOps.
115
115
116
-
1.On the **Welcome to SonarCloud** page, click**Import an organization from Azure**.
116
+
1.Click**Import an organization from Azure**.
117
117
1. On the **Create an organization** page, in the **Azure DevOps organization name** textbox, type the name of your Azure DevOps organization, in the **Personal Access Token** textbox, paste the value of the token you recorded in the previous exercise, and click **Continue**.
118
118
1. In the **Import organization details** section, in the **Key** textbox, type a string of characters that will designate your organization and click **Continue**.
119
119
120
120
> **Note**: The key must be unique within the SonarCloud system. Make sure that the green checkmark appears to the right of the **Key** textbox. This indicates that the key satisfies the uniqueness prerequisite.
121
121
122
-
1. In the **Choose a plan** section, select the plan that you intend to use for this lab and click **Create Organization**.
122
+
1. In the **Choose a plan** section, select the plan that you intend to use for this lab (**free** suggested) and click **Create Organization**.
123
123
124
124
> **Note**: You have now created the SonarCloud organization that mirrors your Azure DevOps organization.
125
125
126
126
> **Note**: Next, within the newly created organization, you will create a SonarCloud project that will mirror the Azure DevOps project **SonarExamples**.
127
127
128
-
1. On the **All set! Your organization is now ready to go** page, click **Analyze new project**.
129
128
1. On the **Analyze projects - Select repositories** page, in the list of Azure DevOps projects, select the checkbox next to the **SonarExamples / SonarExamples** entry and click **Set up**.
130
-
1. On the **Analyze your project** page, click **With Azure DevOps Pipeline** tile.
129
+
1. On the **Choose your Analysis Method** page, click **With Azure DevOps Pipeline** tile.
131
130
1. On the **Analyze with Azure Pipelines** page, in the **Install our extension** section, click **Continue**.
132
131
133
132
> **Note**: You can skip extension creation if you have already installed it.
134
-
135
-
1. On the **Analyze with Azure Pipelines** page, in the **Configure Azure Pipelines** section, click **.NET**. This will display a sequence of steps required to **Prepare Analysis Configuration**, **Run Code Analysis**, and **Publish Quality Gate Result**.
133
+
1. On the **Add a new Sonarcloud Service Endpoint**, follow the steps mentioned on your Azure DevOps project, give the name **SonarSC** to the service connection, **check** the box for granting access to all pipelines and click **Verify and save**. Back on Sonarcloud website, clik on **continue**.
134
+
1. On the **Analyze with Azure Pipelines** page, in the **Configure Azure Pipelines** section, click **.NET**. This will display a sequence of steps required to **Prepare Analysis Configuration**, **Run Code Analysis**, and **Publish Quality Gate Result**. You will need this instructions for the pipeline definition.
136
135
137
136
> **Note**: Review the listing of steps to accomplish each of these objectives. You will implement them in the subsequent tasks.
138
137
@@ -149,25 +148,17 @@ In this exercise, you will set up an Azure DevOps pipeline that integrates with
149
148
150
149
In this task, you will begin creating the build pipeline for our project.
151
150
152
-
1. Switch to the web browser window displaying the **SonarExamples** pane in the Azure DevOps portal, in the vertical menu bar at the far left of the Azure DevOps portal, click **Pipelines** and then click **Create Pipeline**.
153
-
1. On the **Where is your code?** pane, review the available options.
154
-
155
-
> **Note**: You have two options. You can configure the pipeline with either the **YAML editor** or with the **classic editor**. With the classic editor, you can take advantage of the pre-defined templates that were installed as part of the SonarCloud Extension, above. With the YAML editor you need to use a separately provided YAML file. We will step through each of these two options.
151
+
1. Switch to the web browser window displaying the **SonarExamples** pane in the Azure DevOps portal. Go to **Project settings** and change **Visibility** to private and **Save**.
156
152
157
-
> **Note**: Skip the next task if you intend to use the classic editor.
153
+
> **Note**: We need to change because we have pipelines enabled only for private projects.
158
154
159
155
#### Task 2: Create a pipeline by using the YAML editor
160
156
161
157
In this task, you will create a pipeline by using the YAML editor.
162
158
163
159
> **Note**: Before you continue with configuration of the YAML pipeline, you will first create a service connection for SonarCloud.
164
160
165
-
1. Open another browser tab, navigate to the home page of the **SonarExamples** in the Azure DevOps portal.
166
-
1. In the web browser window displaying the **SonarExamples** pane in the Azure DevOps portal and, in the lower left corner, click **Project settings**.
167
-
1. On the **Project settings** pane, in the vertical menu bar, in the **Pipelines** section, click **Service connections** and click **Create service connection**.
168
-
1. On the **New service connection** pane, select the **SonarCloud** option and click **Next**.
169
-
1. On the **New SonarCloud service connection** pane, in the **SonarCloud Token** textbox, paste the value of the token you recorded in the previous task, in the **Service connection name** textbox, type **SC** and click **Verify and save**.
170
-
1. Switch back to the web browser tab displaying the **Where is your code?** pane. If you have closed this tab, return to the **SonarExamples** pane in the Azure DevOps portal, in the vertical menu bar at the far left of the Azure DevOps portal, click **Pipelines** and then click **Create Pipeline**.
161
+
1. In the vertical menu bar at the far left of the Azure DevOps portal, click **Pipelines** and then click **Create Pipeline**.
171
162
1. On the **Where is your code?** pane, click **Azure Repos Git**.
172
163
1. On the **Select a repository** pane, click **SonarExamples**.
173
164
1. On the **Configure your pipeline** pane, click **.NET Desktop** YAML template.
@@ -235,44 +226,15 @@ In this task, you will create a pipeline by using the YAML editor.
235
226
> **Note**: The YAML pipeline needs to be modified by following the remaining steps in this task.
236
227
237
228
1. In the **NuGetCommand@2** task, replace `restoreSolution: 'SomeConsoleApplication.sln'` with `restoreSolution: '**\SomeConsoleApplication.sln'` to account for the fact that our solution is not located in the root of the repo.
229
+
1. In the **SonarCloudPrepare@1** task, click **Settings** option to open visual helper, choose the created **sonarSC** service connection from the dropdown and replace the value of the fields as proposed on the **Sonarcloud website > Configure Azure Pipeline** section. Click **Add** to include the changes to pipeline.
238
230
1. In the **VSBuild@1** task, replace `solution: 'SomeConsoleApplication.sln'` with `solution: '**\SomeConsoleApplication.sln'` to account for the fact that our solution is not located in the root of the repo.
239
-
1. In the **SonarCloudPrepare@1** task, replace the value of the `myorga` placeholder in the `organization: 'myorga'` entry with the name of your SonarCloud organization.
240
-
1. In the **SonarCloudPrepare@1** task, replace the value of the `dotnet-framework-on-azdo` placeholder in the `projectKey: 'dotnet-framework-on-azdo'` entry with the name of your SonarCloud project key.
241
-
1. In the **SonarCloudPrepare@1** task, replace the value of the `Sample .NET Framework project with Azure DevOps` placeholder in the `projectName: 'Sample .NET Framework project with Azure DevOps'` entry with the name of your SonarCloud project name (`SonarExamples`).
242
231
1. On the **Review your pipeline YAML** pane, click **Save and Run** and, on the **Save and run** pane, click **Save and run**.
243
232
244
233
> **Note**: Skip the next task if you completed this task in YAML editor.
245
234
246
-
1. Go to Azure Pipelines > Pipelines and click in **Sonarexample** pipeline, open latest run. You will see it queued, **Cancel** the pending one, click **Yes**. Now click on **Run new** > **Run** to trigger a new run (this time pipeline will have the proper agents assigned for private projects).
247
-
248
-
#### Task 3: Create a pipeline by using the classic editor
249
-
250
-
In this task, you will create a pipeline by using the classic editor.
251
-
252
-
1. On the **Where is your code?** pane, click **Use the classic editor**.
253
-
1. On the **Select a source** pane, ensure that the **Azure Repos Git** option is selected, the **SonarExamples** entry appears in the **Repository** dropdown list, and the **master** branch appears in the **Default branch for manual and scheduled builds**, and click **Continue**.
254
-
255
-
> **Note**: The SonarCloud extension installed earlier provides SonarCloud-enabled custom build templates for Maven, Gradle, .NET Core and .NET Desktop applications. The templates are based on the standard Azure DevOps templates but with additional analysis-specific tasks and some pre-configured settings.
256
-
257
-
1. On the **Select a template** pane, scroll down to the **Others** section and click the **.NET Desktop with SonarCloud** template entry and click **Apply**.
235
+
1. Go to Azure Pipelines > Pipelines and click in **Sonarexample** pipeline, wait for the pipeline to finish.
258
236
259
-
> **Note**: The template contains all of the necessary tasks and most of the required settings. You will need to provide the remaining ones.
260
-
261
-
1. On the **Tasks** tab of the build pipeline definition, ensure that the **Pipeline** entry is selected, on the right side, in the **Agent pool** dropdown list, select the **Azure Pipelines** entry and, in the **Agent Specification** dropdown list, select the **vs2017-win2016** entry.
262
-
1. In the list of pipeline tasks, select the **Prepare analysis on SonarCloud** task and click **+New**.
263
-
1. On the **New service connection** pane, in the **SonarCloud Token** textbox, paste the value of the token you recorded earlier in this lab, click **Verify** to validate it, in the **Service connection name** textbox, type **SC** and click **Verify and save**.
264
-
1. Back on the **Prepare Analysis Configuration** pane, in the **Organization** dropdown list, select the name of your SonarCloud organization.
265
-
1. On the **Prepare Analysis Configuration** pane, in the **Project Key** text box, type the name of the project key you recorded earlier in this lab.
266
-
1. On the **Prepare Analysis Configuration** pane, in the **Project Name** text box, type the name of the project name you recorded earlier in this lab (`SonarExamples`).
267
-
1. Optionally, you can disable the Publish Quality Gate Result, in the list of pipeline tasks, select the **Publish Quality Gate Result** task, on the **Publish Quality Gate Result** pane, expand the **Control Options** section and clear the **Enabled** checkbox.
268
-
269
-
> **Note**: This task is not required unless you want to use the pre-deployment gate along with Release Pipelines.
270
-
271
-
> **Note**: If this step is enabled, a summary of the analysis results will appear on the **Extensions** tab of the **Build Summary** page. However, this will delay the completion of the build until the processing on SonarCloud has finished.
272
-
273
-
1. On the build pipeline editor pane, click **Save & queue**, in the dropdown menu, click **Save & queue**, and, on the **Run pipeline** pane, click **Save and run**, and wait for the build to complete.
274
-
275
-
#### Task 4: Check pipeline results
237
+
#### Task 3: Check pipeline results
276
238
277
239
In this task, you will check pipeline results.
278
240
@@ -288,12 +250,12 @@ In this task, you will check pipeline results.
288
250
289
251
> **Note**: To be able to see the Quality gate result, after running he first report we need to set **New Code Definition**. This way, subsequent pipeline runs will include Quality Gate results.
290
252
291
-
1. On the **Overview** tab of the SonarCloud project, click **Set New Code definition**.
292
-
1. On the **Administration** tab of the SonarCloud project, click **Previous version**.
293
-
1. Switch to the web browser window displaying the **SonarExamples** project pane in the Azure DevOps portal with the most recent build run, click **Run new** and, on the **Run pipeline** pane, click **Run**.
253
+
1. On the **Overview** tab of the SonarCloud project (Sonarcloud website), click on **Administration** icon (left column) and **New Code**.
254
+
1. On the **New code** tab of the SonarCloud project, click **Previous version**.
255
+
1. Switch to the web browser window displaying the **SonarExamples** project pane in the **Azure DevOps portal** with the most recent build run, click **Run new** and, on the **Run pipeline** pane, click **Run**.
294
256
1. On the build run pane, review the content of the **Summary** tab and then click the **Extensions** tab header.
295
257
1. On the **Extensions** tab, click the **Detailed SonarCloud report**. This will automatically open a new browser tab displaying the report on your SonarCloud project page.
296
-
1. Verify that the report now includes the Quality Gate result.
258
+
1. Verify that the report and Azure DevOps **extension** tab now **includes the Quality Gate result**.
297
259
298
260
> **Note**: We have now created a new organization on SonarCloud and configured an Azure DevOps build to perform analysis and push the results of the build to SonarCloud.
299
261
@@ -305,9 +267,9 @@ In this exercise, you will analyze SonarCloud reports.
305
267
306
268
In this task, you will analyze SonarCloud reports.
307
269
308
-
1. On the **Overview** tab of the SonarCloud project, in the **Reliability Measures** section, note that there is a single bug entry.
270
+
1. On the **Overview** tab of the SonarCloud project, we see a summary for the report about the **main** branch. If you click **Main branch** icon (left column), and choose **Overall Code**, you will see a more detailed report.
309
271
310
-
> **Note**: The page has other metrics such as **Code Smells**, **Coverage**, **Duplications**, and **Size** (lines of code). The following table briefly explains each of these terms.
272
+
> **Note**: The page has metrics such as **Code Smells**, **Coverage**, **Duplications**, and **Size** (lines of code). The following table briefly explains each of these terms.
311
273
312
274
| Terms | Description |
313
275
| --- | --- |
@@ -343,7 +305,7 @@ In this exercise, you will set up pull request integration between Azure DevOps
343
305
In this task, you will review the personal access token requirements for implementing Azure DevOps pull request integration with a SonarCloud project.
344
306
345
307
1. Switch to the web browser window displaying the **SonarExamples** project in the Azure DevOps portal.
346
-
1. Repeat the steps described earlier in this lab in order to generate a personal access token with the **Code** scope and **Read & write** permissions to the **SonarExamples** project.
308
+
1. **Reuse** Azure DevOps personal access token you generated earlier in this lab or repeat the steps described earlier in this lab in order to generate a personal access token with the **Code** scope and **Read & write** permissions to the **SonarExamples** project.
347
309
348
310
> **Note**: Alternatively, you can reuse the personal access token you generated earlier in this lab.
349
311
@@ -353,8 +315,8 @@ In this task, you will review the personal access token requirements for impleme
353
315
354
316
In this task, you will configure pull request integration in SonarCloud by assigning an Azure DevOps personal access token to your SonarCloud project.
355
317
356
-
1. Switch to the web browser window displaying the **SonarExamples** project in the SonarCloud portal.
357
-
1. On the project's dashboard page, click the header of the **Administration** tab and, in the dropdown menu, click **General Settings**.
318
+
1. Switch to the web browser window displaying the **SonarExamples** project in the **SonarCloud portal**.
319
+
1. On the project's dashboard page, click the icon for the **Administration** tab and, in the dropdown menu, click **General Settings**.
358
320
1. On the **General Settings** page, click **Pull Requests**.
359
321
1. In the **General** section of the **Pull Requests** settings, in the **Provider** dropdown list, select **Azure DevOps Services** and click **Save**.
360
322
1. In the **Integration with Azure DevOps Services** section of the **Pull Requests** settings, in the **Personal access token** textbox, paste the previously generated Azure DevOps personal access token and click **Save**
@@ -363,7 +325,7 @@ In this task, you will configure pull request integration in SonarCloud by assig
363
325
364
326
In this task, you will configure an Azure DevOps branch policy for integration with SonarCloud.
365
327
366
-
1. Switch to the web browser window displaying the **SonarExamples** project in the Azure DevOps portal.
328
+
1. Switch to the web browser window displaying the **SonarExamples** project in the **Azure DevOps portal**.
367
329
1. In the vertical menu bar at the far left of the Azure DevOps portal, click **Repos** and, in the **Repos** section, click **Branches**.
368
330
1. On the **Branches** pane, in the list of branches, hover with the mouse pointer over the right edge of the **master** branch entry to reveal the vertical ellipsis character designating the **More options** menu, click it, and, in the popup menu, click **Branch policies**.
369
331
1. On the **master** pane, to the right of the **Build Validation** section, click **+**.
0 commit comments