问题
I am trying to pass a parameter from my update command as well as the liquibase properties file to my changeset. For some reason, it does not recognise the placeholder as a parameter but parses it as a value.
This is how I invoke the changeLog (which runs successfully):
@echo off
call Liquibase --changeLogFile=myChangeLogFile.xml update -Dparamname=value
myChangeLogFile.xml:
<changeSet author="tobi" id="preMigration" runAlways="true">
<executeCommand executable="C:\myBatFile.bat">
<arg value="${liquibase.properties.Dparamname}"/>
<arg value="${liquibase.properties.url}"/>
</executeCommand>
</changeSet>
The script does not recognise ${liquibase.properties.Dparamname} or ${liquibase.properties.url} as placeholders.
My Liquibase.properties file has the
url:jdbc:oracle:thin:@xyz:1521:ORCL
parameter set.
Any idea how I can access the properties or the command line parameters?
Thank you
I would appreciate your feedback.
Tobias
回答1:
Rather than using this in your changelog:
<changeSet author="tobi" id="preMigration" runAlways="true">
<executeCommand executable="C:\myBatFile.bat">
<arg value="${liquibase.properties.Dparamname}"/>
<arg value="${liquibase.properties.url}"/>
</executeCommand>
</changeSet>
it should look more like this:
<changeSet author="tobi" id="preMigration" runAlways="true">
<executeCommand executable="C:\myBatFile.bat">
<arg value="${paramname}"/>
<arg value="${url}"/>
</executeCommand>
</changeSet>
The -D
on the command line is the standard java mechanism for setting system properties, but when accessing them you just use the property name. I am fairly certain that you don't need to use the liquibase.properties
prefix either.
回答2:
I have a requirement like calling a .bat file with parameters from liquibase upgrade scripts. Also also this should run only one time like change set.
Thanks, Jagadeesh
来源:https://stackoverflow.com/questions/42368969/liquibase-passing-parameter-from-commandline-or-properties-to-changeset-xml