title: Running liquibase update from script in jenkins pipeline
body: <p>I'm trying to set up a Jenkins pipeline which will run a liquibase update whenever something is pushed to the master branch. The liquibase runner plugin for Jenkins has a security risk and therefore, I can't install it and run liquibase updates from that.</p>
  <p>My liquibase*  file (the bash script) is in my repository at the following path
  <code>/repo/liquibase/liquibase/liquibase*</code></p>
  <p>I've set up the pipeline to run the following shell script. NOTE: I have the command set to <code>liquibase --help</code> for test purposes, but normally I'd want to run an update command.</p>
  <pre><code>export PATH=$PATH:/var/lib/jenkins/workspace/repo/liquibase
  export PATH=$PATH:/var/lib/jenkins/workspace/repo/liquibase/liquibase
  export PATH=$PATH:/var/lib/jenkins/workspace/repo/liquibase/liquibase/liquibase
  export PATH=$PATH:/var/lib/jenkins/workspace/repo/liquibase/liquibase/jre/bin
  cd liquibase
  ls -ltr
  chmod 755 liquibase/liquibase
  chmod 755 liquibase/jre/bin/java.exe
  liquibase --help
  </code></pre>
  <p>The <code>liquibase --help</code> command runs fine from the directory path /repo/liquibase in git bash. However, when I run it from Jenkins, I get the following error.</p>
  <blockquote>
  <p>/var/lib/jenkins/workspace/Database_and_Repos/liquibase/liquibase/liquibase/jre/bin/java: No such file or directory
  Build step 'Execute shell' marked build as failure</p>
  </blockquote>
  <p>My liquibase file looks like this and it is the last line in the file that is causing the error.</p>
  <pre><code>#!/usr/bin/env bash
  
  if [ ! -n &quot;${LIQUIBASE_HOME+x}&quot; ]; then
    # echo &quot;LIQUIBASE_HOME is not set.&quot;
  
    ## resolve links - $0 may be a symlink
    PRG=&quot;$0&quot;
    while [ -h &quot;$PRG&quot; ] ; do
      ls=`ls -ld &quot;$PRG&quot;`
      link=`expr &quot;$ls&quot; : '.*-&gt; \(.*\)$'`
      if expr &quot;$link&quot; : '/.*' &gt; /dev/null; then
      PRG=&quot;$link&quot;
      else
      PRG=`dirname &quot;$PRG&quot;`&quot;/$link&quot;
      fi
    done
  
  
    LIQUIBASE_HOME=`dirname &quot;$PRG&quot;`
  
    # make it fully qualified
    LIQUIBASE_HOME=`cd &quot;$LIQUIBASE_HOME&quot; &amp;&amp; pwd`
    # echo &quot;Liquibase Home: $LIQUIBASE_HOME&quot;
  fi
  
  
  # build classpath from all jars in lib
  if [ -f /usr/bin/cygpath ]; then
    CP=.
    for i in &quot;$LIQUIBASE_HOME&quot;/liquibase*.jar; do
      i=`cygpath --windows &quot;$i&quot;`
      CP=&quot;$CP;$i&quot;
    done
    for i in &quot;$LIQUIBASE_HOME&quot;/lib/*.jar; do
      i=`cygpath --windows &quot;$i&quot;`
      CP=&quot;$CP;$i&quot;
    done
  else
    if [[ $(uname) = MINGW* ]]; then
      CP_SEPARATOR=&quot;;&quot;
    else
      CP_SEPARATOR=&quot;:&quot;
    fi
    CP=.
    for i in &quot;$LIQUIBASE_HOME&quot;/liquibase*.jar; do
      CP=&quot;$CP&quot;&quot;$CP_SEPARATOR&quot;&quot;$i&quot;
    done
    CP=&quot;$CP&quot;&quot;$CP_SEPARATOR&quot;&quot;$LIQUIBASE_HOME/lib/&quot;
    for i in &quot;$LIQUIBASE_HOME&quot;/lib/*.jar; do
      CP=&quot;$CP&quot;&quot;$CP_SEPARATOR&quot;&quot;$i&quot;
    done
  fi
  
  if [ -z &quot;${JAVA_HOME}&quot; ]; then
    #JAVA_HOME not set, try to find a bundled version
    if [ -d &quot;${LIQUIBASE_HOME}/jre&quot; ]; then
      JAVA_HOME=&quot;$LIQUIBASE_HOME/jre&quot;
    elif [ -d &quot;${LIQUIBASE_HOME}/.install4j/jre.bundle/Contents/Home&quot; ]; then
      JAVA_HOME=&quot;${LIQUIBASE_HOME}/.install4j/jre.bundle/Contents/Home&quot;
    fi
  fi
  
  if [ -z &quot;${JAVA_HOME}&quot; ]; then
    JAVA_PATH=&quot;$(which java)&quot;
  
    if [ -z &quot;${JAVA_PATH}&quot; ]; then
      echo &quot;Cannot find java in your path. Install java or use the JAVA_HOME environment variable&quot;
    fi
  else
      #Use path in JAVA_HOME
      JAVA_PATH=&quot;${JAVA_HOME}/bin/java&quot;
  fi
  
  # add any JVM options here
  JAVA_OPTS=&quot;${JAVA_OPTS-}&quot;
  
  &quot;${JAVA_PATH}&quot; -cp &quot;$CP&quot; $JAVA_OPTS liquibase.integration.commandline.Main ${1+&quot;$@&quot;}
  
  </code></pre>
  <p>Has anyone run into this problem with liquibase commands in Jenkins? I've been googling all day, but haven't found much similar to this exact issue. Any help in the right direction would be great.</p>