I am trying to store output of a node script into an azure task variable.
Came across this question Return a value from node.js script in azure pipeline? and based on this I have created a simple yml as below. But when I run this yml, script itself is not running, whereas If I run node test.js directly without setting task variable it is working fine and I can see the output. Not sure what am I doing wrong here, can anyone please point me in the right direction. Thanks
resources:
repositories:
- repository: "testRepo"
type: git
name: project/repo
trigger: none
stages:
- stage: Test
variables:
Test_Result: ''
jobs:
- job: TestJob
displayName: Test
steps:
- checkout: self
- checkout: testRepo
- script: |
npm install
workingDirectory: $(System.DefaultWorkingDirectory)\testrepo
# Not working - script not running
- script: |
echo "##vso[task.setvariable variable=Test_Result]$(node test.js)"
workingDirectory: $(System.DefaultWorkingDirectory)\testrepo
Output for above:
Output when node test.js is used without setting task variable
- script: |
node test.js
workingDirectory: $(System.DefaultWorkingDirectory)\tp-ui-caseMgmtV8
@dudewad I tried to follow your post stackoverflow.com/questions/71833899/…, but its not working for me. Sorry to tag you here as I dont have permission to add a comment in your post. Can you able to help me on this. Thanks