Liquibase update success message appears as an error

I saw this thread https://help.octopusdeploy.com/discussions/problems/46974-lquibase-update-success-message-coming-as-error-in-logs which is about the same issue I’m here about.

When I run a liquibase ‘update’ command, the log saying it was successful registers as an error (see log in other thread as it is the exact same).

A suggestion from the comments is to add Exit 0 to the script if it ran successfully but I’m a bit stumped on how to do that.

Here is my script (I call Liquibase commands a couple of times and I’ve removed unnecessary parts of the command):

Write-Host "2.  Executing updateSql command"
java -cp "jar locations"  liquibase.integration.commandline.Main  --driver "com.mysql.jdbc.Driver" --changeLogFile "_schema.xml" --logLevel severe --username $LiquibaseUsername --password=$LiquibasePassword --url "jdbc:mysql://localhost:3306/$($DatabaseName)?useSSL=false" updateSql

Write-Host "3.  Executing update command"
java -cp "jar locations"  liquibase.integration.commandline.Main  --driver "com.mysql.jdbc.Driver" --changeLogFile "_schema.xml" --logLevel severe --username $LiquibaseUsername --password=$LiquibasePassword --url "jdbc:mysql://localhost:3306/$($DatabaseName)?useSSL=false" update

If possible I’d still like the logs to show "Liquibase ‘update’ Successful, just not appear as an Error - but happy to have it return Exit 0 if that is better, just unsure how.

Hi Troy
In powershell, you can exit with a specific exit code by running Exit 0. Without using the Exit command, the exit code of the last invoked command will be used as the exit code of the script.

In your case, you may want to detect if the java -cp command failed and exit accordingly, while still allowing a successful code to be treated as a 0. In this case what you probably want to do, is make use of the $LASTEXITCODE to detect if the java command succeeded or failed and exit accordingly.

For example, if i assume that the java command is exiting with a 1 if it succeeds, we might do something like

Write-Host "3.  Executing update command"
java -cp "jar locations"  liquibase.integration.comman
if($LASTEXITCODE -eq 1)  {
  EXIT 0
}
Write-Host "Something went wrong"
Exit 1

I hope this example provides some indication of what your script should look like. Take a look at some of the Powershell docs for more details about how this works, or let me know if i can be of any further help.
Cheers,
Rob

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.