简体   繁体   English

未找到处理程序引用的 Static 文件:build/index.html -Bitbucket Pipeline React App Engine

[英]Static file referenced by handler not found: build/index.html -Bitbucket Pipeline React App Engine

I have an issue with my Bitbucket CI/CD pipeline.我的 Bitbucket CI/CD 管道存在问题。 The pipeline itself runs fine, but the application is broken when I try to access it.管道本身运行良好,但是当我尝试访问它时应用程序被破坏了。 The pipeline deploys a React App Engine Node.js application.该管道部署了一个 React App Engine Node.js 应用程序。 The problem comes when I access the site.当我访问该站点时,问题就来了。 This is the error I receive in Google Logging "Static file referenced by handler not found: build/index.html".这是我在 Google Logging “找不到处理程序引用的静态文件:build/index.html”中收到的错误。

If I deploy the application manually, I have no issues and the application works fine.如果我手动部署应用程序,我没有问题并且应用程序工作正常。 This application error only occurs if the deployment happens in the bitbucket pipeline.仅当部署发生在 bitbucket 管道中时,才会出现此应用程序错误。

Here is the app.yaml这是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

Here is the bitbucket-pipelines.yml这是 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

Any help would be greatly appreciated.任何帮助将不胜感激。 Thank you so much.太感谢了。

Bitbucket pipelines does not save artifacts between steps. Bitbucket 管道不保存步骤之间的工件。 You need to declare an artifacts config in the build step so that you can reference it in the deploy step.您需要在构建步骤中声明一个工件配置,以便您可以在部署步骤中引用它。 Something like this:像这样的东西:

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

See here for more details: https://support.atlassian.com/bitbucket-cloud/docs/use-artifacts-in-steps/有关更多详细信息,请参见此处: https://support.atlassian.com/bitbucket-cloud/docs/use-artifacts-in-steps/

Note that I have not tested this.请注意,我没有对此进行测试。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 React.js:Heroku:错误:ENOENT:没有这样的文件或目录,stat '/app/src/client/build/index.html' - React.js: Heroku: Error: ENOENT: no such file or directory, stat '/app/src/client/build/index.html' 重命名从npm run build生成的index.html文件-Create-React-App - Rename index.html file generated from npm run build - Create-React-App React / Express - 错误:ENOENT:没有这样的文件或目录,stat '/app/build/index.html' - React / Express - Error: ENOENT: no such file or directory, stat '/app/build/index.html' Heroku ENOENT:没有这样的文件或目录,stat '/app/build/index.html' - Heroku ENOENT: no such file or directory, stat '/app/build/index.html' 404 Not Found for index.html in Google App Engine - 如何显示页面? - 404 Not Found for index.html in Google App Engine - How to get page to show up? Google App Engine,在 express/react 应用程序中部署后缓存 index.html - Google App Engine, index.html cached after deploy in express/react app Express.js 继续提供静态 index.html(React 应用程序),即使我不想要它 - Express.js keeps serving static index.html (React app) even I do not want it 使用 Express 为 React 应用程序提供服务时,从 express.static 中排除 index.html - Exclude index.html from express.static when serving React app with Express 为什么我的 API 路由在部署时发回 index.html 文件? (提供 create-react-app 构建文件的单个快速应用程序) - Why do my API routes send back the index.html file when deployed? (Single express app serving create-react-app build file) Heroku 错误 404,“ENOENT:没有这样的文件或目录,stat '/app/client/build/index.html'” - Heroku Error 404, “ENOENT: no such file or directory, stat '/app/client/build/index.html'”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM