Liquibase template errors

I’m using the Liquibase Template for SQL Server featured in Delivering Database DevOps with Liquibase and Octopus Deploy - YouTube and having a bit of trouble. When I do either the reporting or the applying steps I get the following error but it’s not enough detail to reveal what’s going wrong. Has anyone experienced this?

I tried using the Octopus.Calamari.CopyWorkingDirectoryIncludingKeyTo variable to copy the work folder however even though the log shows that it’s copying I get nothing.

Downloading Liquibase from https://github.com/liquibase/liquibase/releases/download/v4.9.1/liquibase-4.9.1.zip https://github.com/liquibase/liquibase/releases/download/v4.9.1/liquibase-additional-4.9.1.zip ...
14:55:00   Error    |       NotSpecified: Cannot find an overload for "Substring" and the argument count: "1".
14:55:00   Error    |       At C:\Octopus\Tentacle\Work\20220413145453-106733-109\Script.ps1:37 char:52
14:55:00   Error    |       + ... t\liquibase\$($downloadUrl.Substring($downloadUrl.LastIndexOf("/")))"
14:55:00   Error    |       +                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
14:55:00   Error    |       at Get-Liquibase, C:\Octopus\Tentacle\Work\20220413145453-106733-109\Script.ps1: line 37
14:55:00   Error    |       at <ScriptBlock>, C:\Octopus\Tentacle\Work\20220413145453-106733-109\Script.ps1: line 382
14:55:00   Error    |       at <ScriptBlock>, <No file>: line 1
14:55:00   Error    |       at <ScriptBlock>, C:\Octopus\Tentacle\Work\20220413145453-106733-109\Octopus.FunctionAppenderContext.ps1: line 201
14:55:00   Error    |       at <ScriptBlock>, C:\Octopus\Tentacle\Work\20220413145453-106733-109\Bootstrap.Octopus.FunctionAppenderContext.ps1: line 2944
14:55:00   Error    |       at <ScriptBlock>, <No file>: line 1
14:55:00   Error    |       at <ScriptBlock>, <No file>: line 1

Greetings @james.nichols, thanks for reaching out! The template that was covered in that video has been deprecated in favor of https://library.octopus.com/step-templates/36df3e84-8501-4f2a-85cc-bd9eb22030d1/actiontemplate-liquibase-run-command which has richer functionality. Would you be able to try that one? If you’re still having issues, please let me know, I authored both :slight_smile:

Regards,

Shawn

In fact, I know exactly what error that is and it has been fixed in the newer template :slight_smile:

Regards,

Shawn

Oh! I forgot to mention that we have a working example on our Samples instance - Octopus Deploy

Thanks for pointing me in a better direction! I have gotten farther now. Working through a database access issue at the moment but I did have a question. It looks like I can’t specify the location of the change log. If I put a folder in the parameter it fails to find the file. It does find it if I don’t specify the folder but what happens if I have multiple files with the same name?

Say I wanted to use this as my parameter and folder structure:

Parameter:
#{Octopus.Deployment.Tenant.Name}\changelog.xml

Folders:
\Tenant1\changelog.xml
\Tenant2\changelog.xml
\Tenant2\changelog.xml

I could just as easily name my change logs Tenant##changelog.xml and use a different variable but just wondering if that could work.

I’m actually in it right now adding Azure Managed Identity as an authentication option. Let me do some experimentation to see if we can make that work for you.

Regards,

Shawn

1 Like

The Get-ChangeLog function looks for the file specified so providing a path won’t work as written. If you change the filenames of the changelog like #{Octopus.Depoloyment.Tenant.name}_changelog.xml that would be one way of making it work.

Function Get-ChangeLog
{
    # Define parameters
    param ($FileName)
    
    # Find file
    $fileReference = (Get-ChildItem -Path $OctopusParameters["Octopus.Action.Package[liquibaseChangeSet].ExtractedPath"] -Recurse | Where-Object {$_.Name -eq $FileName})

    # Check to see if something weas returned
    if ($null -eq $fileReference)
    {
        # Not found
        Write-Error "$FileName was not found in $PSScriptRoot or subfolders."
    }

    # Return the reference
    return $fileReference
}

That’s how I’ve been going with it thus far and can roll with it. This is a POC so I can define how we’ll work with the change lists going forward. Thanks for taking a look.

Absolutely! Please let me know if you run into any more difficulties :slight_smile:

Regards,

Shawn

@Shawn_Sesna it seems that if you use Windows Authentication and specify a “Connection query string parameter” it doesn’t concatenate correctly and leaves out a semicolon. I worked around it by prepending on the variable but thought I should mention it.

13:03:36 Info | Caused by: liquibase.exception.DatabaseException: Connection could not be created to jdbc:sqlserver://<SERVER>:1433;database=<DB>;;integratedSecurity=truetrustServerCertificate=true with driver com.microsoft.sqlserver.jdbc.SQLServerDriver. The property integratedSecurity does not contain a valid boolean value. Only true or false can be used.

Ah! Okay, I’ll fix that, thanks for letting me know :slight_smile:

Actually, that’s by design as the format differs by database technology. The help text for the input is currently Add additional parameters to the connection string URL. Example: ?useUnicode=true or ;AuthMech=1 I tried to show that the delimiter needs to be in the beginning, is there some language that might make that more clear?

Regards,

Shawn

A colleague actually added the parameter but looking at the instruction I missed it at first. I think rewording the instruction to “Add additional parameters with delimiter to the connection string URL. Example: ?useUnicode=true or ;AuthMech=1” might call it out more. Granted it will fail and you do easily see the culprit. It took me a moment to find only because I didn’t make the change.

Fair enough, thanks for the suggestion :slight_smile:

Regards,

Shawn

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