未找到处理程序引用的静态文件:build/index.html -Bitbucket Pipeline React App Engine
Static file referenced by handler not found: build/index.html -Bitbucket Pipeline React App Engine
我的 Bitbucket CI/CD 管道有问题。管道本身运行良好,但当我尝试访问它时应用程序被破坏了。管道部署 React App Engine Node.js 应用程序。当我访问该站点时出现问题。这是我在 Google 记录“未找到处理程序引用的静态文件:build/index。html”。
中收到的错误
如果我手动部署应用程序,我没有任何问题并且应用程序运行良好。仅当部署发生在 bitbucket 管道中时才会出现此应用程序错误。
这是app.yaml
runtime: nodejs12
handlers:
# Serve all static files with url ending with a file extension
- url: /(.*\..+)$
static_files: build/
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
如有任何帮助,我们将不胜感激。非常感谢。
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/
请注意,我还没有对此进行测试。
我的 Bitbucket CI/CD 管道有问题。管道本身运行良好,但当我尝试访问它时应用程序被破坏了。管道部署 React App Engine Node.js 应用程序。当我访问该站点时出现问题。这是我在 Google 记录“未找到处理程序引用的静态文件:build/index。html”。
中收到的错误如果我手动部署应用程序,我没有任何问题并且应用程序运行良好。仅当部署发生在 bitbucket 管道中时才会出现此应用程序错误。
这是app.yaml
runtime: nodejs12
handlers:
# Serve all static files with url ending with a file extension
- url: /(.*\..+)$
static_files: build/
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
如有任何帮助,我们将不胜感激。非常感谢。
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/
请注意,我还没有对此进行测试。