Logs not visible while npm task is running - azure-devops

In AzureDevops, when running an NPM task on a private agent, the logs are not visible until the task completes.
The output just appears blank e.g.
This happens for all npm tasks, from tasks that result in large log output and small.
The task above is a long running task which uses TestCafe to perform functional UI tests on a website. However, the same happens for other npm commands such as install.

I tested npm tasks, the log can be loaded normally:
Here are a few points you can try to see if it returns to normal:
What version of npm are you using? If not latest,you can try the latest npm task version.
According to your interface, you are using an older version of UI , you can try to enable Multi-stage pipelines in Preview features.
Try to run with private agent and see if it's still the same.

Related

Should a vscode dev container run npm install as part of its setup?

I've created a VS Code dev container for my project. To help new contributors get started, should the dev container Dockerfile run npm install?
No. Dev container define a development environment and should not perform actions that would be part of a normal development workflow (such as running npm install).
There are a couple of reasons why npm install in particular should be avoided:
If you run npm install in the dev container Dockerfile and it fails, the dev container will fail to launch. It's farbetter if the developer can open the dev container successfully, and then run npm install in an environment where they can investigate potential failures
npm install must be re-run when the project's dependencies change. Running npm install as part of dev container setup hides this from developers.
Dev container should only use npm install to install global scripts or tools that do not belong in the project's package.json.
It is actually good practice to call npm install as part of the dev container configuration. It eases and accelerate setup of the development environment, ensuring it's ready to use out of the box without extra steps possibly missed.
Note that the npm install must be in a postCreateCommand where sources and package.json are available (contrary to the Dockerfile).
Due to the nature of docker and devcontainer, there is very little reason for the npm install command to fail and need debugging. If it ever happen, VSCode logs will provide meaningful information, otherwise the postCreateCommand can be disabled quickly to investigate the issue.
There exists an official VSCode video, so we can assume calling npm install as part of the dev setup is a common practice: How to automatically run npm install in a dev container.

Azure DevOps Release Pipeline Inline Powershell script failing to run python unittest suite

I have a release pipeline setup in Azure DevOps to run a regression test suite. I am running these tests remotely on a Microsoft self-hosted Windows Agent using Selenium (Python bindings) and the Python unittest framework, which invokes chromedriver.exe to run tests.
When the release job reaches the task Run Python Unit Tests however, it freezes and I don't see any output (although, when I open the task manager on the agent
I can see chromedriver and chome instances running which suggests that something is happening).
Other info -
I am able to connect to the agent sucessfully as all my repos and latest commits are pulled down (from an earlier task in the pipeline)
the Chromedriver path is set as an environment variable on the agent
I am using Chromedriver 2.43
I am using Python 2.7.14 as the interpreter (also set as an env variable in the Path)
The inline powershell task has the following in the Script to run field -
cd C:\path\to\folder\with\tests
python tests.py staging
The message displayed when this task runs in DevOps pipeline is -
Waiting for console output from an agent...
console output
When I run the tests locally on the agent with the exact same command (opening the cmd.exe terminal on the agent), I can see chromedriver opening and the tests running as expected (with output in the terminal too)
Why am I unable to run see these tests running when invoked from the inline powershell task in the release pipeline but able to see the tests run when invoked on the VM? And why does the output still not show as the tests are running?
(I have also tried a normal cmd.exe task in place of the inline powershell task, the same issue was encountered)
Any help would be much appreciated, thank you :)
EDIT:
Ran a simple selenium test to check everything was working and got a successful result. However -
I was still unable to see console output as the test was executing
I was still unable to "see" anything executing on the VM (so it appeared to be running as a background task but could not see chrome launching and navigating to pages etc)

Azure private build agent : No agent could be found with the following capabilities: npm, azureps

