<p>I am new to VSTS and Azure Kubernetes. I am building a VSTS CD pipeline. I have added a Deploy to Kubernetes task in my pipeline. I am executing the get command and trying to store the output in the output variables (which is available at the bottom of the Deploy to kubernetes task). I have set the variable name. </p>

<p><a href="https://i.stack.imgur.com/kxqfw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kxqfw.png" alt="VSTS output variable"></a></p>

<p>I am trying to fetch the value of the above output variable. I have used command line task to set a value to the variable as mentioned below    </p>

<p><code>echo '##vso[task.setvariable variable=myStatusVar;isSecret=false;]$(myvar)'</code></p>

<p>where <code>myvar</code> is the variable, which is set in the Deploy to kubernetes task as output variable. </p>

<p>After that in another command line task, I am trying to access the <code>myStatusVar</code> variable value, but when I execute the release pipeline, it shows the message:</p>

<blockquote>
  <p>myvar command not found</p>
</blockquote>

<p>Can anyone let me know, how to use the output variable of the Deploy to kuberentes task of VSTS pipeline?  </p>

HowsTheJosh
<p>As stated in the comments your variable is 'exposed' as 'myvar.KubectlOutput'</p>

<p>the way you are able to use it in scripts differs based on type of scripting you are doing:</p>

<ul>
<li>Batch script: %MYVAR_KUBECTLOUTPUT% </li>
<li>PowerShell script: $env:MYVAR_KUBECTLOUTPUT</li>
<li>Bash script: $MYVAR_KUBECTLOUTPUT</li>
<li>Azure Devops 'designer view': $(myvar.KubectlOutput)</li>
</ul>

<p>For more details on this see the documentation on using variables in Azure DevOps: <a href="https://learn.microsoft.com/en-us/azure/devops/pipelines/process/variables?view=azure-devops&amp;tabs=yaml%2Cbatch" rel="noreferrer">https://learn.microsoft.com/en-us/azure/devops/pipelines/process/variables?view=azure-devops&amp;tabs=yaml%2Cbatch</a></p>
