3

我正在尝试将 golang 应用程序部署到应用程序引擎。现在我可以通过我的 mac 上的 gcloud CLI 来完成它,这工作正常(运行 gcloud app deploy app.yaml)。但是,我在 Bitbucket Pipelines 上收到以下错误:

+ gcloud --quiet --verbosity=error app deploy app.yaml --promote
You are about to deploy the following services:
 - some-project/default/20171128t070345 (from [/go/src/bitbucket.org/acme/some-app/app.yaml])
     Deploying to URL: [https://project-url.appspot.com]

Beginning deployment of service [default]...
ERROR: (gcloud.app.deploy) Staging command [/tmp/google-cloud-sdk/platform/google_appengine/goroot/bin/go-app-stager /go/src/bitbucket.org/acme/some-app/app.yaml /tmp/tmpLbUCA5] failed with return code [1].

------------------------------------ STDOUT ------------------------------------
------------------------------------ STDERR ------------------------------------
2017/11/28 07:03:45 failed analyzing /go/src/bitbucket.org/acme/some-app: cannot find package "github.com/gorilla/context" in any of:
    ($GOROOT not set)
    /go/src/github.com/gorilla/context (from $GOPATH)
GOPATH: /go
--------------------------------------------------------------------------------

这是我的 bitbucket-pipelines.yaml 内容:

image: golang:onbuild

pipelines:
  branches:
    develop:
    - step:
        script: # Modify the commands below to build your repository.
          # Downloading the Google Cloud SDK
          - curl -o /tmp/google-cloud-sdk.tar.gz https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-155.0.0-linux-x86_64.tar.gz
          - tar -xvf /tmp/google-cloud-sdk.tar.gz -C /tmp/
          - /tmp/google-cloud-sdk/install.sh -q
          - source /tmp/google-cloud-sdk/path.bash.inc
          - PACKAGE_PATH="${GOPATH}/src/bitbucket.org/${BITBUCKET_REPO_OWNER}/${BITBUCKET_REPO_SLUG}"
          - mkdir -pv "${PACKAGE_PATH}"
          - tar -cO --exclude-vcs --exclude=bitbucket-pipelines.yml . | tar -xv -C "${PACKAGE_PATH}"
          - cd "${PACKAGE_PATH}"
          - go get -v
          - go get -u github.com/golang/dep/cmd/dep
          - go build -v
          - go install
          - go test -v
          - echo $GOOGLE_CLIENT_SECRET | base64 --decode --ignore-garbage > ./gcloud-api-key.json
          - gcloud auth activate-service-account --key-file gcloud-api-key.json
          - gcloud components install app-engine-go
          #- GOROOT="/tmp/go"
          # Linking to the Google Cloud project
          - gcloud config set project $CLOUDSDK_CORE_PROJECT
          # Deploying the application
          - gcloud --quiet --verbosity=error app deploy app.yaml --promote
          - echo $GCLOUD_API_KEYFILE | base64 --decode --ignore-garbage > ./gcloud-api-key.json
          #- gcloud auth activate-service-account --key-file gcloud-api-key.json

而且,虽然它不应该是一个问题,因为部署到云工作正常,我的 app.yaml 文件也是:

runtime: go
api_version: go1

handlers:
- url: /.*
  script: _go_app


nobuild_files:
- vendor

skip_files:
- |
  ^(.*/)?(
  (#.*#)|
  (.*\.mapping)|
  (.*\.po)|
  (.*\.pot)|
  (.*\.py[co])|
  (.*\.sw?)|
  (.*\.yaml)|
  (.*_test\.go)|
  (.*~)|
  (LICENSE)|
  (Makefile.*)|
  (\..*)|
  (vendor/.*)|
  )$

我相当确定我的问题是我的 bitbucket yaml 文件或我开始使用的 docker 图像的方式,但我被卡住了。有什么想法吗?

4

1 回答 1

1

github.com/gorilla/context仅在您的测试文件中使用?

go get, 默认情况下不会获取测试依赖项。

您可以专门添加go get github.com/gorilla/context到您的管道脚本。

于 2017-11-29T01:37:50.970 回答