Azure DevOps YAML Pipeline
Prerequisites
Note: Users have Azure SSO enabled in CodeScan. If an integration user has to be set up for Jenkins/Bitbucket projects, then the user must be created in Azure SSO.
Install the CodeScan Cloud Extension
In the Azure DevOps app, go to the Marketplace and then select Browse Marketplace.
Search for CodeScan, select the CodeScan Cloud extension and then click Get it free.
Select your account and complete the installation.
Create a Service Endpoint
Open Project Settings
Under Pipelines select Service Connections
Select CodeScanCloud from the list and click Next
Add your CodeScan server URL (e.g., https://app.codescan.io/)
You will need a token from your CodeScan Cloud account for this step. Learn how to create security token here.
Add a name for your connection.
If you would like this connection available everywhere, click Grant access permissions to all pipelines. If you would like to restrict the use of this connection, leave this box unchecked and see this article.
Click Verify and Save
Setup
On your Project dashboard screen, select Pipeline > Pipelines and create a new Pipeline.
Once you are in the "Where is your code?" page, select the source of your code.
On the Select a Repository page, select the repository you would like to scan from.
On the Configure Your Pipeline page, select Starter Pipeline
You should see a bare bones YAML file. Remove the header comments, test step and script as you wont need those.
Add Prepare Analysis Configuration
On the right hand side of the page, click Show Assistant
Search for CodeScan
Click on Prepare Analysis Configuration.
Select your new Service Endpoint and the Organization you would like to connect to from the dropdown menu. If you are not sure, the Organization Key is available at the top left of your Organization page.
Select Use standalone scanner under the Choose a way to run the analysis.
Under Mode, select the Manually provide configuration checkbox.
Click Add
Now, in CodeScan Cloud we can set up the project.
In your selected CodeScan Cloud organization, navigate to Administration > Projects Management.
Click Create Project.
Enter your desired Project Name and Project Key and click Create. Keep these in mind, we'll need them in a second.
Click on your new empty project and navigate to Administration > Branches and Pull Requests.
Change your main branch name to the name of the default branch that you selected.
Now, back to Azure DevOps.
Enter the Project Name and Project Key you just created.
Click on Advanced. Remove the contents and add sonar.qualitygate.wait=true . This will fail the analysis if the Quality Gate fails.
Click Add
Add Run Code Analysis
On the right hand side of the page, click Show Assistant
Search for CodeScan
Click on Run Analysis
Click Add
Add Publish Quality Gate Result
On the right hand side of the page, click Show Assistant
Search for CodeScan
Click on Publish Quality Gate Result
Click Add
Your script should now look similar to the image below.

Triggering Builds from a Repository
The triggers in Azure DevOps can be configured for pushes to your branches or pull requests made against them.
Please see this article for information on triggers in YAML.
Last updated
Was this helpful?

