0

I am creating bitbucket pipeline in which I am using shell script which will take environment name. Based on environment name I am deploying the code to different environments.

pipelines:
  default:
    - step:
        script:
          # Install Google Cloud SDK
          - export CLOUDSDK_CORE_DISABLE_PROMPTS=1
          # Google Cloud SDK is pinned for build reliability. Bump if the SDK complains about deprecation.
          - SDK_VERSION=127.0.0
          - SDK_FILENAME=google-cloud-sdk-${SDK_VERSION}-linux-x86_64.tar.gz
          - curl -O -J https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/${SDK_FILENAME}
          - tar -zxvf ${SDK_FILENAME} --directory ${HOME}
          - export PATH=${PATH}:${HOME}/google-cloud-sdk/bin
          # Install Google App Engine SDK
          - GAE_PYTHONPATH=${HOME}/google_appengine
          - export PYTHONPATH=${PYTHONPATH}:${GAE_PYTHONPATH}
          - python scripts/fetch_gae_sdk.py $(dirname "${GAE_PYTHONPATH}")
          - echo "${PYTHONPATH}" && ls ${GAE_PYTHONPATH}
          # Install app & dev dependencies, test, deploy, test deployment
          - pip --quiet install -r requirements.txt -t lib/
          - echo "key = '${GOOGLE_API_KEY}'" > api_key.py
          - python test_main.py
          - echo ${GOOGLE_CLIENT_SECRET} > client-secret.json
          - gcloud auth activate-service-account --key-file client-secret.json
          - ./deploy.sh dev service-test here

I am getting following error:

    + ./deploy.sh dev test-service
bash: ./deploy.sh: Permission denied
Dan Cornilescu
  • 39,470
  • 12
  • 57
  • 97
Vikram Shinde
  • 1,022
  • 6
  • 17
  • Does the userid executing the pipeline have read and execute permissions for `./deploy.sh` (and read/execute permissions for all its ancestor directory path)? – Dan Cornilescu Feb 07 '18 at 18:25
  • @DanCornilescu, how to check and give read/execute permission to deploy.sh on bitbucket pipeline ? – Vikram Shinde Feb 08 '18 at 09:39
  • From its path it appears to exist in your app dir. `ls -l ./deploy.sh`, `chmod u+x ./deploy.sh`. An alternative is to ignore it's not executable and run it explicitly from bash: `bash ./deploy.sh dev service-test here`. – Dan Cornilescu Feb 08 '18 at 14:54
  • @DanCornilescu I am using bitbucket pipeline to deploy on Google App Engine. How can change the mode in the path ? – Vikram Shinde Feb 12 '18 at 11:30
  • I'm not saying to do it in bitbucket, I mean this: https://stackoverflow.com/questions/18960689/ubuntu-says-bash-program-permission-denied – Dan Cornilescu Feb 12 '18 at 14:53

1 Answers1

1

You just need to add "- bash" before the actual bash script is called. In your case it'd be:

pipelines:
  default:
    - step:
        script:
          # Install Google Cloud SDK
          - export CLOUDSDK_CORE_DISABLE_PROMPTS=1
          # Google Cloud SDK is pinned for build reliability. Bump if the SDK complains about deprecation.
          - SDK_VERSION=127.0.0
          - SDK_FILENAME=google-cloud-sdk-${SDK_VERSION}-linux-x86_64.tar.gz
          - curl -O -J https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/${SDK_FILENAME}
          - tar -zxvf ${SDK_FILENAME} --directory ${HOME}
          - export PATH=${PATH}:${HOME}/google-cloud-sdk/bin
          # Install Google App Engine SDK
          - GAE_PYTHONPATH=${HOME}/google_appengine
          - export PYTHONPATH=${PYTHONPATH}:${GAE_PYTHONPATH}
          - python scripts/fetch_gae_sdk.py $(dirname "${GAE_PYTHONPATH}")
          - echo "${PYTHONPATH}" && ls ${GAE_PYTHONPATH}
          # Install app & dev dependencies, test, deploy, test deployment
          - pip --quiet install -r requirements.txt -t lib/
          - echo "key = '${GOOGLE_API_KEY}'" > api_key.py
          - python test_main.py
          - echo ${GOOGLE_CLIENT_SECRET} > client-secret.json
          - gcloud auth activate-service-account --key-file client-secret.json
          - gcloud auth activate-service-account --key-file client-secret.json
          - bash ./deploy.sh dev service-test here
Miller G.
  • 178
  • 6