Validating Environment Variables in the Azure Build Pipeline
Automated tests often require environment variables, e.g. to define the test browser, access data or the interval for the test.With a simple Powershell at the beginning of the pipeline these can be easily validated.
$browsers = @("Chrome","IE","Edge", "Firefox")
If ($browsers -NotContains $env:TEST_BROWSER)
{
Throw "$($env:TEST_BROWSER) is not a valid Browser or environment var 'TEST_BROWSER' is not set. Use $($Browsers) instead."
}
if($env:TEST_FILTER_CRITERIA.Length -lt 10)
{
Throw "$($env:TEST_FILTER_CRITERIA) is not a valid filter or environment var 'TEST_FILTER_CRITERIA' is not set. Use something like 'Category=basetest' instead."
}
This ensures that the required environment variables are set correctly at the beginning of the pipeline.
Kommentare
Kommentar veröffentlichen