0

I have a deployment group job which executes a PowerShell script and returns a value.

the output of the PowerShell task in azure DevOps console -

2019-12-31T16:57:11.2860409Z ##[command]"C:\windows\System32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command ". 'C:\AzurePiplinesAgent_Extension\_work\_temp\ff9189f4-abc8-476f-868e-cb6e2c502d22.ps1'"
2019-12-31T16:59:26.5696135Z **tdeJTKF9pono3xkdYnKVcTEyID9cJCJqGb0xWaGAhjg**
2019-12-31T16:59:26.6240777Z ##[section]Finishing: install-configure-key

I want to assign this value to an output variable and use that in the next task in the same deployment variable.

1st task, I have configured the output variable

enter image description here

and the referring this in the subsequent task:

enter image description here

I am getting the below error message:

The term 'key.VariableName' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

can someone help me with this?

James Z
  • 12,209
  • 10
  • 24
  • 44
krishna
  • 49
  • 2
  • 6
  • Update your question to include the script that's supposed to set the output variable. Did you read the documentation on output variables? – Daniel Mann Dec 31 '19 at 17:13
  • I am reading a log file for retrieving a password from a file . This is the powershell script which i am excuting from azure devops pipeline $key = ((Get-Content $secretlogfile | Where-Object { $_.Contains("KEY") }).Split('=')[-2]).replace(" ","") Write-Host $key and i am trying to store this $key to the output variable which i am going to use in the subsequent task for storing this in the azure key vault. – krishna Dec 31 '19 at 19:51
  • Did you try looking up the documentation on the syntax for setting pipeline variables? – Daniel Mann Dec 31 '19 at 20:06
  • Yes, i looked at the documentation, couldn't find anything working, tried https://stackoverflow.com/questions/57485621/share-variables-across-stages-in-azure-devops-pipelines, https://learn.microsoft.com/en-us/azure/devops/pipelines/process/variables?view=azure-devops&tabs=classic%2Cbatch – krishna Dec 31 '19 at 20:19
  • 1
    I was able to fix the issue., used this line for storing the output variable -> Write-Output "##vso[task.setvariable variable=value;isOutput=true]$key" the output variable name i used was key and in the subsequent task i used $password = '$(key.value)' and it worked. – krishna Dec 31 '19 at 22:53
  • 1
    @krishna Glad you were able to figure it out. Please summarize your findings as an answer below so it can help others in the community who might have similar questions. Thanks! – Bhargavi Annadevara Jan 04 '20 at 17:27

0 Answers0