I'm using Azure DevOps SQL Server database deploy task to run a SQL Server Agent Job using its inline SQL feature which works.
However if the job fails I have some logic that generates an error from the SQL script as per below. When the script errors, that error correctly gets displayed in the task logs, however it doesn't fail the whole task but rather returns a succeeded status. This confuses the developer as they think their changes are not breaking the job when in fact they are.
Is there anyway to bubble up the error generated form the SQL script so that the SQL Server database deploy task returns a failed status instead of a succeeded status.
Please see screen shots and YAML of the release issue below:
steps:
- task: SqlDacpacDeploymentOnMachineGroup@0
displayName: 'Run SQL Agent Job'
inputs:
TaskType: sqlInline
InlineSql: |
/* SQL Agent Job Logic Here... */
/* Raise error if job fails */
RAISERROR('##vso[task.logissue type=error]]%s job has either failed or is not in a good state!', 16, 1, 'JobName') WITH LOG
DatabaseName: master
AdditionalArgumentsSql: '-QueryTimeout 1800 -IncludeSqlUserErrors -OutputSqlErrors 1 -Verbose'

