Azure DevOps is a Microsoft-owned version control system used for managing the software development lifecycle.
Integrating Cortex with Azure DevOps allows you to:
Automatically discover and track ownership of Azure DevOps entities
Follow a GitOps workflow with Azure DevOps
View information about your Azure DevOps repositories on an entity's details page, including: The repo associated with the entity, recent commits and releases in the event timeline, the most-used language in the files for that entity, the top code contributors, and their number of contributions.
If you pull in Azure DevOps pipeline data, you can also see pipeline runs and builds in the CI/CD section of an entity's details page.
Use Azure DevOps metrics in Eng Intelligence to understand key metrics and gain insight into services, incident response, and more.
Create Scorecards that track progress and drive alignment on projects involving your repositories, Azure DevOps work items, and Azure DevOps pipeline data.
In Cortex, click your avatar in the lower left corner, then click Settings.
Under "Integrations", click Azure DevOps.
Click Add configuration.
Configure the Azure DevOps integration form:
Organization: Enter the slug for your Azure DevOps organization.
Username: Enter the username for your personal access token.
Personal access token: Enter your Azure DevOps personal access token.
Host: Optionally, if you are using a self-managed setup, enter your hostname.
Click Save.
Cortex supports mapping multiple identities for a single user if you have multiple configurations of Azure DevOps. See the Identity mapping documentation for more information.
Enable or disable Azure DevOps work items
On the Azure DevOps settings page in Cortex, you can choose whether Azure DevOps work items should be pulled in from Azure DevOps. Cortex recommends disabling this option if your organization does not use work items or if you are worried about running into rate limit issues.
To define Azure DevOps work items for a given entity, add the x-cortex-azure-devops block to the entity's descriptor. If there is no work item registrations, but the entity matches a repository, we will pull in all work items from the repository's project with a tag that matches the Cortex entity name, Cortex entity tag, or the repository name.
Initiatives allow you to set deadlines for specific rules or a set of rules in a given Scorecard and send notifications to users about upcoming due dates.
From the Issues tab of an Initiative, you can automatically create a Azure DevOps work item from a failing rule:
Click Create issue.
In the modal that appears, fill out the form:
Integration: If you have multiple task tracking tools, select Azure DevOps from the Integration dropdown.
Name: Enter a name for the configuration.
Project: Select from the dropdown.
Options available in the dropdown are pulled in from the specific Azure DevOps instances configured in Settings.
Select the Work item type and the Sub-item Type from the respective dropdowns. Then, select how the sub-items's fields should be populated on issue creation and status change.
Choose to include or exclude groups of entities, or define a more advanced filter.
The issue configuration will apply to all entities that meet the filter criteria. Once an entity is passing the rule, Cortex will automatically close the associated ticket.
Expected results
Entity pages
The Azure DevOps integration will populate the Repo detail block on an entity's details page.
In the Recent activity preview, you'll find the recent commits and releases. These will also appear in the event timeline.
These data will appear for entities imported from a Git source or those that have a Git repo defined in their YAMLs.
Events
On an entity's Events page, you can find all of the commits and releases associated with that entity. Each is hyperlinked to the commit or release page in Azure DevOps and includes a timestamp.
CI/CD
From the CI/CD > Azure DevOps page in the entity's sidebar, see a history of pipeline runs.
Repository
You can access more detailed information pulled from Azure DevOps under Repository in the sidebar. At the top of the repository page, you'll find the repo associated with that entity and the most-used language in files for that entity. In the Top contributors block, you'll find the three users who have contributed the most code and the number of their contributions.
In the Commits section, you'll find the 10 most recent commits and metadata about each. Below Commits is the Recent releases section, which includes the 5 most recent releases.
Issue tracking
In the Issue tracking section, you can find a list of open Azure DevOps work items. Each work item will show the title, summary, assignees, priority, and date created.
Dev homepage
The Azure DevOps integration enables Cortex to pull information about pull requests and work items into the Dev homepage. You can find your open pull requests under the My open PRs tab, any pull requests assigned to you for review under the Assigned reviews tab, and any work items assigned to you under the Issues tab.
Pull requests and work items from Azure DevOps are refreshed every 5 minutes.
Eng Intelligence
The Eng Intelligence tool also uses pull request data from Azure DevOps to generate metrics:
Total number of approval required to merge a pull request into a repository. Defaults to 0 if no approvals are defined.
Definition:git.numOfRequiredApprovals()
Examples
For a security or development maturity Scorecard, you can write a rule to make sure at least one approval is required for a pull request:
git.numOfRequiredApprovals() >= 1
By having a rigorous PR process in place for a repo, you can make sure changes aren't made that create vulnerabilities. This kind of rule could also be used in a best practices or project standards Scorecard.
You can also use a similar expression in the Query Builder to find entities lacking approval:
git.numOfRequiredApprovals() < 1
Branches
List all live branches with some basic metadata:
Head
Is protected
Name
Definition:git.branches(): List<GitBranch>
Example
For a development best practices Scorecard, you can make sure that branches associated with an entity match a standard naming convention:
For a security Scorecard, you can write a rule to make sure the default branch is protected:
git.branchProtection() != null
Or to make sure the main branch is protected:
git.branchProtection("main") != null
Because vulnerabilities in the default branch are critical, this rule should be in one of the first couple levels. A higher-level rule might make sure that branch protection checks are set:
You can also use the Query Builder to find entities with unprotected default branches:
git.branchProtection() = null
Commits
Get the latest commits (to a maximum of 100) for a defined lookback period (defaulting to 7 days).
These results can be filtered based on branch name, using the default branch if no other branch is provided.
Definition:git.commits()
Examples
You can use the git.commits() expression in a security Scorecard to make sure entities have fewer than three commits to a "security-fixes" branch in the last week:
git.commits(branch="security-fixes").length < 3
Entities passing this rule will include those that haven't needed three or more security fixes. This can indicate that there aren't vulnerabilities in a given entity's code, but could also suggest that fixes aren't being implemented.
Using this rule in conjunction with one focused on vulnerabilities could provide the extra context needed to gain a better understanding of what's happening.
Default branch
Default branch for the entity's repository or main when null.
Definition:git.defaultBranch()
Examples
If default branches should always be named "main," you can write a rule in a best practices Scorecard to make sure entities are compliant:
git.defaultBranch().matches("main")
File contents
Load the contents of a file from the entity's associated repository.
The contents can be validated by using string comparison operations or parsed by the built-in jq function. The jq function will automatically coerce file contents of JSON or YAML formats.
Definition:git.fileContents(<filename: Text>)
Examples
For a Scorecard focused on development maturity, you could use the git.fileContents() rule to enforce that a CI pipeline exists, and that there is a testing step defined in the pipeline:
git.fileContents(“circleci/config.yml”).matches(“.*npm test.*”) - Enforce that a CI pipeline exists, and there is a testing step defined in the pipeline
A best practices Scorecard, meanwhile, could use this expression for a number of rules:
To make sure node engine version in specified in the package.json file:
To make sure projects using yarn do not allow NPM:
jq(git.fileContents("package.json"), ".engines.yarn") == null or jq(git.fileContents("package.json"), ".engine.npm") = "please-use-yarn"
And to ensure the yarn version being used is not deprecated:
jq(git.fileContents("package.json"), ".engines.yarn") == null or !(semver("1.2.0") ~= semverRange(jq(git.fileContents("package.json"), ".engines.yarn")))
File exists
Check if file exists from within the entity's associated repository.
Definition:git.fileExists(<filename: Text>)
Examples
For a development best practices Scorecard, this expression can be used for a rule that makes sure developers are checking in lockfiles to ensure repeatable builds:
git.fileExists(“package-lock.json”)
In the Query builder, you can use this expression with a wildcard to find entities with unit tests enabled:
git.fileExists(*Test.java”)
Or to find entities with an outdated Terraform version:
git.fileExists("terraform/versions.tf") and !git.fileContents("terraform/versions.tf").matchesIn("required_version =! \"[~>= ]{0,3}0\\.(12|13)")
Has Cortex YAML (GitOps)
When enabling GitOps to manage entity descriptors, Cortex checks for a checked in file ./cortex.yaml at the root directory. This rule can help track migrations from UI editing to GitOps for entity descriptor management.
Definition:git.hasCortexYaml()
Examples
If you're using a Scorecard to track a migration from Cortex UI to GitOps, you can use this rule to make sure entities are set up for GitOps management of entity descriptors:
git.hasCortexYaml() == true
Git repository set
Check if entity has a registered Git repository.
Definition:git (==/!=) null
Examples
A Scorecard focused on best practices or standards will likely include a rule in its first level making sure a Git repository is set up:
git != null
If an entity is failing this rule, it can indicate broader issues with the integration or explain why an entity isn't functioning as expected.
Last commit details
Provides last commit details.
Definition:git.lastCommit()
Examples
Depending on best practices at your organization, you may want to confirm the last commit for a given entity is no older than 3 days:
Confirming whether a service was updated recently can help team members catch outdated code sooner. Plus, if there is a security issue, you can quickly determine which services have or have not been updated to patch the vulnerability.
For a best practices Scorecard, you can also use this expression to make sure the entity's last commit message follows conventional commit guidelines:
Get pipelines runs meeting the given filter criteria, which includes results, states. Results include "succeeded", "failed", "canceled", "unknown", states include "completed", "inProgress", "canceling", "unknown".
Definition: azureDevops.pipelineRuns()
Examples
List pipeline runs that are opened and reviewed within 1 day:
Calculates the duration of time between Scorecard evaluation and the date of the last commit from the entity's Git repository.
Definition:git.lastCommit().freshness
Examples
One of the first rules you might write for a Scorecard focused on development maturity or security is one validating that the last commit was within the last month:
git.lastCommit().freshness < duration("P1M")
As counterintuitive as it may seem, services that are committed too infrequently are actually at more risk. People who are familiar with the service may leave a team, institutional knowledge accumulates, and from a technical standpoint, the service may be running outdated versions of your platform tooling.
Reviews
List reviews left during a defined lookback period.
Organization
Repository
Review date
Reviewer
Definition:git.reviews()
Examples
A development maturity Scorecard might use the git.reviews() expression to make sure that there is a rigorous review process in place before changes are implemented:
git.reviews(lookback=duration("P7D")).length > 25
This rule makes sure that there are more than 25 reviews left in the last week.
Search repository files
Find all instances of code search query from within a repository.
Can filter by path, file name (extension required in file name), or extension. Filters can use * for glob matching. Supplying a query is required.
Find top used language for a repository, if available.
Definition:git.topLanguage()
Examples
Let's say the primary language developers should be using is Kotlin. You can write a rule to make sure that the top language associated with entities is Kotlin:
git.topLanguage() == "kotlin"
You can also use this expression to query for entities that don't have Kotlin as the top language to identify those that need to be updated:
git.topLanguage() != "kotlin"
Work items
Number of unresolved work items associated with the entity, where unresolved is defined as the WIQL [System.State] NOT IN ('Closed', 'Done', 'Completed', 'Inactive', 'Removed').
Definition:azureDevops.workItems()
Examples
For a Scorecard measuring entity maturity, you can use this expression to make sure entities have fewer than 10 Azure DevOps work items:
azureDevops.workItems().length <= 10
Work items from WIQL query
Number of work items associated with the entity based on arbitrary WIQL query.
Definition:azureDevops.workItems(query: Text | Null)
Examples
For a more specific rule in an entity maturity Scorecard, you can use this expression with a WIQL query to make sure entities have no more than 3 tickets with "Doing" status and highest priority.
jira.workItems("System.State = \"Doing\" AND Microsoft.VSTS.Common.Priority = 1").length <= 3
Background sync
Cortex conducts a background sync of Azure DevOps identities every day at 10 a.m. UTC. Pull requests and work items are refreshed every 5 minutes.
The following options are available to get assistance from the Cortex Customer Engineering team:
Email: help@cortex.io, or open a support ticket in the in app Resource Center
Chat: Available in the Resource Center
Slack: Users with a connected Slack channel will have a workflow added to their account. From here, you can either @CortexTechnicalSupport or add a :ticket: reaction to a question in Slack, and the team will respond directly.
Don’t have a Slack channel? Talk with your Customer Success Manager.