skip to Main Content

What I would like to achive is that the developer is forced to include the bugfix/feature workitem id in the commit message that he is currently working on

or do some regex validation mybe

Like:

  • fix: fixes bug #123
  • feat: implements #124

Settings are forcing a developer to include workitems but that he can link in the dialog and that does not get inclided in the commit message

2

Answers


  1. For commits, ideally, you would look to use pre-commit git hooks. These can be run on the client or the server. The bad news is that Azure DevOps does not support server-side git hooks as mentioned here. You can use client hooks however it would then require each developer to ensure they have set them up on their machine.

    For pull requests, you can set up PR templates, these would not enforce but could prompt users with a checklist.

    You can also set up an Azure pipeline to be triggered as PR validation on a branch. This can then write comments, add reviewers or even reject PRs. You can have one pipeline that would work for every repo or set it per branch.

    Finally, a webhook is raised when a PR is created in Azure DevOps. You can hook into this and perform custom logic including calling an API to add a PR comment.

    Login or Signup to reply.
  2. Settings are forcing a developer to include workitems but that he can link in the dialog and that does not get inclided in the commit message

    Isn’t this good enough?

    Configuring a branch policy in order to require associations between PRs and work items does the job IMO – listing the branch history you can see the corresponding PR:

    Branch history

    In case you need to do custom validation, consider using Azure Functions to create custom branch policies to validate PRs in an Azure DevOps Services Git repository for code events, such as Pull request created or Pull request updated.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search