badge is shown in this pic in orange color:
I have tried below pipeline. but not getting warning badge.
trigger:
branches:
include:
- main
pool:
vmImage: 'ubuntu-latest'
steps:
- script: |
echo "Parsing JSON output..."
echo "##[error]Warning: some message"
displayName: "Force Warning as Error"
badge is shown in this pic in orange color:
I have tried below pipeline. but not getting warning badge.
trigger:
branches:
include:
- main
pool:
vmImage: 'ubuntu-latest'
steps:
- script: |
echo "Parsing JSON output..."
echo "##[error]Warning: some message"
displayName: "Force Warning as Error"
The echo "##[warning]Warning message"
command is used to mark the log as warning, affect the display as below but not the task result with badge.
To get warning badge:
One option is to use command echo "##vso[task.complete result=SucceededWithIssues;]"
as mentioned by @ScottRichards. The limitation is you need to make sure the task is NOT failed. If it's failed, it will still get failed badge.
In this scenario, we can consider another option, we can setcontinueOnError
option as true
. sample as below:
- script: |
exit 1 ### the command fails but task is succeededwithissue with continuesOnError
continueOnError: true
displayName: 'Force Warning'
Task with warning badge:
You can also consider to combine two options together, so that no matter the command result is failed or not, the task will get warning badge.
- script: |
any command
echo "##vso[task.complete result=SucceededWithIssues;]"
continueOnError: true
displayName: 'Force Warning'
You can run this command in a script to force the result of a pipeline task:
- script: echo "##vso[task.complete result=SucceededWithIssues;]"
Possible task results are:
See more here: https://learn.microsoft.com/en-us/azure/devops/pipelines/scripts/logging-commands?view=azure-devops&tabs=bash#example-1