TeamCity npm update command not run every other time - npm

Having a weird issue in TeamCity npm steps where we update our internal npm packages. When the build is run it does not run the npm update command even though the log says it executes the command. But running the exact same build again triggers the command correctly (image 2).
Tried having the update command together with the following npm install and build commands in a single step and also as in the example images having them in separate steps but all scenarios give the same result; the update commands don't run every other time but all other npm commands runs correctly and trigger the build again makes the update commands execute. Why?!?!

Related

Only show critical errors of NPM audit on Azure Pipeline build

I am using NPM audit on my Azure Pipeline build using the following custom command
npm audit --registry=https://registry.npmjs.org/ | Select-String -Pattern ( "Critical") -Context 0,10
The idea here is that I only want to fail this step if there are any critical issues picked up by the audit.
Using this command locally within the command line works fine. But running it as a custom npm command in the pipeline still results in the full npm audit running and returning some moderate errors which cause the step to fail.
I feel I'm missing some formatting on the command but I'm not sure what it is.
Does any one else have experience of using NPM audit in a pipeline while successfully supressing certain error severities?
The reason the task is failing is not because of what the task is logging, but because npm audit is exiting with a non-zero code, which means a failure.
I suggest that instead, you add the --audit-level parameter to the npm audit command, to change whether it will finish with failure code or not:
By default, the audit command will exit with a non-zero code if any vulnerability is found. It may be useful in CI environments to include the --audit-level parameter to specify the minimum vulnerability level that will cause the command to fail. This option does not filter the report output, it simply changes the command's failure threshold.

Azure DevOps - npm invisible

I have a strange problem with a release pipeline in Azure DevOps.
I have two tasks:
1) Install packages
2) Run npm using the above packages
All seems to be easy so what I do is:
1) Command line task
npm install -g mkdirp 1.0.3
npm install -g newman
npm install -g newman-reporter-junitfull
2) PowerShell task
$(newman run $collection -e $environment --env-var "x=$(x)" -r junit --reporter-junit-export $resultFile)
This all worked fine until today. I tried a lot, but nothing works.
The error I have is:
newman : The term 'newman' is not recognized as the name of a cmdlet,
function, script file, or operable program. Check the spelling of the
name, or if a path was included, verify that the path is correct and
try again.
Did anyone have a similar issue?
I ran above npm install scripts in a Command line task, and found only the first npm install command got executed. And my following powershell task to run newman command failed with above error message too. You can check the log of Command line task to see if it is the same issue.
If you want to report this issue, you can report a problem here.
The workaround i found is to run the npm install commands in a Powershell task too, do not use Command line task. Then the npm install commands will all get executed and the following powershell task can run successfully.
Or you can separate above three npm install commands into three Command line tasks to install them separately, which will make sure the newman library is installed.

NPM - how to publish only if tests pass?

I have tests setup for a package I maintain - create-new-app. When I run npm publish, I want the tests to run first and only if they pass, move on to the publish portion. I thought this is what prepublishOnly was for. My prepublishOnly value looks like this:
prepublishOnly: "npm run test"
That successfully runs the tests prior to publishing, but if the tests fail, it still publishes! How can I get the publish to happen only when tests pass?
it's possible that your npm run test command is not returning a proper error code of non-zero

Couldn't find a debug log in the cache or working directory

I want to create a VSTS build with npm package auditing capabilities using npm audit. I added a few tasks to run npm audit. The command runs and I can see the details in the console/logs for all the packages. However, the task fails complaining about not finding a logs file. Any idea on how I can get the builds to stop working if I find a high vulnerability package?
EDIT
This is the final line in the result when I run npm audit locally
Notice how it displays vulnerabilities in categories. I want the build to not proceed if there is a non-zero value for High vulnerability.
I got the same error, but then realize that I am using incorrect custom command for npm task:
it was "npm install gulp -g", but should be "install gulp -g" (without npm).
For me it helps.
There isn’t the way to stop/fail build directly if there is a non-zero value for High vulnerability.
The workaround is that you can do it through PowerShell with Build log REST api to analysis whether there is related information in the log, then fail the build (Write-error …) (Run the powershell through PowerShell task)

skeleton-typescript-webpack fails when running npm start or npm run build on Windows 7

I'm running Windows 7 64bit with Node v6.5.0 and NPM 3.10.3. I ran npm install in the skeleton-typescript-webpack folder and all the packages installed fine. When I run any commands that call webpack though, I get the errors below.
When I run npm run build I get this error:
When I run npm start I get this error:
As you can see, the command that is run before the npm build error happens is concerning webpack, and same with the command that is run before the npm start error happens.
Anyone have an idea on how to fix this?
The skeleton skeleton-typescript-webpack uses TypeScript 2.0 for compilation.
This gives tries to compile adm-zip which is in the selenium-webdriver node module. And this gives an error on a break statement after a return statement.
The file .\nodes_modules\selenium-webdriver\node_modules\adm-zip\zipEntry.js gives the issue. You have to comment out two break; statements in the file on line 96 and line 115. After this you get a correct build.