Forum Discussion

tanulbhasin's avatar
tanulbhasin
Brass Contributor
Feb 21, 2023

Complete pipeline execution with warning?

Hello,

 

While running pipeline, it either completes as Success(Green color), Error(Red color) or Cancelled(White circle with borders) as shown below

 

Is it possible complete this with warning(Yellow color) on the basis of some condition inside pipeline.

 

Please help. Thank you.

 

Kind Regards,

Tanul

  • RobinaThank you the details. This is the only algo can work.

     

    If possible, could you please share any msdn url for creating these labels etc. I don't know the procedure to define custom status or labels for pipelines in azure devops portal. I have searched a lot on google but no luck.

     

    Does this work Logging Commands 

  • Robina's avatar
    Robina
    Iron Contributor

    tanulbhasin 

    • To achieve this, you can define custom statuses or labels for your pipeline runs and use them to differentiate between successful runs, runs with errors, and runs with warnings.

    How you could implement this in a pipeline using a condition to trigger a warning status:

     

    • Define custom statuses or labels for your pipeline runs. For example, you could define "SUCCESS" as the status for successful runs, "ERROR" as the status for runs with errors, and "WARNING" as the status for runs with warnings.
    • Inside your pipeline, include a condition that checks for the warning condition. For example, you could check if a certain task failed, but not critical enough to mark the pipeline as failed. If this condition is met, set the status or label of the pipeline run to "WARNING".
    • When the pipeline completes, the status or label of the pipeline run will be set based on the condition you defined. You can use these custom statuses or labels to differentiate between successful, error, and warning runs.
    • tanulbhasin's avatar
      tanulbhasin
      Brass Contributor

      RobinaThank you the details. This is the only algo can work.

       

      If possible, could you please share any msdn url for creating these labels etc. I don't know the procedure to define custom status or labels for pipelines in azure devops portal. I have searched a lot on google but no luck.

       

      Does this work Logging Commands 

    • edrandall-blk's avatar
      edrandall-blk
      Copper Contributor

      Achieved this by echoing the following before the task ends, then exit with status 0:

       

      echo "##vso[task.complete result=SucceededWithIssues;]"

       

      The following will make the task fail (or alternatively, exit with non-zero status):

      echo "##vso[task.complete result=Failed;]"

       

Resources