Pipelines
Azure DevOps
Trigger a deployment based on a tag
To trigger a deployment based on a tag, you can use the "Tag" trigger in your pipeline YAML file. This allows you to specify a tag pattern that will trigger the pipeline when a new tag is pushed to the repository.
Here is an example of how to set up a tag trigger in your pipeline YAML file:
trigger:
tags:
include:
- 'approved*'
pool:
vmImage: 'windows-latest'
variables:
buildConfiguration: 'Release'
steps:
- task: UseDotNet@2
inputs:
packageType: 'sdk'
version: '8.x' # Adjust to your .NET version
- task: DotNetCoreCLI@2
inputs:
command: 'publish'
publishWebProjects: true
arguments: '--configuration $(buildConfiguration) --output $(Build.ArtifactStagingDirectory)'
- task: AzureWebApp@1
inputs:
azureSubscription: 'ControlledReleaseConnection' # Replace with your Azure service connection name
appType: 'webApp' # Use 'webApp' for Windows, 'webAppLinux' for Linux
appName: 'controlled-release' # Replace with your Azure Web App name
package: '$(Build.ArtifactStagingDirectory)/**/*.zip'
Standard workflow
Make changes to the code> git status (shows changed files)
> git add . (stages all files ready for commit)
> git commit -m “Commit message here”
The changes are committed to the local git repository
> git push origin master (pushes changes to the remote ‘master’ branch)
Using tags
Use git log to list the commits
Find the commit to be tagged and copy its hash
> git tag “candidate-release-v1" -m “This commit is ready for approval” [hash]
> git push origin “candidate-release-v1" (the tag is now applied to the remote commit)
Make any further changes and commit to the remote. They will not affect the tagged version
> git tag “approved-cab-20250425" -m “Approved at CAB” [hash]
> git push origin “approved-cab-20250425"
The build pipeline will see the tag and start a deployment