Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to setup latest version of liquibase through bash script?

I used to install liquibase older version e.g

   `wget https://github.com/downloads/liquibase/liquibase/liquibase-2.0.5-bin.tar.gz`

and proceed with extraction and move it to desired location . I am unable to locate latest version of liquibase on github. Probably its removed or unavailable ?

Liquibase download page has only link to source-forge , could someone help me how to wget a package from source-forge ?

Edit I am not sure of github, it seems there are no builds available for latest version. However, my complete script looks like this:

#!/bin/bash
sudo apt-get update
sudo apt-get install -y openjdk-7-jre-headless
sudo apt-get install -y libmysql-java
LV="3.1.1"
function setupLiquibase(){
  source $HOME/.profile

  INSTALLED="$(command -v liquibase)"

  # if not added already
  if [ -z "$LIQUIBASE_HOME" ]
    then
      echo  'export MYSQL_JCONNECTOR=/usr/share/java/mysql-connector-java.jar'|sudo tee -a $HOME/.profile
      echo  'export LIQUIBASE_HOME=/usr/local/liquibase' |sudo tee -a $HOME/.profile
      echo  'export PATH=$PATH:$LIQUIBASE_HOME'|sudo tee -a $HOME/.profile
  fi

  if [ -z "$INSTALLED" ]
    then
        echo "Installing liquibase $LV "
        sudo rm -rf liquibase*
        wget http://kaz.dl.sourceforge.net/project/liquibase/Liquibase%20Core/liquibase-"$LV"-bin.tar.gz
        gunzip liquibase-"$LV"-bin.tar.gz
        sudo mkdir /usr/local/liquibase
        sudo tar -xf liquibase-"$LV"-bin.tar -C /usr/local/liquibase
        sudo chmod +x /usr/local/liquibase/liquibase
    else
        INSTALLED="$(liquibase --version)"
        echo "Liquibase is already installed, ${INSTALLED}"
  fi
}

setupLiquibase
like image 231
sakhunzai Avatar asked Jun 18 '14 13:06

sakhunzai


People also ask

What is the latest version of Liquibase?

Liquibase 4.15. 0 - August 5, 2022.

How do I find Liquibase version in Linux?

From a command line or terminal, type liquibase --version to verify that Liquibase has been installed successfully.


3 Answers

Try to download it with this command line

wget http://sourceforge.net/projects/liquibase/files/Liquibase%20Core/liquibase-3.2.0-bin.tar.gz/download -O liquibase-3.2.0-bin.tar.gz

To choose a filename for the download you can specify the option -O nomefile (Note that it is a capital o not a 0).

If you forget (like I did the first time) to specify -O nomefile you will have on the hard disk a file with the name as guessed by wget. So:

http://Site/FullPath/liquibase-3.2.0-bin.tar.gz/download  --> download

and after you have to rename by hands the file download.

If instead it was

http://Site/FullPath/liquibase-3.2.0-bin.tar.gz  --> liquibase-3.2.0-bin.tar.gz

you will have directly the file with the correct name.

like image 162
Hastur Avatar answered Oct 21 '22 09:10

Hastur


Github moved downloads section to /release.

So your url becomes:

https://github.com/liquibase/liquibase/archive/liquibase-parent-3.2.0.tar.gz
like image 44
Louis Kottmann Avatar answered Oct 21 '22 08:10

Louis Kottmann


I use apache ivy to download liquibase and its database driver dependencies from Maven Central.

Ivy itself is just a jar and can also be downloaded from Maven Central.

Example

This example runs a standard liquibase changeset and creates a h2 database. The bash script will download and cache required jars.

├── changesets
│   └── scottTiger.xml
├── ivy.xml
├── liquibase.properties
└── liquibase.sh

Run as follows

./liquibase.sh update

liquibase.sh

Apache ivy can be used as an executable jar.

#!/bin/bash
java -jar $HOME/.ant/lib/ivy.jar \
     -error \
     -ivy ivy.xml \
     -main liquibase.integration.commandline.Main \
     -args $@

ivy.xml

<ivy-module version="2.0">
    <info organisation="com.myspotontheweb" module="demo"/>
    <dependencies>
        <dependency org="org.liquibase" name="liquibase-core" rev="latest.release" conf="default"/>
        <dependency org="com.h2database" name="h2" rev="latest.release" conf="default"/>
    </dependencies>
</ivy-module>

liquibase.properties

url=jdbc:h2:./db/scottTiger
driver=org.h2.Driver
username=user
password=pass
changeLogFile=changesets/scottTiger.xml
logLevel=info
like image 3
Mark O'Connor Avatar answered Oct 21 '22 08:10

Mark O'Connor