I am trying to use a local server as a build agent to build a project. The server already has
VS 2015,
VS 2017
Node 6,7,8 via NVM
NPM 4,5,6 via NVM
I can build the project locally via npm build or yarn build.
I have downloaded and configured and registered the private build agent already and I have it in the agent pool in the portal - xxx.visualstudio.com/xxx.
But when I try to schedule a build from the portal the following message is displayed :
No agent could be found with the following capabilities: npm, azureps
What do I need to fix so the build can run locally?
The problem was simple - I did not see where the Capabilities tab was. IMHO Requests and Capabilities are not easily discoverable. I saw it and I set the two variables to true and it started to work even though I did not know for sure if true is the right value.
Another problem was that NVM SYMLINK was not working as expected and the build agent could not find node.exe at all. It was not in the PATH at all. I uninstalled nvm and used only node 8.1.2 with npm 5 in order to make it run.
UPDATE
As of today you can add a 'node tool installer' task to your definition - this is the better solution that is available today as D.J. points out in the comment section.

TeamCity with npm - Error: ENOENT, stat 'C:\Windows\system32\config\systemprofile\AppData\Roaming\npm'

I'm having serious problems getting the last pieces of my TeamCity configuration in place.
I have a powershell step that executes the following commands:
& npm install
& grunt build
logging the following output:
Build (Powershell) (1s)
[13:18:08]PowerShell Executable: C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe
[13:18:08]Working directory: C:\BuildAgent\work\6a434ee5d01fd0d9
[13:18:08]PowerShell arguments: [-NonInteractive, -ExecutionPolicy, ByPass, -File, C:\BuildAgent\temp\buildTmp\powershell8407335260182621582.ps1]
[13:18:09]Error: ENOENT, stat 'C:\Windows\system32\config\systemprofile\AppData\Roaming\npm'
[13:18:09]
[13:18:09]grunt-cli: The grunt command line interface. (v0.1.13)
[13:18:09]Process exited with code 0
I've seen that this is a known problem, but none of the solutions has worked for me so far.
My setup is the following: I have two virtual machines in Azure, build and agent. Both are connected to the same AD domain, domain, in which there is a user domain\teamcityuser, who is of "standard" class (i.e. not admin). This user runs both the build server (on the build instance) and the build agent (on the agent instance).
I've tried these things without success:
Creating the directory in the error message, making sure that domain\teamcityuser has full controll access rights to it.
Creating an npm directory under C:\Users\teamcityuser\AppData\Roaming
Creating a file C:\Windows\System32\config\SystemProfile\.npmrc with the contents prefix=C:\npm-global, as well as creating the latter folder
Running npm cache clean before running the build
Installing a global npm package through npm install -g npm
What more can I try to get this working?
And to avoid the XY problem, here's my actual problem:
I have a .NET Web API project with CI setup through this TeamCity installation, via Octopus Deploy and to the hosting server. I also have a github repo with the code for a web SPA that will consume the API. The spa is built with grunt build, after which there's a dist folder with everything I need to deploy.
I'd like to re-use as much as possible of the CI architecture to roll out the client too.
Given that path to executable contains SysWOW64, this is an x32 Powershell, therefore, it refers to x32 system profile path, which is located at C:\Windows\sysWOW64\config\systemprofile. So, you need to use that path as your base in order to implement any workarounds, say, create C:\Windows\sysWOW64\config\systemprofile\AppData\Roaming\npm folder, and not plain C:\Windows\system32\config\systemprofile\AppData\Roaming\npm.

How to further automate Teamcity

I have successfully configured my project for build in TeamCity. Going a step more, I want to run a deployment script once a build completes successfully. The deployment script is a simple bash command. To make the question more simpler, how would I invoke a shell command once a build successfully completes in Teamcity.
Please help
TeamCity 6.0 has a new feature called Multiple Build Steps:
Multiple Build Steps: Now any build configuration can be comprised of unlimited number of build steps, where each step is represented by a build runner. Don’t limit yourself, and combine as many build runners into one configuration as you need. Feel free to call a NAnt script before compiling VS solutions, run inspections and duplicates finder after your ANT build, add NUnit tests after your Rake build, and so on.
So you can add a new build step with the command line runner which will execute your shell script.