Azure-devops-docs: Since the cmd task supports multiple lines, is it supposed to only one run command?

Created on 21 Aug 2019  Â·  2Comments  Â·  Source: MicrosoftDocs/azure-devops-docs

I have tried to use v2 of the cmd task for a few different scenarios, and my usage has led me to believe that only the first command in the script runs.

Example, here is my script/command in the task:

npm install -g tfx-cli
tfx login --service-url $(TfsUrl) --auth-type pat --token $(TfsPAT)
tfx build tasks upload --task-path $(taskFolderName) --overwrite

Based on the logs, it is only running the first command. I just get an output that the package was installed. Is that intended? The way the task and documentation is laid out, it seems like it should run the entire script / multiple commands. This is the default content in the task when you add it - note 'commands' :

echo Write your commands here

echo Hello world

Instead, I can just use 3 command line tasks which is no problem, but it would be helpful to document if this is a known issue / if this is the intent of the task.

Thanks!


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Pri1 devops-cictech devopprod product-question

Most helpful comment

On Windows, npm is a .cmd script. Windows CMD does something strange with .cmd files - I think it exits the current session and starts a new one (or similar - I'm honestly a bit fuzzy on the details). The upshot is: when you enter commands interactively, you can't see this difference, but when running headless on a CI machine, the difference matters. You need to use the call command for npm or npm globals.

call npm install -g tfx-cli
call tfx login --service-url $(TfsUrl) --auth-type pat --token $(TfsPAT)
call tfx build tasks upload --task-path $(taskFolderName) --overwrite

You're not the first to be confused by this; I'll add a note in the docs. Thank you!

All 2 comments

On Windows, npm is a .cmd script. Windows CMD does something strange with .cmd files - I think it exits the current session and starts a new one (or similar - I'm honestly a bit fuzzy on the details). The upshot is: when you enter commands interactively, you can't see this difference, but when running headless on a CI machine, the difference matters. You need to use the call command for npm or npm globals.

call npm install -g tfx-cli
call tfx login --service-url $(TfsUrl) --auth-type pat --token $(TfsPAT)
call tfx build tasks upload --task-path $(taskFolderName) --overwrite

You're not the first to be confused by this; I'll add a note in the docs. Thank you!

@vtbassmatt Thank you for the clarification!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

KacperMucha picture KacperMucha  Â·  3Comments

MJECloud picture MJECloud  Â·  3Comments

atrauzzi picture atrauzzi  Â·  3Comments

dannyvv picture dannyvv  Â·  3Comments

letmaik picture letmaik  Â·  3Comments