Let your Inline Powershell task fail

Tips and tricks Inline Powershell task VSTS

Advertisements

Maximize how you use your VSTS build and release pipeline with Inline Powershell tasks. In this blog series ‘Tips and Tricks for Inline Powershell’, I will show simple samples on how to get more out of your pipelines. This blog post: Let your task fail.

VSTS Inline Powershell task
The Inline PowerShell VSTS task enables you to execute PowerShell from a textbox within your build or release pipeline. You can run a PowerShell script on you agent or as Azure Powershell.
Introduction Inline Powershell Task
Install Inline Powershell Task

Let your Inline Powershell task fail
Sometimes you have to fail your build or release. In your Inline Powershell task you have 2 options in bow to do this. The first option in with a ‘exit 1’, the second option is vso command.

exit 1
Write-Host "##vso[task.complete result=Failed;]DONE"

You have to following options as result value for your task:
Succeeded
SucceededWithIssues
Failed
Cancelled
Skipped

 

More tips and tricks
Use VSTS variables
Let your task fail
Set progress
Change buildnumber
VSTS Command overview
Call a WebHook
Download a file
Install a Powershell Module
Navigate VSTS as filesystem
Make VSTS API Rest calls
Script example: Act on failed build

6 thoughts on “Let your Inline Powershell task fail”

  1. Hi
    Again thanks for the Task you created it is great!
    Is it possible to get the last task result and use it in the next task?
    Do i need to set my own variable for this or is there a system variable?
    I need to know if former task failed and then decide what to do with current task
    thanks
    gal

    Like

      1. Hi
        What i am trying to get is the result of the build – using task “Visual Studio Build”
        I want to trigger an event on that fail
        Is there an option\parmeter to get Last Task Result?
        Thanks
        Gal

        Like

  2. Hi
    Sorry to trouble you
    I am trying to get the result of a build task during the build not after build fails .
    Is that possible?
    Thanks
    Gal

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s