I've a git repository on our Azure Devop. I publish the application on firebase everytime it is published on master.
Here is my current YML:
trigger:
- master
pool: vmImage: ubuntu-latest
steps:
- task: NodeTool@0 inputs:
versionSpec: '14.x' displayName: 'Install Node.js'
- task: CmdLine@2 inputs:
script: 'npm install -g firebase-tools'
workingDirectory: '$(Agent.ToolsDirectory)' displayName: 'install firebase tools'
- script: |
npm install
npm run build displayName: 'npm install and build'
- script: |
cd functions
npm install displayName: 'install functions dependencies'
- task: CmdLine@2 inputs:
script: 'firebase deploy --token "$(FIREBASE_TOKEN)" -m "$(Build.BuildNumber)"' displayName: 'firebase publish -m "$(Build.BuildNumber)"'
I recently noticed the following warning in my jobs:
! Authenticating with a
login:citoken is deprecated and will be removed in a future major version offirebase-tools. Instead, use a service account key withGOOGLE_APPLICATION_CREDENTIALS: https://cloud.google.com/docs/authentication/getting-started
The article is not quite clear, it talks more about how to access stuff within code, not directly with firebase deploy. After some search I was able to find multiple example with a JSON file.
But in my case, with a git repository and a pipeline, I'm not sure how to proceed:
- I don't want to store in the git repository a file with the credentials, it has to be some kind of secret stored in azure devop.
- Azure Devop doesn't allow me to store file, only string
So, if I've generated this json, how can I use it? Or is there another method?
Here is what you need to do.
You go to your Firebase console, open the project you want, and then do the following steps
p.s.: Here is a image showing where each step is located. Sorry for the image in Portuguese , I'm from Brazil.
Then you will create a variable named
GOOGLE_APPLICATION_CREDENTIALSin your Azure DevOps pipeline with the content of the json file you just downloaded. Just like the images bellow.And the last step is to include the deploy step in your pipeline. It will look like these:
Assuming that your project is correctly set up with the
.firebasercandfirebase.jsonfiles, everything should work just fine.p.s.: Remember to mark the
Keep this value secretcheckbox in your Azure DevOps variable after everything is set up, to leaving public your admin privates keys from the json file.