Azure管道Yaml权限被拒绝 [英] Azure pipelines yaml permission denied

查看:60
本文介绍了Azure管道Yaml权限被拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试使用Azure管道进行部署时出现错误.

I'm getting an error when trying to deploy using azure pipelines.

Error: EACCES: permission denied, access '/usr/local/lib/node_modules'

我认为它是因为在阶段之间未共享node_modules文件夹.但是我不知道什么是正确的方法.

I think its becuase the node_modules folder is not being shared between stages. But I cant figure out what is proper way to do it.

这是我的Yaml文件:

Here is my yaml file:

variables:
  - group: netlify

trigger:
- master

pool:
  vmImage: 'ubuntu-latest'

stages: 
  - stage: Build
    jobs:
      - job: ARM
        steps:
        - task: NodeTool@0
          inputs:
            versionSpec: '10.x'
          displayName: 'Install Node.js'

        - script: |
            npm install
            npm run unit
          displayName: 'Setup and test'

        - script: npm run build
        - publish: $(System.DefaultWorkingDirectory)
          artifact: dist
  - stage: Deploy
    dependsOn: Build
    condition: succeeded()
    jobs:
      - job: APP
        steps:
        - bash: |
           npm i -g netlify-cli
           netlify deploy --site $(NETLIFY_SITE_ID) --auth $(NETLIFY_AUTH_TOKEN) --prod

运行npm install之后,软件包node_modules应该出现在目录中,但是似乎未正确共享.

After running npm install, package node_modules should appear somehwere in the directory but it seems its not properly shared.

推荐答案

您正在使用Ubuntu映像,并尝试在没有sudo Linux中全局安装netlify-cli.

You are using Ubuntu image, and trying to global install netlify-cli in Linux without sudo.

如果Ubuntu是必须使用的必要系统,则最好在此命令之前添加sudo:

If the Ubuntu is the necessary system you must use, you'd better add sudo before this command:

sudo npm i -g netlify-cli

命令在我的管道上成功

在此文档中,在* nix(OSX,Linux等)上升级:

您可能需要为这些命令添加sudo前缀,尤其是在Linux上, 或OS X(如果使用默认安装程序安装了Node).

You may need to prefix these commands with sudo, especially on Linux, or OS X if you installed Node using its default installer.

Same in VSTS, you must use sudo in the command to let you has password-less sudo rights for Ubuntu.

如果对构建环境没有任何特殊要求,另一种方法是将映像更改为vs2017-win2016:

Another way is change the image to vs2017-win2016 if you do not has any special requirements for the build environment:

pool:
  vmImage: 'vs2017-win2016'

使用此映像时,您可以安装任何东西,而无需使用sudo.

When using this image, you could install anything and do not need use sudo.

事实上,我们已经在所有托管映像中预装了许多基本工具,包括node.js

In fact, we has been pre-installed many basic tools in all hosted images, including node.js

在我们的 github描述中,我们列出了所有工具预先安装了所有图像.您可以检查以了解有关VSTS的更多信息.

In our github description, we listed all tools that pre-installed for all images. You can check to know more about VSTS.

这篇关于Azure管道Yaml权限被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