Cannot save output from npm task in Azure Pipelines release

378 views Asked by At

I have added a npm-step in my release-pipeline to get currently latest package version for a beta build like this:

- task: Npm@1
  displayName: 'Get current published beta-version'
  inputs:
    command: custom
    workingDir: ./packages/package
    verbose: false
    customCommand: 'show somepackagename@beta version'
    customRegistry: useFeed
    customFeed: '<someguids>'

This prints the latest version with the beta-tag, but I have not found a way to persist this value to the next step in my pipeline. I have tried adding things like > version.txt, | Out-File version.txt etc to the end of the customCommand, but it escapes both with double quotes and it is not executed. Any ideas if it is possible to achieve this with the current npm-task, or do I have to set up NPM registry authentication manually with .npmrc (the package is private in azure artifacts)?

1

There are 1 answers

4
Cece Dong - MSFT On

Check the solution in the following case Is there a way to log the output of npm install command to see whether it works for you:

npm show somepackagename@beta version 2>&1 | tee version.txt

The 2>&1 routes stderr to stdout, so everything will output in a single stream.