2017-05-30 32 views
0

我試圖使用vsts-npm-auth獲取我們的VSTS軟件包存儲庫的身份驗證令牌。在我的機器,我可以運行的命令vsts-npm-auth無法在VSTS版本上獲取身份驗證令牌

npm install -g vsts-npm-auth vsts-npm-auth -config path-to-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 `-- [email protected] 
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 

該錯誤沒有指出爲什麼它無法獲得憑據。任何想法,爲什麼這可能是?

回答

1

錯誤並說明爲什麼它不能獲得證書:

The prompt option is invalid because the process is not interactive. 

這可以通過生成代理造成的互動模式,使憑據對話框不能促使不運行。如果您使用的是託管構建代理,則構建代理將作爲服務運行,並且無法更改爲交互模式。

但是,這裏的問題是,如果您想在構建步驟中使用該提要,則在構建過程中提示憑據對話框沒有意義,因爲構建步驟無法自動輸入所需的憑據。不確定在您的環境中是否有任何特定需求,但是一般工作流程應該將本地計算機中生成的.npmrc文件上傳到源代碼管理,以便npm可以使用該文件中的身份驗證令牌來安裝/發佈軟件包到VSTS飼料。

+0

好的,這是有道理的。我已經使用auth令牌上傳/複製.npmrc文件作爲構建管道的一部分,以使其工作(根據VSX/Linux的VSTS/MSFT指令) –

相關問題