microsoft / azure-pipelines-tasks

Tasks for Azure Pipelines
https://aka.ms/tfbuild
MIT License
3.43k stars 2.59k forks source link

[BUG]: npmAuthenticate@0 Post-job started failing #18245

Open kaimas50 opened 1 year ago

kaimas50 commented 1 year ago

Task name

npmAuthenticate

Task version

0.218.0

Environment type (Please select at least one enviroment where you face this issue)

Azure DevOps Server type

dev.azure.com (formerly visualstudio.com)

Azure DevOps Server Version (if applicable)

No response

Operation system

ubuntu-latest

Task log

##[debug]Agent.ProxyUrl=undefined
##[debug]Agent.CAInfo=undefined
##[debug]Agent.ClientCert=undefined
##[debug]Agent.SkipCertValidation=undefined
##[debug]check path : /home/vsts/work/_tasks/npmAuthenticate_ad884ca2-732e-4b85-b2d3-ed71bcbd2788/0.218.0/task.json
##[debug]adding resource file: /home/vsts/work/_tasks/npmAuthenticate_ad884ca2-732e-4b85-b2d3-ed71bcbd2788/0.218.0/task.json
##[debug]system.culture=en-US
##[debug]SAVE_NPMRC_PATH=/home/vsts/work/1/npmAuthenticate/7av3Yv
##[debug]workingFile=/home/vsts/work/1/s/.npmrc
##[debug]workingFile=/home/vsts/work/1/s/.npmrc
##[debug]SAVE_NPMRC_PATH=/home/vsts/work/1/npmAuthenticate/7av3Yv
##[debug]Restoring file /home/vsts/work/1/s/.npmrc
##[debug]task result: Failed
##[error]Unhandled: EACCES: permission denied, open '/home/vsts/work/1/s/.npmrc'
##[debug]Processed: ##vso[task.issue type=error;]Unhandled: EACCES: permission denied, open '/home/vsts/work/1/s/.npmrc'
##[debug]Processed: ##vso[task.complete result=Failed;]Unhandled: EACCES: permission denied, open '/home/vsts/work/1/s/.npmrc'
##[error]Error: EACCES: permission denied, open '/home/vsts/work/1/s/.npmrc'
    at Object.openSync (node:fs:594:3)
    at Object.writeFileSync (node:fs:2207:35)
    at copyFile (/home/vsts/work/_tasks/npmAuthenticate_ad884ca2-732e-4b85-b2d3-ed71bcbd2788/0.218.0/node_modules/azure-pipelines-tasks-packaging-common-v3/util.js:20:8)
    at Object.restoreFileWithName (/home/vsts/work/_tasks/npmAuthenticate_ad884ca2-732e-4b85-b2d3-ed71bcbd2788/0.218.0/node_modules/azure-pipelines-tasks-packaging-common-v3/util.js:58:13)
    at /home/vsts/work/_tasks/npmAuthenticate_ad884ca2-732e-4b85-b2d3-ed71bcbd2788/0.218.0/npmauthcleanup.js:27:18
    at Generator.next (<anonymous>)
    at /home/vsts/work/_tasks/npmAuthenticate_ad884ca2-732e-4b85-b2d3-ed71bcbd2788/0.218.0/npmauthcleanup.js:8:71
    at new Promise (<anonymous>)
    at __awaiter (/home/vsts/work/_tasks/npmAuthenticate_ad884ca2-732e-4b85-b2d3-ed71bcbd2788/0.218.0/npmauthcleanup.js:4:12)
    at run (/home/vsts/work/_tasks/npmAuthenticate_ad884ca2-732e-4b85-b2d3-ed71bcbd2788/0.218.0/npmauthcleanup.js:18:12)
