[英]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.