简体   繁体   English

Firebase 部署在控制台中有效,但在 bitbucket 管道中无效

[英]Firebase deploy works in the console but not in bitbucket pipeline

I'm trying to deploy my webapp to firebase hosting through a bitbucket pipeline, It's not deploying correctly in the pipeline but in the console it works no problem.我正在尝试通过 bitbucket 管道将我的 webapp 部署到 firebase 托管,它没有在管道中正确部署,但在控制台中它没有问题。 This is what I do in the console:这就是我在控制台中所做的:

npm run build
firebase login:ci
firebase deploy --project $PROJECT_NAME

In the pipeline I'm running this YAML script:在管道中,我正在运行这个 YAML 脚本:

image: node:10.15.3

pipelines:
  default:
        - step:
            name: Install and Build App
            caches:
              - node
            script:
              - npm install
              - CI=false npm run build
            artifacts:
              - build/
        - step:
            name: Deploy App to Firebase
            deployment: production
            script:
              - pipe: atlassian/firebase-deploy:0.6.0
                variables:
                  KEY_FILE: $KEY_FILE
                  PROJECT_ID: $PROJECT_ID

I think it might have to do with the .firebaserc but I'm not sure.我认为这可能与 .firebaserc 有关,但我不确定。 this is the .firebaserc:这是 .firebaserc:

firebase target:apply hosting $PROJECT_ID $DOMAIN

Maybe someone can shed some light on why this isn't working, I'm new to pipeline scripts and I don't really see the issue, it succeeds in deploying to firebase hosting but It's not working at all on the actual domain.也许有人可以解释为什么这不起作用,我是管道脚本的新手,我并没有真正看到这个问题,它成功部署到 firebase 托管,但它在实际域上根本不起作用。

When you run the command firebase login:ci that should generate a TOKEN, you add that token in Bitbucket in your Repository Settings > Repository Variables.当您运行应该生成令牌的命令 firebase login:ci 时,您将该令牌添加到 Bitbucket 中的 Repository Settings > Repository Variables 中。 What ever name you choose should match your pipeline.您选择的任何名称都应与您的管道相匹配。 In my example I use FIREBASE_TOKEN_CI.在我的示例中,我使用 FIREBASE_TOKEN_CI。 When I commit my changes to bitbucket, it runs the pipeline, builds and deploys.当我将更改提交到 bitbucket 时,它会运行管道、构建和部署。

You can always modify your script in your package.json so in your cli you can run npm run build:prod like you would run npm run start , etc and use the build:prod in the yml.你总是可以在你的 package.json 中修改你的脚本,所以在你的 cli 中你可以像运行npm run start一样运行npm run build:prod ,并在 yml 中使用 build:prod 。 here is an example:这是一个例子:

"scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build:prod": "ng build --prod=true"
    }

CODE BELOW is a pipeline.yml I use for Ionic/Angular NOTE: Artifacts is the folder your build files are generated after running build.下面的代码是我用于 Ionic/Angular 的 pipeline.yml 注意:Artifacts 是您的构建文件在运行构建后生成的文件夹。 Angular is called dist, so you might use dist/. Angular 被称为 dist,所以你可以使用 dist/。 My example uses www/** that is Ionics build output.我的示例使用 www/** 即 Ionics 构建输出。 You have some CI=False in your example, I have not seen that nor use that and my project builds and deploys.你的例子中有一些 CI=False ,我没有看到也没有使用它,我的项目构建和部署。 My second script is for cloud functions我的第二个脚本是针对云函数的

- cd functions
   - npm install
   - cd ..

you can omit that part if you don't have functions.如果你没有函数,你可以省略那部分。 I have recently had a error about OAuth and I had to generate a new token with login:ci and replace my token, and it was working again for deploy.我最近遇到了一个关于 OAuth 的错误,我不得不用 login:ci 生成一个新令牌并替换我的令牌,它再次用于部署。 Hope this helps anyone.希望这可以帮助任何人。 I had problems at first also and found a working format that I can adapt to other frameworks.起初我也遇到了问题,并找到了一种可以适应其他框架的工作格式。


image: node:10.15.3

pipelines:
 default:
   - step:
       name: Install, Build
       caches:
         - node
       deployment: test
       script:
         - npm install
         - npm run build:prod
       artifacts: 
         - www/**
   - step:
       name: Deploy to Firebase
       deployment: production
       script:
         - cd functions
         - npm install
         - cd ..
         - pipe: atlassian/firebase-deploy:0.3.4
           variables:
             FIREBASE_TOKEN: '$FIREBASE_TOKEN_CI'

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

相关问题 在 Bitbucket 管道中部署 Firebase Cloud function 时出错 - Error when I deploy Firebase Cloud function in Bitbucket pipeline Bitbucket 管道 + Firebase 托管 - Bitbucket Pipeline + Firebase hosting Bitbucket Pipeline部署到Elasticbeanstalk - 上传问题 - 没有反映出任何变化 - Bitbucket Pipeline deploy to Elasticbeanstalk - Upload issue - No changes reflected 使用Bitbucket Pipeline和AWS CodeDeploy自动部署Angular 4 App - Auto Deploy Angular 4 App using Bitbucket Pipeline and AWS CodeDeploy BitBucket管道 - 使用node / gulp / git ftp构建和部署 - BitBucket Pipeline - Build and deploy using node / gulp / git ftp 如何在 Firebase 控制台上部署 ionic 4 应用程序? - How to deploy ionic 4 app on firebase console? Firebase服务失败但部署工作正常 - Firebase serve fails but deploy works fine 需要使用 bitbucket-pipeline 将 Node.js docker 镜像部署到 AWS Elastic Beanstalk - Need to deploy Node.js docker image to AWS Elastic Beanstalk using bitbucket-pipeline 在firebase部署之后,“array.forEach不是一个函数”,但可以在firebase服务上运行 - “array.forEach is not a fuction” after firebase deploy but works on firebase serve Bitbucket 管道 mongodb - Bitbucket pipeline mongodb
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM