I want to update the build version number at the firebase, so I am running a firebase command through a bash file that looks like this-
sudo firebase database:set /build_version --data '"1.1.13.12.34"' --project <PROJECT_ID>
This is working fine.
But, I want to pass the version number dynamically, so I would like to write this command something like that-
VERSION=<ANY_NUMBER>
sudo firebase database:set /build_version --data $VERSION --project <PROJECT_ID>
But passing dynamic variable giving me an error-
Error: Unexpected error while setting data: FirebaseError: HTTP Error:
400, Invalid data; couldn't parse JSON object, array, or value.
I have read that firebase doesn't allow some special character and we cannot wrap firebase data in double-quotes
At firebase, "build_version" is not a JSON Object. It's a single variable.
My real-time database structure is looking like this-
Can anyone suggest how can I pass the dynamic data to the firebase database command?
Sharing just a trick
If firebase doesn't allow using special characters then you can just put any string (let's say BUILD_VERSION) instead of your shell script variable $VERSION and then using shell script syntax just search and replace that string with your build version before running firebase command.
In the end, you can again replace the build version with the string BUILD_VERSION.
Related
I want to run CMD from vb.net and then run a curl command with it. I have followed the options in this question How to run DOS/CMD/Command Prompt commands from VB.NET? already but it doesn't work for me.
I am running this command via vb.net.
Process.Start("cmd /k", "curl --location --request GET http://ipaddress:port/")
The expected output should be Hello-World. But I get an error that "
System can not find the file specified.
However when I am running the same command in CMD then it works fine.
Is there any way to make it work?
I have seen the other methods like httpwebrequest and already tried them and it works but I do not want to use those methods as I have many other complex curl commands and do not want to convert them to lengthy httprequests.
Please guide me with the explained problem.
Thank you in advance.
Best Regards
When you run curl within your command prompt, what this does behind the scenes is prefix the respective environment variable for you. You can verify this by doing the following:
Use the Shortcut Key Windows Key + s to bring up the search box
Type in Environment Variables and pick the top result
Click on the Environment Variables button towards the bottom
Inspect the Path (or PATH) variable for where your curl.exe application lives
For my operating system, the application lives at C:\Windows\System32\curl.exe.
Once you get the fully qualified filename, there is one other error in your code. You are attempting to pass the /k in the filename argument of Process.Start. Instead, pass it in the arguments argument.
Here is an example:
Dim curlApplicationPath = IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), "curl.exe")
Dim arguments = $"/k {curlApplicationPath} --location --request GET http://ipaddress:port/"
Process.Start("cmd", arguments)
I'm posting to see if someone can point me in the right direction. I've been trying to get this working for a few days now and I'm at a dead end.
I have tried to remove " around the variables and remove variables completely. I have tried to run this in Azure Cloud Shell, WSL, and PowerShell as a .ps1 script. However, I continue to get the same type of errors.
Here is the script.
Here is the error I am getting.
validation error: Parameter 'resource_group_name' must conform to the
following pattern: '^[-\w\._\(\)]+$'. ' not recognized. ' not found. Check the spelling and casing and
try again.
If I run a one liner with out variables I get this error.
az vm create: error: local variable 'images' referenced before
assignment
Any help would be greatly appreciated. Thank you!
So for the first error, looks like the create VM is initiating to fast to recognize the new resource group.
For the image you need to use the full URN MicrosoftWindowsServer:WindowsServer:2016-Datacenter:latest
First, it's a bash script and the variable definition is different between Windows and Linux. So I suggest you run the script in the Azure Cloud Shell with bash mode or the WSL when it's a bash script.
Second, the error shows the resource group name does not meet the Naming rules and restrictions for Azure resources, you need to read the document to check if the group name is right.
So I have found out that the issue was. It was how VS Code formats bash scripts. I'm not exactly sure how VS Code is formatting but I think it might have something to do with ASCII. I recreated the script in Azure CLI with nano and it runs fine as a bash shell script. Thanks everyone for your help.
In our release pipeline, we have a console app that performs a function which generates an encryption key and outputs it to STDOUT. We need to be able to use this value in a variable during deployment (updating a configuration file with the results from the console app). We've tried using the Output Variables option in the command line task in Azure Devops but unfortunately we need it in a different format... and it just doesn't seem to work as expected.
E.g. Our cmd line tool outputs 908321093RANDOMLYGENERATEDKEY3422543 to STDOUT
The name in our config file for that key is something like Settings.Security.OurKey however the output variable in the command line task does not allow periods (.) and as such is set to SettingsSecurityOurKey... we've also tried SETTINGS_SECURITY_OURKEY, but the variable value is never set by the task.
Is it possible to somehow set the Azure Devops variable to the value of the output variable from the command line or a powershell script? Something like:
set $(Settings.Security.OurKey) = SettingsSecurityOurKey
Or is there a simpler method of achieving this? It seems like it shouldn't be that difficult..
This sounds like a Powershell issue rather than an issue with Azure DevOps.
# Variable name with special characters
$VariableName.That.Contains.Periods # This will NOT work.
${VariableName.That.Contains.Periods} # This will work.
Refer this for more information: https://blog.danskingdom.com/accessing-powershell-variables-with-periods-in-their-name/
If you want a PowerShell variable to contain the standard output from a command, just assign it:
$yourVariableName = your_command_that_writes_to_stdout
If the output is only one line, the PowerShell variable will contain a single string; otherwise it will contain an array.
I am following the docs here and it says:
The simplest way for applications to authenticate to a Google Cloud Platform API service is by using Application Default Credentials (ADC). Services using ADC first search for credentials within a GOOGLE_APPLICATION_CREDENTIALS environment variable; Google Cloud recommends you set this environment variable to point to your service account key file (the .json file downloaded when you created a service account key, as explained in Set Up a Service Account.
And it says to use this command:
$ export GOOGLE_APPLICATION_CREDENTIALS=<path_to_service_account_file>
In the Google Shell, I have attempted this:
<INSERT_SOMETHING>"~$ $ export GOOGLE_APPLICATION_CREDENTIALS=</Users/grantespanet/Downloads/myfile.json>
But I get this error: -bash: syntax error near unexpected token newline
I have also tried this:
<INSERT_SOMETHING>:~$ $ export GOOGLE_APPLICATION_CREDENTIALS=/Users/grantespanet/Downloads/myfile.json
but nothing happens
I know the command is pointing to the correct file location. How can I successfully Authenticate Application Default Credentials?
The command you are executing is a variable assignment. Variable GOOGLE_APPLICATION_CREDENTIALS is given the value that follows the = sign.
The export keyword has the effect of making this variable available to child processes of the shell you are executing it from. In plain terms, it means any program you launch from the shell will have a copy of that variable (with its value) and can use it.
It is entirely normal for that command to produce no visible result or output.
The instructions you have probably require you to launch other commands after this one, which will use this value. Try performing the next steps.
I am trying to make use of the uuid library within a shell command invoked by an AWS data pipeline. It seems like the uuid function works fine, but when I try to pass this value to a variable, the data is lost.
A snippet of my testing script below:
sudo yum -y install uuid-devel
myExportId=$(uuid)
echo 'myExportId:' $myExportId
uuid
When I look at the activity log for the pipeline I see that the uuid function seems to be working, but the variable does not seem to contain anything?
myExportId:
b6cf791a-1d5e-11e6-a581-122c089c2e25
I notice this same behavior with other local variables in my scripts. Am I expressing these incorrectly?
My pipeline parameters are working fine within the script, so no issues there.
Shortly after posting this I realized that I had encoded some of the above steps in subshells within my pipeline definition. It can be difficult debugging shell scripts embedded within JSON, so I think I will move on to using the scriptUri parameter pointing to a bash file.