johanclasson / vso-agent-tasks

Build and Release Tasks for Visual Studio Online and Team Foundation Server
MIT License
20 stars 16 forks source link

DbUpMigration - When using System.Debug=true, errors/warnings reported in release summary #16

Closed sumo300 closed 7 years ago

sumo300 commented 7 years ago

Here's a debug log of a successful run of a DbUp task in TFS 2017. In the log, there are errors/warnings that then get reported in the release summary as errors. Here's the log and a screenshot.

2017-03-23T21:30:05.8642571Z ##[section]Starting: DbUp Migration - ****** - Everytime
2017-03-23T21:30:05.8642571Z ==============================================================================
2017-03-23T21:30:05.8642571Z Task         : DbUp Migration
2017-03-23T21:30:05.8642571Z Description  : Runs SQL Server change scripts, and only those which have not been run already.
2017-03-23T21:30:05.8642571Z Version      : 0.10.5
2017-03-23T21:30:05.8642571Z Author       : Johan Classon
2017-03-23T21:30:05.8642571Z Help         : [More Information](https://github.com/johanclasson/vso-agent-tasks)
2017-03-23T21:30:05.8642571Z ==============================================================================
2017-03-23T21:30:05.8642571Z Preparing task execution handler.
2017-03-23T21:30:06.1767642Z Executing the powershell script: D:\******\agent\_work\_tasks\UpdateDatabaseWithDbUp_4182dbda-71db-4d18-89b3-75255b7802eb\0.10.5\Update-Database.ps1
2017-03-23T21:30:06.1767642Z ##[debug]PowerShellHandler.Execute - AddCommand(D:\******\agent\_work\_tasks\UpdateDatabaseWithDbUp_4182dbda-71db-4d18-89b3-75255b7802eb\0.10.5\Update-Database.ps1)
2017-03-23T21:30:06.1767642Z ##[debug]PowerShellHandler.Execute - Add inputParameters
2017-03-23T21:30:06.1767642Z ##[debug]PowerShellHandler.Execute - AddParameter(ConnectionString=Server=*********,******;Database=******;Trusted_Connection=true;)
2017-03-23T21:30:06.1767642Z ##[debug]PowerShellHandler.Execute - AddParameter(ScriptPath=D:\******\agent\_work\r18\a\***.******.******.******\drop\impl\******)
2017-03-23T21:30:06.1767642Z ##[debug]PowerShellHandler.Execute - AddParameter(JournalToSqlTable=false)
2017-03-23T21:30:06.1767642Z ##[debug]PowerShellHandler.Execute - AddParameter(ScriptFileFilter=everytime-.*)
2017-03-23T21:30:06.1767642Z ##[debug]PowerShellHandler.Execute - AddParameter(TransactionStrategy=SingleTransaction)
2017-03-23T21:30:06.3017632Z ##[debug]PowerShellHandler.Execute - Invoke
2017-03-23T21:30:06.3330153Z ConnectionString: Server=*********,******;Database=******;Trusted_Connection=true;
2017-03-23T21:30:06.3330153Z 
2017-03-23T21:30:06.3330153Z 
2017-03-23T21:30:06.3330153Z ScriptPath: D:\******\agent\_work\r18\a\***.******.******.******\drop\impl\******
2017-03-23T21:30:06.3330153Z 
2017-03-23T21:30:06.3330153Z 
2017-03-23T21:30:06.3330153Z Journal: NullJournal
2017-03-23T21:30:06.3330153Z 
2017-03-23T21:30:06.3330153Z 
2017-03-23T21:30:06.3330153Z ScriptFileFilter: everytime-.*
2017-03-23T21:30:06.3330153Z 
2017-03-23T21:30:06.3330153Z 
2017-03-23T21:30:06.3330153Z TransactionStrategy: SingleTransaction
2017-03-23T21:30:06.3330153Z 
2017-03-23T21:30:06.3330153Z 
2017-03-23T21:30:06.3955132Z ##[debug]
2017-03-23T21:30:06.3955132Z public class VstsUpgradeLog : DbUp.Engine.Output.IUpgradeLog
2017-03-23T21:30:06.3955132Z {
2017-03-23T21:30:06.3955132Z     private System.Action<string> WriteHost { get; set; }
2017-03-23T21:30:06.3955132Z 
2017-03-23T21:30:06.3955132Z     public VstsUpgradeLog(System.Action<string> writeHost)
2017-03-23T21:30:06.3955132Z     {
2017-03-23T21:30:06.3955132Z         WriteHost = writeHost;
2017-03-23T21:30:06.3955132Z     }
2017-03-23T21:30:06.3955132Z 
2017-03-23T21:30:06.3955132Z     public void WriteInformation(string format, params object[] args)
2017-03-23T21:30:06.3955132Z     {
2017-03-23T21:30:06.3955132Z         WriteHost(string.Format(format, args));
2017-03-23T21:30:06.3955132Z     }
2017-03-23T21:30:06.3955132Z 
2017-03-23T21:30:06.3955132Z     public void WriteWarning(string format, params object[] args)
2017-03-23T21:30:06.3955132Z     {
2017-03-23T21:30:06.4111395Z ##[warning]" + string.Format(format, args));
2017-03-23T21:30:06.4111395Z ##[debug]Processed:         WriteHost("##vso[task.logissue type=warning;]" + string.Format(format, args));
2017-03-23T21:30:06.4111395Z     }
2017-03-23T21:30:06.4111395Z 
2017-03-23T21:30:06.4111395Z     public void WriteError(string format, params object[] args)
2017-03-23T21:30:06.4111395Z     {
2017-03-23T21:30:06.4111395Z ##[error]" + string.Format(format, args));
2017-03-23T21:30:06.4111395Z ##[debug]Processed:         WriteHost("##vso[task.logissue type=error;]" + string.Format(format, args));
2017-03-23T21:30:06.4111395Z     }
2017-03-23T21:30:06.4111395Z }
2017-03-23T21:30:06.5673946Z Beginning transaction
2017-03-23T21:30:06.5673946Z 
2017-03-23T21:30:06.5673946Z 
2017-03-23T21:30:06.5673946Z Beginning database upgrade
2017-03-23T21:30:06.5673946Z 
2017-03-23T21:30:06.5673946Z 
2017-03-23T21:30:06.5673946Z Executing SQL Server script 'everytime-Registration.sql'
2017-03-23T21:30:06.5673946Z 
2017-03-23T21:30:06.5673946Z 
2017-03-23T21:30:06.5986453Z Upgrade successful
2017-03-23T21:30:06.5986453Z 
2017-03-23T21:30:06.5986453Z 
2017-03-23T21:30:06.6142698Z ##[section]Finishing: DbUp Migration - ****** - Everytime

image

johanclasson commented 7 years ago

To get the output of DbUp to play nice with VSTS i had to override the default logging supplying an implementation of DbUp.Engine.Output.IUpgradeLog. The implementation is made through C#-code that is loaded into the PowerShell session through Add-Type. That C#-code is stored in a variable that seams to be logged when running in system debug mode.

Perhaps that behavior will be fixed if I remove the variable and supply the code inline with the Add-Type command instead. I will experiment with this when I get some time over.

Thanks for reporting this!

sumo300 commented 7 years ago

@johanclasson Good news is that it still works flawlessly! Thanks for providing it!

johanclasson commented 7 years ago

I finally got some time over to fix this! 😀 New version 0.12.0 available.