Azure Devops pipeline build suddenly stopped working - azure-devops

Our Azure build pipeline started failing today. This was working fine with the same code a few days back. I'm struggling to find a reason. The build works fine in my local machine but doesn’t work on DevOps.
Below are some lines from the error log. Can anyone guide me to find the issue please?
Start of the error in the logs:
2021-12-04T09:08:08.1234486Z 6728 timing metavuln:packument:sass-loader Completed in 28ms
2021-12-04T09:08:08.1234976Z 6729 timing metavuln:load:security-advisory:sass-loader:sKa4m2v9CoUt2NE/HFdn2iHPGTVRUKpbo4oLNnOVBTLyHGQ/KmGqhFuwUlvkR/owQNQEXwZFOGQt5TNCCkoHWw== Completed in 5ms
2021-12-04T09:08:08.1235699Z 6730 timing metavuln:cache:put:security-advisory:sass-loader:0+Q0+uaac9NG7L1nbkGVbvFbaBvbLzENFqRpXWUE7U0t2jjSSjVZ79o6UtQRkcjQ/gcgS0kd8p2vAnNjva/3Eg== Completed in 15ms
2021-12-04T09:08:08.1236341Z 6731 timing metavuln:calculate:security-advisory:sass-loader:sKa4m2v9CoUt2NE/HFdn2iHPGTVRUKpbo4oLNnOVBTLyHGQ/KmGqhFuwUlvkR/owQNQEXwZFOGQt5TNCCkoHWw== Completed in 48ms
2021-12-04T09:08:08.1237034Z 6732 timing metavuln:cache:get:security-advisory:imagemin-jpegtran:s0MaKyyWWIoVMQAlu89TduB0lW+w9ANmAjDodgTT4fcy4ki3FsHrWalCv/COtdz4o3adGXtGYSamW2jub7ta+Q== Completed in 1ms
2021-12-04T09:08:08.1237558Z 6733 info run node-sass#4.14.1 postinstall { code: 1, signal: null }
2021-12-04T09:08:08.1238006Z 6734 http fetch GET 200 https://registry.npmjs.org/imagemin-jpegtran 5491ms (cache miss)
2021-12-04T09:08:08.1238399Z 6735 timing metavuln:packument:imagemin-jpegtran Completed in 5491ms
2021-12-04T09:08:08.1238952Z 6736 timing metavuln:load:security-advisory:imagemin-jpegtran:u6oOqPrIyXrFjQnhqewixjKDTSD2uoKmmWFnU4zRuXrk8rdHkm8zODnNe7xy3697n8Yy/cBLgdQBE6mFa/kxsg== Completed in 1ms
2021-12-04T09:08:08.1239443Z 6737 timing reify:rollback:createSparse Completed in 5296ms
2021-12-04T09:08:08.1239823Z 6738 timing reify:rollback:retireShallow Completed in 0ms
2021-12-04T09:08:08.1240144Z 6739 timing command:install Completed in 77131ms
2021-12-04T09:08:08.1240444Z 6740 verbose stack Error: command failed
2021-12-04T09:08:08.1240974Z 6740 verbose stack at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\#npmcli\promise-spawn\index.js:64:27)
2021-12-04T09:08:08.1241517Z 6740 verbose stack at ChildProcess.emit (node:events:390:28)
2021-12-04T09:08:08.1241956Z 6740 verbose stack at maybeClose (node:internal/child_process:1064:16)
2021-12-04T09:08:08.1242405Z 6740 verbose stack at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)
2021-12-04T09:08:08.1242817Z 6741 verbose pkgid node-sass#4.14.1
2021-12-04T09:08:08.1243073Z 6742 verbose cwd D:\a\1\s
2021-12-04T09:08:08.1243323Z 6743 verbose Windows_NT 10.0.17763
2021-12-04T09:08:08.1243767Z 6744 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
2021-12-04T09:08:08.1244152Z 6745 verbose node v16.13.0
2021-12-04T09:08:08.1244424Z 6746 verbose npm v8.1.0
2021-12-04T09:08:08.1244643Z 6747 error code 1
2021-12-04T09:08:08.1244930Z 6748 error path D:\a\1\s\node_modules\gulp-sass\node_modules\node-sass
2021-12-04T09:08:08.1245270Z 6749 error command failed
2021-12-04T09:08:08.1245577Z 6750 error command C:\Windows\system32\cmd.exe /d /s /c node scripts/build.js
2021-12-04T09:08:08.1246161Z 6751 error Building: C:\Program Files\nodejs\node.exe D:\a\1\s\node_modules\node-gyp\bin\node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
2021-12-04T09:08:08.1246648Z 6752 error gyp info it worked if it ends with ok
Last few lines of the log:
2021-12-04T09:08:08.1681219Z 6752 error gyp verb node dev dir C:\Users\VssAdministrator\.node-gyp\16.13.0
2021-12-04T09:08:08.1681621Z 6752 error gyp verb found first Solution file build/binding.sln
2021-12-04T09:08:08.1682050Z 6752 error gyp verb using MSBuild: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\15.0\Bin\MSBuild.exe
2021-12-04T09:08:08.1682559Z 6752 error gyp info spawn C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\15.0\Bin\MSBuild.exe
2021-12-04T09:08:08.1682993Z 6752 error gyp info spawn args [
2021-12-04T09:08:08.1683269Z 6752 error gyp info spawn args 'build/binding.sln',
2021-12-04T09:08:08.1683573Z 6752 error gyp info spawn args '/nologo',
2021-12-04T09:08:08.1683893Z 6752 error gyp info spawn args '/p:Configuration=Release;Platform=x64'
2021-12-04T09:08:08.1684205Z 6752 error gyp info spawn args ]
2021-12-04T09:08:08.1684463Z 6752 error gyp ERR! UNCAUGHT EXCEPTION
2021-12-04T09:08:08.1684876Z 6752 error gyp ERR! stack Error: spawn C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\15.0\Bin\MSBuild.exe ENOENT
2021-12-04T09:08:08.1685424Z 6752 error gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:282:19)
2021-12-04T09:08:08.1685894Z 6752 error gyp ERR! stack at onErrorNT (node:internal/child_process:477:16)
2021-12-04T09:08:08.1686366Z 6752 error gyp ERR! stack at processTicksAndRejections (node:internal/process/task_queues:83:21)
2021-12-04T09:08:08.1686766Z 6752 error gyp ERR! System Windows_NT 10.0.17763
2021-12-04T09:08:08.1687321Z 6752 error gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "D:\\a\\1\\s\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
2021-12-04T09:08:08.1687915Z 6752 error gyp ERR! cwd D:\a\1\s\node_modules\gulp-sass\node_modules\node-sass
2021-12-04T09:08:08.1688248Z 6752 error gyp ERR! node -v v16.13.0
2021-12-04T09:08:08.1688513Z 6752 error gyp ERR! node-gyp -v v3.8.0
2021-12-04T09:08:08.1688788Z 6752 error gyp ERR! This is a bug in `node-gyp`.
2021-12-04T09:08:08.1689164Z 6752 error gyp ERR! Try to update node-gyp and file an Issue if it does not help:
2021-12-04T09:08:08.1689568Z 6752 error gyp ERR! <https://github.com/nodejs/node-gyp/issues>
2021-12-04T09:08:08.1689916Z 6752 error Build failed with error code: 7
2021-12-04T09:08:08.1690179Z 6753 verbose exit 1
2021-12-04T09:08:08.1690283Z
2021-12-04T09:08:08.1720104Z ##[error]Error: Npm failed with return code: 1
2021-12-04T09:08:08.1747833Z ##[section]Finishing: Npm
Below is the yaml file
name: 1.0.$(BuildID)-$(SourceBranchName)
trigger:
- release
variables:
versionNumber: '1.0.$(BuildID)'
mvcSolution: 'SVHA.MVC.Web.sln'
jobs:
- job: "BuildStaging"
variables:
buildConfiguration: 'Staging'
buildPlatform: 'Any CPU'
pool:
vmImage: 'windows-latest'
steps:
- task: Npm#1
inputs:
command: 'install'
workingDir: './'
- task: CmdLine#2
inputs:
script: 'npm run apps-build'
workingDirectory: './'
- task: Gulp#1
inputs:
gulpFile: 'gulpfile.js'
targets: 'build'
arguments: '--production'
enableCodeCoverage: false
- task: NuGetToolInstaller#1
- task: NuGetCommand#2
inputs:
restoreSolution: '$(mvcSolution)'
- task: VSBuild#1
inputs:
solution: '$(mvcSolution)'
msbuildArgs: '/t:Rebuild /p:Configuration=Staging;DeployOnBuild=true;DeployTarget=Package;AutoParameterizationWebConfigConnectionStrings=False;_PackageTempDir="$(Build.BinariesDirectory)\mvc"'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: CopyFiles#2
inputs:
SourceFolder: 'src\SVHA.Web\Config\staging'
Contents: 'connectionStrings.config'
TargetFolder: '$(Build.BinariesDirectory)\mvc\Config'
OverWrite: true
- task: ArchiveFiles#2
inputs:
rootFolderOrFile: '$(Build.BinariesDirectory)\mvc'
includeRootFolder: false
archiveType: 'zip'
archiveFile: '$(Build.ArtifactStagingDirectory)\mvc.zip'
replaceExistingArchive: true
- task: PublishBuildArtifacts#1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'staging'
publishLocation: 'Container'

