Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/28.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
vsts npm认证可以';无法在VSTS生成上获取身份验证令牌_Npm_Azure Pipelines - Fatal编程技术网

vsts npm认证可以';无法在VSTS生成上获取身份验证令牌

vsts npm认证可以';无法在VSTS生成上获取身份验证令牌,npm,azure-pipelines,Npm,Azure Pipelines,我正在尝试使用获取VSTS包存储库的身份验证令牌。在我的开发机器上,我可以运行这些命令 npm安装-g vsts npm auth vsts npm auth-my\.npmrc的配置路径 它成功地为我提供了一个身份验证令牌。我现在正试图在VSTS上重新创建它作为构建步骤,因此我创建了powershell脚本auth VSTS.ps1 $npmrcFile = "$PSScriptRoot\path-to-my\.npmrc"; npm install -g vsts-npm-auth; vst

我正在尝试使用获取VSTS包存储库的身份验证令牌。在我的开发机器上,我可以运行这些命令

npm安装-g vsts npm auth
vsts npm auth-my\.npmrc的配置路径

它成功地为我提供了一个身份验证令牌。我现在正试图在VSTS上重新创建它作为构建步骤,因此我创建了powershell脚本
auth VSTS.ps1

$npmrcFile = "$PSScriptRoot\path-to-my\.npmrc";
npm install -g vsts-npm-auth;
vsts-npm-auth -config $npmrcFile;
并将其添加为powershell任务。但是,任务失败如下

2017-05-30T09:37:41.1082686Z ##[section]Starting: auth-vsts
2017-05-30T09:37:41.1092712Z ==============================================================================
2017-05-30T09:37:41.1092712Z Task         : PowerShell
2017-05-30T09:37:41.1092712Z Description  : Run a PowerShell script
2017-05-30T09:37:41.1092712Z Version      : 1.2.3
2017-05-30T09:37:41.1092712Z Author       : Microsoft Corporation
2017-05-30T09:37:41.1092712Z Help         : [More Information](https://go.microsoft.com/fwlink/?LinkID=613736)
2017-05-30T09:37:41.1092712Z ==============================================================================
2017-05-30T09:37:41.1112679Z ##[command]. 'd:\a\1\s\auth-vsts.ps1' 
2017-05-30T09:37:47.3792461Z C:\NPM\Modules\vsts-npm-auth -> C:\NPM\Modules\node_modules\vsts-npm-auth\bin\vsts-npm-auth.exe
2017-05-30T09:37:47.3792461Z C:\NPM\Modules
2017-05-30T09:37:47.3802239Z `-- vsts-npm-auth@0.25.0 
2017-05-30T09:37:47.3802239Z 
2017-05-30T09:37:47.3802239Z 
2017-05-30T09:37:47.3802239Z vsts-npm-auth v0.25.0.0 
2017-05-30T09:37:47.3802239Z -----------------------
2017-05-30T09:37:47.3802239Z Creating npmrcFile. Path: D:\a\1\s\.npmrc
2017-05-30T09:37:47.3802239Z Getting new credentials for source:https://our-domain/_packaging/SharedLib/npm/registry/, scope:vso.packaging_write vso.drop_write
2017-05-30T09:37:49.8729702Z Caught exception: The prompt option is invalid because the process is not interactive.
2017-05-30T09:37:49.8729702Z Parameter name: PromptType
2017-05-30T09:37:49.8729702Z Caught exception: The prompt option is invalid because the process is not interactive.
2017-05-30T09:37:49.8729702Z Parameter name: PromptType
2017-05-30T09:37:49.8729702Z Couldn't get an authentication token for //our-domain/_packaging/SharedLib/npm/registry/:_authToken.
2017-05-30T09:37:50.1769711Z ##[error]Process completed with exit code 1.
2017-05-30T09:37:50.1809715Z ##[section]Finishing: auth-vsts

该错误没有说明它无法获取凭据的原因。知道原因吗?

错误确实指出了无法获取凭据的原因:

The prompt option is invalid because the process is not interactive.
这可能是由于生成代理未在交互模式下运行导致无法提示凭据对话框。如果您使用的是托管生成代理,则生成代理将作为服务运行,并且无法更改为交互模式


但是,这里的问题是,如果要在生成步骤中使用提要,则在生成过程中提示凭据对话框没有意义,因为生成步骤无法自动输入所需的凭据。不确定您的环境中是否有任何特定要求,但是一般的工作流程应该是将本地计算机中生成的.npmrc文件上载到源代码管理,以便npm可以使用文件中的auth令牌将包安装/发布到VSTS源。

我在尝试通过Visual Studio代码的powershell终端执行时遇到了这个问题

vsts-npm-auth -config .npmrc
但通过简单控制台运行相同的命令解决了这个问题,我被重定向到身份验证窗口


可以建议由于内部限制,禁用powershell以打开其他窗口。

好的,这是有意义的。我已经求助于上传/复制带有auth令牌的.npmrc文件,作为构建管道的一部分,以使其工作(根据OsX和Linux的VSTS/MSFT说明),您是如何分类的?您使用了什么命令标记令牌