1

I have a small CI/CD script which is written in PowerShell, but I don't know how to stop it, if in the script I get unexpected error running Liquibase. All scripts in SQL and work (preconditions in place where I need to add), but I want to have more opportunity to control CI/CD script. Now, if the script gets the exception, it continues execution. The script updates some schemes and some of them has an influence on each other, so order is important.

#update first scheme - ETL (tables, global temp tables, packages)
.\liquibase update --defaults-file=import.properties

#how to stop this script, if I get unexpected error running Liquibase?

#update second scheme - data (only tables and roles for data)
.\liquibase update --defaults-file=data.properties
#update third scheme - views, tables and other for export data
.\liquibase update --defaults-file=export.properties

Compo
  • 36,585
  • 5
  • 27
  • 39
Bushuev
  • 557
  • 1
  • 10
  • 29
  • in fact, you need to track the exit code of the process https://stackoverflow.com/questions/10262231/obtaining-exitcode-using-start-process-and-waitforexit-instead-of-wait – rinat gadeev Feb 14 '23 at 11:01

1 Answers1

1

Have you tried this?

$result = Start-Process -filepath 'path to liquibase' -ArgumentList "your liquibase arguments go here" -wait
if($result.ExitCode -ne 0){
  write-host 'something went wrong'
}
Gerrit Geeraerts
  • 924
  • 1
  • 7
  • 14
  • 1
    Work, but without "-wait $True", PowerShell write exception:"A positional parameter cannot be found that accepts argument "True"", I used "-wait" and the script was run. – Bushuev Feb 14 '23 at 13:15
  • 1
    I passed $True to a switch, that was pretty pointless of me :p I adjusted the answer. Good luck with your script! – Gerrit Geeraerts Feb 14 '23 at 15:23