title: Jenkins sh run with functions
body: <p>I have the following script. Unfortunately I not able to get it run on Jenkins.</p>
  
  <pre><code>#!/bin/bash
  function pushImage () {
      local serviceName=$1
      local version=$(getImageVersionTag $serviceName)
      cd ./dist/$serviceName
      docker build -t $serviceName .
      docker tag $serviceName gcr.io/$PROJECT_ID/$serviceName:$version
      docker tag $serviceName gcr.io/$PROJECT_ID/$serviceName:latest
      docker push gcr.io/$PROJECT_ID/$serviceName
      cd ../..
  }
  
  function getImageVersionTag () {
      local serviceName=$1
  
      if [ $BUILD_ENV = "dev" ];
      then
          echo $(timestamp)
      else
          if [ $serviceName = "api" ];
          then
              echo $(git tag -l --sort=v:refname | tail -1 | awk -F. '{print $1"-"$2"-"$3"-"$4}')
          else
              echo $(git tag -l --sort=refname | tail -1 | awk -F. '{print $1"-"$2"-"$3"-"$4}')
          fi
      fi
  }
  
  function timestamp () {
      echo $(date +%s%3N)
  }
  
  set -x
  ## might be api or static-content
  pushImage $1
  </code></pre>
  
  <p>I'm receiving this error on Jenkins</p>
  
  <pre><code>10:10:17 + sh push-image.sh api
  10:10:17 push-image.sh: 2: push-image.sh: Syntax error: "(" unexpected
  </code></pre>
  
  <p>I already configured Jenkins global parameter to <code>/bin/bash</code> as default shell execute environment, but still having same error.</p>
  
  <p>The main issue here in usage of functions, as other scripts that has been executed successfully don't have any.</p>
  
  <p>How this can be fixed? </p>