如何将Node脚本输出存入Azure任务变量?脚本执行异常求助
问题:Azure Pipeline中无法将Node.js脚本输出存入任务变量
我尝试将Node.js脚本的输出存储到Azure Pipeline任务变量中,编写了如下YAML管道:
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
但运行该YAML时,上述标注“Not working - script not running”的脚本步骤未执行;而直接单独运行如下脚本步骤时,node test.js可正常执行并显示输出:
- script: | node test.js workingDirectory: $(System.DefaultWorkingDirectory)\tp-ui-caseMgmtV8
相关输出截图:
- 含变量赋值的脚本步骤输出:

- 单独运行
node test.js的输出:
不清楚问题出在哪里,恳请指点解决方向,谢谢。
内容的提问来源于stack exchange,提问作者sp13aut
相关产品推荐
相关产品推荐

