使用shell部署Google App Engine的Bitbucket管道

时间:2018-02-07 17:18:21

标签: python google-app-engine bitbucket-pipelines

我正在创建bitbucket管道,我在其中使用将采用环境名称的shell脚本。 根据环境名称,我将代码部署到不同的环境中。

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

我收到以下错误:

    + ./deploy.sh dev test-service
bash: ./deploy.sh: Permission denied

1 个答案:

答案 0 :(得分:1)

你只需要添加" - bash"在调用实际的bash脚本之前。在你的情况下,它是:

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