这是firebase.json文件
{
"hosting": {
"public": "build",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
}
}
这是我的.gitlab-ci.yml
:
image: tragopoulos/firebase:latest
stages:
- build
- test
- deploy
cache:
paths:
- node_modules/
key: "$CI_BUILD_REPO"
build:
stage: build
image: node
script:
- echo "# Start building App"
- npm install
- npm build
- echo "# Build successfully!"
artifacts:
expire_in: 1 hour
paths:
- "/build"
- node_modules/
test:
stage: test
image: node
script:
- echo "# Testing App"
- npm install
- CI=true npm test
- echo "# Test successfully!"
deploy-develop:
stage: deploy
environment: tragopoulos-portfolio-dev
only:
- develop
before_script:
- npm install
- npm build
script:
- echo "# Deploying App"
- firebase use tragopoulos-portfolio --token $FIREBASE_TOKEN
- firebase deploy --only hosting -m "Pipeline $CI_PIPELINE_ID Build $CI_BUILD_ID"
- echo "# Deployed successfully!"
这是错误:
我尝试了“ build”,“ / build”,“ / build /”,“ / PROJECT_NAME / build”,但没有任何效果。我也不知道如何$ echo
构建路径,因此我可以在项目中对其进行调试。在Angular中,“ dist”可以正常工作。有想法吗?
答案 0 :(得分:1)
根据评论部分的讨论,似乎在部署步骤中没有创建build
文件夹。它们很可能在不同的容器中运行。因此,firebase deploy
命令找不到必要的build
。
我会尝试从before_script
中删除.gitlab-ci.yml
,并将其步骤与script
合并为:
script:
- npm install
- npm build
- echo "# Deploying App"
- firebase use tragopoulos-portfolio --token $FIREBASE_TOKEN
- firebase deploy --only hosting -m "Pipeline $CI_PIPELINE_ID Build $CI_BUILD_ID"
- echo "# Deployed successfully!"
这样,您就可以在部署步骤中放置build
文件夹了。