I have developed an Azure DevOps (AzDO) task, it’s working great. https://github.com/LanceMcCarthy/akeyless-extension-azdo
However, there’s one last showstopper problem, my task’s output variables are not available in subsequent tasks.
Description
As a task author, you can predefine some output variables as part of your task manifest. You are also allowed to set what’s a called an “ad-hoc” output variable form your code (or script if its a powershell task)
Here’s the method:
SDK.setVariable(outputVarName, varValue, true, true);
Here is a real place where I use it, but here’s what the method parameters are supposed to do:
According to the SDK’s documentation, using this method should provide me with some outputs:
Although the doc example uses the script approach, that’s the same as using the SDK’s
setVariable()
method.
Problem
Okay, now onto the problem. I am expecting that if I run this code in my extension:
SDK.setVariable('MY_COOL_OUTPUT', 'hello world', true, true);
and the task’s name was:
I would expect the following to be available in the subsequent tasks using the output variable task-name.output-var-name
syntax (as explained in this doc section).
$myValue = $(MY_TASK_NAME.MY_COOL_OUTPUT);
However, I get the following error:
MY_TASK_NAME.MY_COOL_OUTPUT : The term 'MY_TASK_NAME.MY_COOL_OUTPUT' 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.
I know for a fact that using the name, as entered in the task settings, works because I do it in a previous script-only steps:
Further Investigation
I have tried a few different things, but no success. It’s as if I have the task name wrong, but I’ve tried many different spelling and they never match.
Have you developed an extension before that uses ad-hoc outputs? If yes, how do the subsequent tasks reference that variable?
Thank you!