##[debug]Processed: ##vso[task.issue type=error;]Error: EACCES: permission denied, open '/home/vsts/work/1/s/.npmrc'
    at Object.openSync (node:fs:594:3)
    at Object.writeFileSync (node:fs:2207:35)
    at copyFile (/home/vsts/work/_tasks/npmAuthenticate_ad884ca2-732e-4b85-b2d3-ed71bcbd2788/0.218.0/node_modules/azure-pipelines-tasks-packaging-common-v3/util.js:20:8)
    at Object.restoreFileWithName (/home/vsts/work/_tasks/npmAuthenticate_ad884ca2-732e-4b85-b2d3-ed71bcbd2788/0.218.0/node_modules/azure-pipelines-tasks-packaging-common-v3/util.js:58:13)
    at /home/vsts/work/_tasks/npmAuthenticate_ad884ca2-732e-4b85-b2d3-ed71bcbd2788/0.218.0/npmauthcleanup.js:27:18
    at Generator.next (<anonymous>)
    at /home/vsts/work/_tasks/npmAuthenticate_ad884ca2-732e-4b85-b2d3-ed71bcbd2788/0.218.0/npmauthcleanup.js:8:71
    at new Promise (<anonymous>)
    at __awaiter (/home/vsts/work/_tasks/npmAuthenticate_ad884ca2-732e-4b85-b2d3-ed71bcbd2788/0.218.0/npmauthcleanup.js:4:12)
    at run (/home/vsts/work/_tasks/npmAuthenticate_ad884ca2-732e-4b85-b2d3-ed71bcbd2788/0.218.0/npmauthcleanup.js:18:12)
Finishing: Authenticate npm

Relevant log output

##[error]Unhandled: EACCES: permission denied, open '/home/vsts/work/1/s/.npmrc'

Aditional info

Previously runs with npmAuthenticate@0 (0.218.0) succeeded. Now `Post-job: Authenticate npm` fails every time.
matthewtmurray commented 1 year ago

I'm having the same issue, As a workaround I've set npmAuthenticate to a specific earlier version,0.208.1, as below, this solves the problem for now.

- task: npmAuthenticate@0.208.1
              inputs:
                workingFile: 'frontend/.npmrc'
owennewo commented 1 year ago

I'm seeing the same problem i.e. fails with npmAuthenticate@0 (0.218.0) but works with 0.208.1.

It was working with 0.218.0 on 3rd May. So a bit tricky.

My pipeline has a couple of other npm commands after it (install and lint). All work, but the post-job: npmAuthenticate fails with EACCESS: permission denied, open '/home/vsys/work/1/s/.npmrc

I think this is a duplicate of #18242

PXL_20230509_152844672

Pieeer1 commented 1 year ago

Confirming that changing npmAuthenticate@0 to npmAuthenticate@0.208.1 is a temporary solution.

Jarod1662 commented 1 year ago

Any update on this? just tried to run our pipeline for the first time in a while and having the same issue. will set the pipeline to use npmAuthenticate@0.208.1 for the time being

embetten commented 11 months ago

Hi all, I am trying to repro this issue and see npmAuthenticate 0.218.0 is working on my hosted ubuntu-latest. Are these failures on self-hosted ubuntu-latest machines? Is it failing in the npmAuthenticate step or the subsequent restore steps?

alex-bartleynees commented 6 months ago

I've also just encountered the error, it occurred on the post-job clean up step. I need to run the NPM authenticate task before deploying to azure static web app.

image image

jeffvannijlen commented 5 months ago

We hae noticed that before deploying the Azure Static Web app the file had following rights:

-rw-r--r-- 1 vsts docker 1.4K Jan 29 13:50 .npmrc

After the deployment:

-rw-r--r-- 1 root root 1.4K Jan 29 13:50 .npmrc

Looks like the Azure Static Web app deployment changes the permission of the files.

pszujewski commented 2 months ago

Same thing for me: "I've also just encountered the error, it occurred on the post-job clean up step. I need to run the NPM authenticate task before deploying to azure static web app."

Installing packages via an azure artifacts feed works totally fine in the container and my build works as expected, but in the "Post Job" step I get as well:

EACCES: permission denied, open '/home/vsts/work/1/s/.npmrc'

My company configures this pipeline in the devops ui and not using a yaml file. When I go into the UI under here I check "Continue on error":

image

This allows the rest of the deployment to go through but now the pipeline results have warnings.

I can't set a specific version for "Npm Authenticate" in the UI:

image