I created a Visual Studio Team Services extension that provides several build tasks. All tasks are implemented as PowerShell scripts.
Everything seemed to work as expected but then I realised that when a task had an error that did not break the build, as it should.
I assumed that a PowerShell script returning a non-zero exit code would break the build, but it doesn't. To confirm it, I created a very simple task with this line only:
exit 1
and checked that the build succeeds.
I have also found out that uncaught exceptions in the script do cause the build to fail.
Therefore, how should failures be notified from build tasks?
UPDATE: There are the task.json and script I am using:
task.json:
{
"id": "7CA6E75B-0700-4723-83A7-C167EA514988",
"name": "ExampleTask",
"friendlyName": "Example build task",
"description": "Example build task for development purposes",
"author": "eduardomhg",
"category": "Utility",
"visibility": [
"Build",
"Release"
],
"demands": [],
"version": {
"Major": "0",
"Minor": "0",
"Patch": "1"
},
"minimumAgentVersion": "1.83.0",
"instanceNameFormat": "Example Task",
"groups": [
{
"name":"advanced",
"displayName":"Advanced",
"isExpanded":false
}
],
"execution": {
"PowerShell": {
"target": "$(currentDirectory)\\ExampleTask.ps1",
"argumentFormat": "",
"workingDirectory": "$(currentDirectory)"
}
}
}
ExampleTask.ps1:
Write-Host "Executing example task..."
exit 1
Try to use this code instead:
[Environment]::Exit(1)
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments