Adding branch name to LivingDoc¶
Branch name in LivingDoc Generator¶
Using the --title
command line option the branch name (and commit information) can be included in the
generated HTML.
This process can be automated using a CI/CD system.
Branch name in Azure DevOps Pipeline¶
Azure DevOps Pipelines provides a rich set of variables like the branch name and commit message. Any of these variables can be used as part of the document title when the LivingDoc.CLI task is executed in the Pipeline.
First the LivingDoc.CLI has to be installed on the Agent, using the .NET Core build task
- Command
custom
- Custom command:
tool
- Arguments:
install --global SpecFlow.Plus.LivingDoc.CLI
YAML
steps:
- task: DotNetCoreCLI@2
displayName: 'dotnet custom'
inputs:
command: custom
custom: tool
arguments: 'install --global SpecFlow.Plus.LivingDoc.CLI'
Then the CLI can be invoked after the Visual Studio Test task using the Command line task.
In the script parameter the %Build_SourceBranchName%
and %Build_SourceVersion%
variables will be replaced during execution:
Script:
livingdoc test-assembly MyProject.Specs\bin\Debug\netcoreapp3.1\MyProject.Specs.dll --title "BookShop (%Build_SourceBranchName% - Build_SourceVersion:~0,7%)"
YAML
steps:
- script: 'livingdoc test-assembly MyProject.Specs\bin\Debug\netcoreapp3.1\MyProject.Specs.dll --title "BookShop (%Build_SourceBranchName% - Build_SourceVersion:~0,7%)"'
workingDirectory: BookShop.AcceptanceTests
displayName: 'Command Line Script'