【问题标题】:Static file referenced by handler not found: build/index.html -Bitbucket Pipeline React App Engine找不到处理程序引用的静态文件:build/index.html -Bitbucket Pipeline React App Engine
【发布时间】:2021-03-19 10:25:09
【问题描述】:

我的 Bitbucket CI/CD 管道存在问题。管道本身运行良好,但是当我尝试访问它时应用程序被破坏了。该管道部署了一个 React App Engine Node.js 应用程序。当我访问该站点时,问题就来了。这是我在 Google Logging “找不到处理程序引用的静态文件:build/index.html”中收到的错误。

如果我手动部署应用程序,我没有任何问题,并且应用程序运行良好。仅当部署发生在 bitbucket 管道中时才会发生此应用程序错误。

这里是 app.yaml

runtime: nodejs12
handlers:
  # Serve all static files with url ending with a file extension
  - url: /(.*\..+)$
    static_files: build/\1
    upload: build/(.*\..+)$
  # Catch all handler to index.html
  - url: /.*
    static_files: build/index.html
    upload: build/index.html

这里是 bitbucket-pipelines.yml

pipelines:
  branches:
    master:
      - step:
          name:  NPM Install and Build
          image: node:14.15.1
          script:
            - npm install
            - unset CI
            - npm run build
      - step:
          name: Deploy to App Engine
          image: google/cloud-sdk
          script:
            - gcloud config set project $GCLOUD_PROJECT
            - 'echo "$GOOGLE_APPLICATION_CREDENTIALS" > google_application_credentials.json'
            - gcloud auth activate-service-account --key-file google_application_credentials.json
            - gcloud app deploy app.yaml

任何帮助将不胜感激。非常感谢。

【问题讨论】:

  • 这个错误是在部署过程中出现还是部署正确你在尝试使用它时遇到错误?
  • @vitooh 它部署正确。这是我在尝试访问网站时在 Google Logging 中遇到的错误
  • @vitooh 我改写了我的帖子以澄清问题

标签: node.js reactjs google-app-engine bitbucket-pipelines


【解决方案1】:

Bitbucket 管道不会在步骤之间保存工件。您需要在构建步骤中声明一个工件配置,以便您可以在部署步骤中引用它。像这样的:

pipelines:
  branches:
    master:
      - step:
          name:  NPM Install and Build
          image: node:14.15.1
          script:
            - npm install
            - unset CI
            - npm run build
          artifacts: # Declare artifacts here for later steps
            - build/**
      - step:
          name: Deploy to App Engine
          image: google/cloud-sdk
          script:
            - gcloud config set project $GCLOUD_PROJECT
            - 'echo "$GOOGLE_APPLICATION_CREDENTIALS" > google_application_credentials.json'
            - gcloud auth activate-service-account --key-file google_application_credentials.json
            - gcloud app deploy app.yaml

更多详情请看这里:https://support.atlassian.com/bitbucket-cloud/docs/use-artifacts-in-steps/

请注意,我没有对此进行测试。

【讨论】:

  • 我绝对需要这样做。谢谢!
猜你喜欢
  • 2021-02-03
  • 1970-01-01
  • 2013-09-23
  • 1970-01-01
  • 1970-01-01
  • 2014-11-25
  • 2021-07-10
  • 1970-01-01
  • 2020-03-19
相关资源
最近更新 更多