The TargetBranchValidator Azure Pipeline Extension is a tool designed to help ensure that pull requests are targeting the correct branches for different release stages in your development workflow.
- Validates target branches for pull requests against release stages.
- Prevents pull requests from being merged into incorrect branches.
- Helps maintain a structured and organized release process.
To use the TargetBranchValidator Azure Pipeline Extension, you need to add it to your Azure DevOps Pipeline configuration. Here's how:
- Open your Azure DevOps project.
- Navigate to Pipelines > Pipeline settings > Extensions.
- Search for "TargetBranchValidator" and install the extension.
- Configure the extension in your pipeline YAML file.
In your pipeline YAML file, you can configure the TargetBranchValidator extension by adding a step similar to the following:
- task: TargetBranchValidator@0
inputs:
branches: 'develop, prerelease, master'
releases: '1.0.0, 2.0.0, 3.0.0'
fieldName: 'Custom.Release'- branches - List of target branches which we need to check out
- releases - List of releases which we have in target branches
- fieldName - Name of filed from task which we need to take for comparing
The extension first captures the target branch's name, followed by the associated release number designated for that branch. Subsequently, it gathers all interconnected tasks linked to the pull request. The extension's core functionality involves scrutinizing a specific field's value within these tasks and comparing it against the previously acquired release number.
Within our development team, we manage a variety of branches, each dedicated to distinct releases. On occasion, team members inadvertently create pull requests in branches that aren't aligned with the intended release target. To address this challenge, we have implemented an automated solution using Azure Pipelines. Now, when a pull request is initiated, our extension examines the connected tasks within the pull request and conducts a thorough comparison between task attributes and the specified target branch. This process ensures that pull requests are seamlessly validated against the appropriate target branch, promoting a streamlined and error-free development workflow.
This project is licensed under the MIT License.
