I have a dev.json file inside my folder that I use to authenticate my account in CLI and it sits at the root folder of Jenkins.
When I run my pipeline everything works fine until I get this error:
Failed to load function definition from source: FirebaseError: Failed to load function definition from source: Failed to generate manifest from function source: SyntaxError: /var/jenkins_home/workspace/storm-backend_jenkins_2/functions/lib/utils/dev.json: Expected property name or '}' in JSON at position 2
Have you ever seen something like this?
This is my pipeline in Jenkinsfile.
pipeline {
agent any
tools {
nodejs '19.4.0'
}
environment {
API_KEY_OPEN_DOTA = credentials('API_KEY_OPEN_DOTA')
FORTNITE_API_KEY = credentials('FORTNITE_API_KEY')
CLIENT_ID = credentials('CLIENT_ID')
STORM_TOKEN = credentials('STORM_TOKEN')
STRIPE_KEY = credentials('STRIPE_KEY')
FIREBASE_LOGIN_TOKEN = credentials('FIREBASE_LOGIN_TOKEN')
DEV_JSON_SERVICE = credentials('DEV_JSON_SERVICE')
GOOGLE_APPLICATION_CREDENTIALS = "./dev.json"
FIREBASE_TOKEN = credentials('FIREBASE_LOGIN_TOKEN')
}
stages {
stage('setup') {
steps {
sh 'echo API_KEY_OPEN_DOTA=\"$API_KEY_OPEN_DOTA\" >> .env'
sh 'echo FORTNITE_API_KEY=\"$FORTNITE_API_KEY\" >> .env'
sh 'echo CLIENT_ID=\"$CLIENT_ID\" >> .env'
sh 'echo STORM_TOKEN=\"$STORM_TOKEN\" >> .env'
sh 'echo TESTING_ENDPOINT=\"TRUE\" >> .env'
sh 'echo DEPLOYED=\"FALSE\" >> .env'
sh 'echo GOOGLE_APPLICATION_CREDENTIALS=$GOOGLE_APPLICATION_CREDENTIALS >> .env'
sh 'cp ./.env ./functions'
sh 'cp ../../firebase_keys/dev.json ./functions/src/utils'
sh 'echo $DEV_JSON_SERVICE >> dev.json'
sh 'ls'
}
}
stage('installing npm packages') {
steps {
sh 'npm install'
sh 'npm --prefix ./functions install ./functions'
sh 'npm install -g firebase-tools'
}
}
stage('jenkins') {
when {
branch 'jenkins_2'
}
steps {
sh 'cd ./functions && firebase emulators:start --token \"$FIREBASE_TOKEN\" --project stormdevelopment-64ea9 --import ~/firestore/2023-01-15T10:30:05_94356'
}
}
}
}
That’s so strange because when I run the same command outside of Jenkins that file is JSON valid. Maybe it has something to do with the way I’m creating the JSON file in the pipeline?
Hi, I’ve already tried that but the emulator continue to tells me that I don’t have the permission because I’m not logged. Even though as you can see from my pipeline code I insert the “token” flag when I use the command to start the tests.
I’ve followed that tutorial