Remove node-sass and install sass instead.

Related

NodeTool#0 Task Fails on Hosted Agent

I am running a pipeline on a macos-12 agent which has a NodeTool#0 task
- task: NodeTool#0
inputs:
versionSource: 'spec'
versionSpec: '16.x'
checkLatest: false
`
This link: https://github.com/actions/runner-images/blob/main/images/macos/macos-12-Readme.md
mentions that NodeJS 16.8.1 is cached in macos-12 hosted agents
However, I often (but not always) get the following error when running my pipeline:
##[error]Unable to create directory '/opt/hostedtoolcache/node/16.18.1/x64'. EACCES: permission denied, mkdir '/opt/hostedtoolcache'
Why? And what can I do to prevent this error?
Thank you
Kiko

Can't Switch to Windows Latest Agent in Azure Pipeline. Gives error gyp ERR! This is a bug in `node-gyp`

pool:
name: Azure Pipelines
demands: npm
#Your build pipeline references an undefined variable named ‘Parameters.solution’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab. See https://go.microsoft.com/fwlink/?linkid=865972
#Your build pipeline references an undefined variable named ‘Parameters.ArtifactName’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab. See https://go.microsoft.com/fwlink/?linkid=865972
steps:
task: NuGetToolInstaller#0
displayName: 'Use NuGet 4.4.1'
inputs:
versionSpec: 4.4.1
task: NuGetCommand#2
displayName: 'NuGet restore'
inputs:
restoreSolution: '$(Parameters.solution)'
feedsToUse: config
nugetConfigPath: Nuget.config
task: Npm#1
displayName: 'npm custom'
inputs:
command: custom
verbose: false
customCommand: 'cache clean --force'
task: Npm#1
displayName: 'npm custom'
inputs:
command: custom
verbose: false
customCommand: 'i --unsafe-perm node-sass'
task: Npm#1
displayName: 'npm custom'
inputs:
command: custom
verbose: false
customCommand: 'install run-sequence'
task: NodeTool#0
displayName: 'Use Node 6.x'
task: Npm#1
displayName: 'npm install'
inputs:
verbose: false
task: gulp#0
displayName: 'gulp CI-Build'
inputs:
targets: 'CI-Build'
task: ArchiveFiles#2
displayName: Output
inputs:
rootFolderOrFile: output
includeRootFolder: false
task: PublishBuildArtifacts#1
displayName: 'Publish Artifact: drop'
inputs:
ArtifactName: '$(Parameters.ArtifactName)'
condition: succeededOrFailed()
It is giving the error as below:
3675 error gyp ERR! cwd D:\a\1\s\node_modules\gulp-sass\node_modules\node-sass
3675 error gyp ERR! node -v v16.13.2
3675 error gyp ERR! node-gyp -v v3.8.0
3675 error gyp ERR! This is a bug in node-gyp.
3675 error gyp ERR! Try to update node-gyp and file an Issue if it does not help:
3675 error gyp ERR! https://github.com/nodejs/node-gyp/issues
3675 error Build failed with error code: 7
3676 verbose exit 1
I have tried different version of Node like Node11.x & Node 13.x
But can't compile the Build.
Please help !

Error: spawn chromedriver when ng e2e -- --protractor-config=./e2e/protractor-ci.conf.js on config.yml file

I am trying to integrate protractor e2e tests on my circleCi with the following setup:
config.yml
- run:
name: NPM test
command: |
cd frontend
npm install
apk update
apk add chromium
export CHROME_BIN=$(which chromium-browser)
npm run test -- --no-watch --no-progress --browsers=ChromeHeadlessCI --code-coverage || exit 0
- run:
name: Protractor e2e tests
command: |
cd frontend
npm run e2e -- --protractor-config=./e2e/protractor-ci.conf.js
protractor config:
const config = require('./protractor.conf').config;
config.capabilities = {
browserName: 'chrome',
chromeOptions: {
args: ['--headless', '--no-sandbox']
}
};
exports.config = config;
Unit test run with success, although e2e tests are not running:
[10:12:58] I/file_manager - creating folder /root/project/frontend/node_modules/protractor/node_modules/webdriver-manager/selenium
[10:12:58] I/config_source - curl -o/root/project/frontend/node_modules/protractor/node_modules/webdriver-manager/selenium/chrome-response.xml https://chromedriver.storage.googleapis.com/
ℹ 「wdm」: Compiled successfully.
[10:12:58] I/downloader - curl -o/root/project/frontend/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_81.0.4044.69.zip https://chromedriver.storage.googleapis.com/81.0.4044.69/chromedriver_linux64.zip
[10:12:59] I/update - chromedriver: unzipping chromedriver_81.0.4044.69.zip
[10:12:59] I/update - chromedriver: setting permissions to 0755 for /root/project/frontend/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_81.0.4044.69
[10:12:59] I/launcher - Running 1 instances of WebDriver
[10:12:59] I/direct - Using ChromeDriver directly...
[10:12:59] E/launcher - spawn /root/project/frontend/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_81.0.4044.69 ENOENT
[10:12:59] E/launcher - Error: spawn /root/project/frontend/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_81.0.4044.69 ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:246:19)
at onErrorNT (internal/child_process.js:421:16)
at process.internalTickCallback (internal/process/next_tick.js:72:19)
[10:12:59] E/launcher - Process exited with error code 199
An unexpected error occurred: undefined
Setup:
Angular CLI: 7.3.9
Node: 10.19.0
Protractor: 5.4.3
Already tried:
- Update webdriver before the tests started.
- Already check thatc hromedriver_81.0.4044.69 file is on the folder of the error

Access GitVersion variable in azure pipeline for javascript build

I've got the following pipeline:
steps:
- task: GitVersion#4
- script: |
echo '##vso[task.setvariable variable=buildVersion]$(GitVersion.FullSemVer")'
- task: NodeTool#0
inputs:
versionSpec: '10.x'
displayName: 'Install Node.js'
- task: Npm#1
inputs:
command: 'install'
workingDir: '$(Build.SourcesDirectory)'
displayName: "NPM Install"
- task: Npm#1
inputs:
command: 'custom'
workingDir: '$(Build.SourcesDirectory)'
customCommand: 'run-script build'
displayName: "NPM Build"
- task: Npm#1
inputs:
command: 'custom'
workingDir: '$(Build.SourcesDirectory)'
customCommand: 'npm version $(buildVersion)'
displayName: "Add version"
But I can't get access to the GitVersion output. I've tried with simply referencing $(GitVersion.FullSemVer) as well, but it gives the same result. The output from npm version is:
[command]C:\windows\system32\cmd.exe /D /S /C "C:\hostedtoolcache\windows\node\10.16.0\x64\npm.cmd npm version "$(GitVersion.FullSemVer)'""
Usage: npm <command>
If I write out the actual variables it looks fine.
Edit: It seems the problem at hand is that the version number is quoted, which npm doesn't like. So the question is more how to make that not happen.
You have an extra " in $(GitVersion.FullSemVer"), just remove it and it will be fine:
echo '##vso[task.setvariable variable=buildVersion]$(GitVersion.FullSemRev)'
For example:
- task: GitVersion#4
- script: 'echo ##vso[setvariable variable=buildVersion]$(GitVersion.FullSemRev)'
- script: 'echo $(buildVersion)'
Results:

Error when running angular e2e test on gitlab CI

I'm having a not very meaningful error on my gitlab CI server when running e2e tests.
[22:40:18] I/launcher - Running 1 instances of WebDriver
[22:40:18] I/local - Starting selenium standalone server...
[22:40:18] E/launcher - Error: Error: Server terminated early with status 1
at earlyTermination.catch.e (/selenium-webdriver/remote/index.js:252:52)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
[22:40:18] E/launcher - Process exited with error code 100
npm ERR! code ELIFECYCLE
npm ERR! errno 100
npm ERR! guide-scanner-web#0.0.0 e2e-ci: `ng e2e --conf protractor-ci.conf.js`
npm ERR! Exit status 100
npm ERR!
npm ERR! Failed at the guide-scanner-web#0.0.0 e2e-ci script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2017-11-28T22_40_19_015Z-debug.log
ERROR: Job failed: exit code 1
Here is the protractor.conf.js
const { SpecReporter } = require('jasmine-spec-reporter');
exports.config = {
allScriptsTimeout: 11000,
specs: [
'./e2e/**/*.e2e-spec.ts'
],
capabilities: {
'browserName': 'chrome',
'chromeOptions': {
args: ["--headless", '--no-sandbox', "--disable-gpu", "--window-size=800x600"]
}
},
chromeDriver: '/selenium-grid/chromedriver_2.33',
seleniumServerJar: "/selenium-grid/selenium-server-standalone-3.7.1.jar",
baseUrl: 'http://localhost:4200/',
framework: 'jasmine',
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000,
print: function() {}
},
onPrepare() {
require('ts-node').register({
project: 'e2e/tsconfig.e2e.json'
});
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
}
};
the job desciption in my gitlab-ci.yml
before_script:
- npm install
e2e:
stage: testing
script:
- apt-get update -y
- apt-get install default-jre -y
- npm install -g webdriver-manager
- webdriver-manager update --out_dir /selenium-grid
- npm run e2e
And here is my package.json:
"#angular/language-service": "^5.0.0"
"#types/jasmine": "~2.5.53"
"#types/jasminewd2": "~2.0.2"
"#types/node": "~6.0.60"
"codelyzer": "~3.2.2"
"jasmine-core": "~2.6.2"
"jasmine-spec-reporter": "~4.1.0"
"karma": "~1.7.0"
"karma-chrome-launcher": "~2.1.1"
"karma-cli": "~1.0.1"
"karma-coverage-istanbul-reporter": "^1.2.1"
"karma-jasmine": "~1.1.0"
"karma-jasmine-html-reporter": "^0.2.2"
"protractor": "~5.1.2"
"ts-node": "~3.2.0"
"tslint": "~5.7.0"
"typescript": "~2.4.2"
I've been struggling on setting up the CI for a little while now so any suggestions will be very much appreciated ^^'
Just use image with headless chrome preinstalled. Here is my script for Gitlab pipelines:
cache:
paths:
- node_modules/
before_script:
- npm cache clean --force
- npm install && npm rebuild
stages:
- test
- build
build:
image: node:alpine
stage: build
script:
- ./node_modules/#angular/cli/bin/ng build --prod
test:
image: gnomeontherun/docker-node-chrome-headless:latest
stage: test
script:
- ./node_modules/#angular/cli/bin/ng test --watch=false --single-run=true