2

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)?

andMarkus
  • 960
  • 1
  • 8
  • 16

1 Answers1

0

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.
Cece Dong - MSFT
  • 29,631
  • 1
  • 24
  • 39
  • The solution you provided is for routing stderr to stdout - that is not the problem I'm facing. The output from npm show is already stdout. – andMarkus Oct 21 '20 at 11:08
  • Are you able to save output from npm command locally? – Cece Dong - MSFT Oct 22 '20 at 09:24
  • Yes, if I add `> version.txt` to my command locally, I get a txt-file that contains the output from the command. – andMarkus Oct 26 '20 at 14:32
  • It seems it need to follow traditional unix style quoting and escaping via the shell. You may try to quote it. Check this case to see whether it is helpful: https://unix.stackexchange.com/questions/296141/how-to-use-a-special-character-as-a-normal-one. – Cece Dong - MSFT Oct 27 '20 at 10:42