Skip to content
| Marketplace
Sign in
Azure DevOps>Azure Pipelines>Commit Comment Validator
Commit Comment Validator

Commit Comment Validator

True Velocity

|
141 installs
| (0) | Free
Validate commit messages in a PR or diff with a target branch. Defaults validate that commit comments match the Conventional Commits specification. https://www.conventionalcommits.org
Get it free

Purpose

This extension provided a build task called "Commit Comment Validator" which allows teams to validate that either some or all commits in pull requests conform to a supplied regular expression.

How it works

The task can be added as a step/task in an Azure DevOps pipeline. Once it is added the task will examine commit messages to make sure they pass the provided regular expression. The task will fail if the validation fails.

Configuration

All Commits Must Match (allCommitsMustMatch)

This setting determines the behavior of validation concerning whether the whole set of examined commits must pass validation or any of the commits must pass validation.

Default

true

Enabled Behavior

  • When turned on, the step will fail if any of the commits being examined do not match the regular expression. Otherwise it will pass.

Disabled Behavior

  • When turned off, the step will fail if all of the commits being examined do not match the regular expression. Otherwise it will pass.

PR Mode (prMode)

This settings effects how the task decides which commit messages will actually be validated by examining the git history of the current repo and branch.

Default

false

Enabled Behavior

When using 'PR Mode', the task will examine all of the commits in the PR that triggered the pipeline run. Ideally, this should be used if the pipeline that your build task is in is a pipeline which is triggered by a pull request.

Disabled Behavior

When not using 'PR Mode', the task requires you to configure a diffBranch configuration.

In this case, the task will compare the 'current' branch from the repository it is being run within w/ the configured 'diffBranch' (i.e. origin/main).

So if the difference between the current repository and the configured 'diffBranch' is 3 commits, then all of these 3 commits will be examined against the configured regular expression.

Diff. Branch (diffBranch)

This configuration determines what branch to diff the 'current' branch (from the context of the repository that the running task is being run from) against when determining the commit messages to validate.

It is required if prMode is false.

Default

origin/main

Regular Expression (regExPattern)

The regular expression pattern (Irregexp flavor) to match commit messages against.\n\nA match means the commit message is valid.\n\nThe default pattern will match comments that are valid based on the Conventional Commits specification

Default

^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test){1}(\\([\\w\\.\\-\\p{Extended_Pictographic}]+\\))?(!)?: ([\\w \\p{Extended_Pictographic}])+([\\s\\S]*)

Regular Expression Flags (regExFlags)

Regular expression flags to use.

Options

Simply type a string of characters (no slashes or anything needed).

With the 'u' flag, \p{Extended_Pictographic} will match an emoji character.

Default

um

The default 'um' allows matching unicode and multiline.

How to use

After installing the extension, you can add the task to your pipeline.

PR mode

Validate all of the commits messages in the PR from a pipeline which is triggered by a PR in Azure Devops against conventional commit standards.

Pair this with a GitVersion config that relies on conventional commit standards to determine package SemVer increment for auto-incrementing major/minor/patch versions reliably.

Further pair this with Husky/git hooks that trigger git-cz or similar to automate enforcing devs using conventional commit standards for a truly automated package version experience.

- task: CommitMessageValidator@1
  inputs:
    regExPattern: '^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test){1}(\([\w\.\-\p{Extended_Pictographic}]+\))?(!)?: ([\w \p{Extended_Pictographic}])+([\s\S]*)'
    regExFlags: "um"
    allCommitsMustMatch: true
    prMode: true

Non PR Mode

Validate that the commits that result from diffing the current branch against origin/main conventional commit standards.

- task: CommitMessageValidator@1
  inputs:
    regExPattern: '^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test){1}(\([\w\.\-\p{Extended_Pictographic}]+\))?(!)?: ([\w \p{Extended_Pictographic}])+([\s\S]*)'
    regExFlags: "um"
    allCommitsMustMatch: true
    prMode: false
    diffBranch: origin/main

Restrictions

This task has only been tested against Azure DevOps pipelines. Also there are known issues with regular expression parsing if the build agent which is executing the task is running an older versions of Node (v6 to be exact although we havent' tested thoroughly on other versions).

Contribute

At the moment this code is private but we would consider opening it up to the public. Drop a question in Q & A if you'd like to contribute. We pay attention to it!

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft