azure-pipelines-task-lib and isOutput setVariable
Some blog posts are insightful treatises on the future of web development, some are "here's how I solved my problem". This is most assuredly the latter.
I'm writing an custom pipelines task extension for Azure Pipelines. It's written with TypeScript and the azure-pipelines-task-lib.
The pipeline needs to output a variable. Azure Pipelines does that using the setvariable
command combined with isOutput=true. This looks something like this: ##vso[task.setvariable variable=myOutputVar;isOutput=true]this is the value"
.
The bad news is that the lib doesn't presently support isOutput=true
. Gosh it makes me sad. Hopefully in future it will be resolved. But what now?
For now we can hack ourselves a workaround:
The above is effectively a wrapper for the existing setVariable
. However, once it's called into the initial implementation, setOutputVariable
then writes out the same variable once more, but this time bolting on isOutput=true
.
Finally, I've raised a PR to see if isOutput
can be added directly to the library. You can track progress on that here.