2

Im trying to setup a CI/CD pipeline but it keeps failing for my react app.

here is the script:

 image: node:latest

.deploy: &deploy
- npm install -g firebase-tools
- firebase use $FIREBASE_PROJECT_ID --token $FIREBASE_TOKEN
- yarn
- yarn build


stages:
  - deploy


deploy_preview:
  stage: deploy
  before_script:
    - *deploy
  script: 
    - firebase hosting:channel:deploy $FIREBASE_PROJECT_ID --token $FIREBASE_TOKEN
    - echo "ENVIRONMENT_URL=$(firebase hosting:channel:open live --non-interactive | tail -1 | awk '{ print $3 }')"
  rules:
    - if: $CI_PIPELINE_SOURCE == "merge_request_event"

staging:
  stage: deploy
  before_script:
    - *deploy
  only:
    - staging
  script:
    - firebase deploy -m "Pipe $CI_PIPELINE_ID Build $CI_BUILD_ID" --only hosting:staging --non-interactive --token $FIREBASE_TOKEN

production:
  stage: deploy
  before_script:
    - *deploy
  only:
    - main
  when: manual
  allow_failure: false
  script:
    - firebase deploy -m "Pipe $CI_PIPELINE_ID Build $CI_BUILD_ID" --only hosting:prod --non-interactive --token $FIREBASE_TOKEN

but I keep getting the error:

added 612 packages in 22s

34 packages are looking for funding
  run `npm fund` for details
$ firebase use $FIREBASE_PROJECT_ID --token $FIREBASE_TOKEN
error: option '--token <token>' argument missing
Cleaning up project directory and file based variables
ERROR: Job failed: exit code 

from gitlab about why the pipeline is failing

Im not sure why its complaining about the token. I do have the gitlab variables also set up correctly.

Grant Solomons
  • 181
  • 1
  • 1
  • 11

1 Answers1

2

Found out that its because the var was PROTECTED, which means only the branches that were PROTECTED would work with it

Grant Solomons
  • 181
  • 1
  • 1
  • 11