Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to raise and display build warnings from build steps using TFS 2015? #573

Closed
mattbrooks2010 opened this issue Sep 22, 2015 · 7 comments
Assignees

Comments

@mattbrooks2010
Copy link

Background

The questions below relate to TFS 2015 on-premise.

It is possible to fail a build step by returning a non-zero exit code from, for example, a PowerShell or Command Line step. The build logs also capture anything written to the standard output stream. It is also possible to fail a Command Line step if anything is written to the standard error stream.

Question 1

Is it possible to raise build warnings via PowerShell and Command Line steps so that they're displayed on the build summary page under Issues? For example, in the same way that the Visual Studio Build / MSBuild steps are raised and displayed?

image

Question 2

I notice in the build logs for the Command Line step the following lines:

2015-09-22T12:29:21.0696320Z Executing the following commandline. (workingFolder = C:\Builds\_work\dacceaf2\Repo)
2015-09-22T12:29:21.0696320Z C:\Builds\_work\dacceaf2\Repo\tools\Test\bin\Release\Test.exe .\src\Web\Content\Images\ C:\Builds\_work\dacceaf2\staging\Web\Content\Images\
2015-09-22T12:29:21.0696320Z Error message highlight pattern: 
2015-09-22T12:29:21.0706314Z Warning message highlight pattern: 

Is there any way to set these highlight patterns for the step?

@pascalberger
Copy link
Contributor

You should be able to return warnings and errors from your script using logging commands.

@mattbrooks2010
Copy link
Author

@pascalberger OK thanks — tried emitting the output below from a PowerShell step and got the desired result on the build summary page:

Write-Host "##vso[task.logissue type=warning;]Test warning"
Write-Host "##vso[task.logissue type=error;]Test error"

image

Is there currently a generic way of teaching the build system what forms of existing tool output should be considered as warnings though — as per question 2 above?

Additionally are there any built-in generic conventions (other than the logging commands) for triggering a 'partially succeeded' step rather than a 'failed' step?

I'm happy the logging commands will work for us but they are proprietary — existing build logic will need updating.

@bryanmacfarlane
Copy link
Contributor

the logging cmds are the only mechanism. and even though are proprietary, then just go to console out

@sufyannisar
Copy link

sufyannisar commented Nov 28, 2017

I am using PowerShellOnTargetMachines Using File
Whenever I use Write-Host in script file e.g.
Write-Host "##vso[task.logissue type=error;]Test error"
in Powershell script I get error saying

A command that prompts the user failed because the host program or the command type does not support user interaction. Try a host program that supports user interaction, such as the Windows PowerShell Console or Windows PowerShell ISE, and remove prompt-related commands from command types that do not support user interaction, such as Windows PowerShell workflows.

@cosminstirbu
Copy link

I am also interested in VSTS being able to report warnings logged by MSBuild when invoked via a script such as Cake Build.

We're currently using Jenkins and this works really well there, however we'd like to migrate to VSTS but this is a show stopper for us.

I've also logged an issue here MicrosoftPremier/VstsExtensions#2 related to this.

@pascalberger
Copy link
Contributor

@cosminstirbu If you're using Cake you might be intereste in the Cake.Issues Addin. It provides addins for parsing MsBuild output for warnings and processing them further (by e.g. posting them as comments to VSTS pull requests). If it doesn't cover your scenario it can easily be enchanced with additional addins or code in your Cake script.

@cosminstirbu
Copy link

The addin looks like a good alternative. I'll have a look into it, as it's not quite clear if I should first redirect the output of the MSBuild to a file, and use that file as the input of the addin, or it can simply work off the MSBuild console output.

Thank you for mentioning it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants