Npm@1 - npm v1 工作

使用此工作來安裝和發佈 npm 套件,或執行 npm 命令。 支持 npmjs.com 和驗證的登錄,例如 Azure Artifacts。

注意

npm 驗證工作是向 Azure Artifacts 進行驗證的建議方式。 這項工作不再採用新功能,而且只會解決重大錯誤。

Syntax

# npm v1
# Install and publish npm packages, or run an npm command. Supports npmjs.com and authenticated registries like Azure Artifacts.
- task: Npm@1
  inputs:
    command: 'install' # 'ci' | 'install' | 'publish' | 'custom'. Required. Command. Default: install.
    #workingDir: # string. Working folder that contains package.json. 
    #customCommand: # string. Required when command = custom. Command and arguments. 
  # Advanced
    #verbose: # boolean. Optional. Use when command = install || command = ci || command = publish. Verbose logging. 
    #publishPackageMetadata: true # boolean. Optional. Use when command = publish && publishRegistry = useFeed && command = install || command = ci || command = publish. Publish pipeline metadata. Default: true.
  # Custom registries and authentication
    #customRegistry: 'useNpmrc' # 'useNpmrc' | 'useFeed'. Optional. Use when command = install || command = ci || command = custom. Registries to use. Default: useNpmrc.
    #customFeed: # string. Required when customRegistry = useFeed && command = install || command = ci || command = custom. Use packages from this Azure Artifacts/TFS registry. 
    #customEndpoint: # string. Optional. Use when customRegistry = useNpmrc && command = install || command = ci || command = custom. Credentials for registries outside this organization/collection. 
  # Destination registry and authentication
    #publishRegistry: 'useExternalRegistry' # 'useExternalRegistry' | 'useFeed'. Optional. Use when command = publish. Registry location. Default: useExternalRegistry.
    #publishFeed: # string. Required when publishRegistry = useFeed && command = publish. Target registry. 
    #publishEndpoint: # string. Required when publishRegistry = useExternalRegistry && command = publish. External Registry.
# npm v1
# Install and publish npm packages, or run an npm command. Supports npmjs.com and authenticated registries like Azure Artifacts.
- task: Npm@1
  inputs:
    command: 'install' # 'install' | 'publish' | 'custom'. Required. Command. Default: install.
    #workingDir: # string. Working folder that contains package.json. 
    #customCommand: # string. Required when command = custom. Command and arguments. 
  # Advanced
    #verbose: # boolean. Optional. Use when command = install || command = publish. Verbose logging. 
    #publishPackageMetadata: true # boolean. Optional. Use when command = publish && publishRegistry = useFeed && command = install || command = publish. Publish pipeline metadata. Default: true.
  # Custom registries and authentication
    #customRegistry: 'useNpmrc' # 'useNpmrc' | 'useFeed'. Optional. Use when command = install || command = custom. Registries to use. Default: useNpmrc.
    #customFeed: # string. Required when customRegistry = useFeed && command = install || command = custom. Use packages from this Azure Artifacts/TFS registry. 
    #customEndpoint: # string. Optional. Use when customRegistry = useNpmrc && command = install || command = custom. Credentials for registries outside this organization/collection. 
  # Destination registry and authentication
    #publishRegistry: 'useExternalRegistry' # 'useExternalRegistry' | 'useFeed'. Optional. Use when command = publish. Registry location. Default: useExternalRegistry.
    #publishFeed: # string. Required when publishRegistry = useFeed && command = publish. Target registry. 
    #publishEndpoint: # string. Required when publishRegistry = useExternalRegistry && command = publish. External Registry.
# npm v1
# Install and publish npm packages, or run an npm command. Supports npmjs.com and authenticated registries like Package Management.
- task: Npm@1
  inputs:
    command: 'install' # 'install' | 'publish' | 'custom'. Required. Command. Default: install.
    #workingDir: # string. Working folder with package.json. 
    #customCommand: # string. Required when command = custom. Command and arguments. 
  # Advanced
    #verbose: # boolean. Optional. Use when command = install || command = publish. Verbose logging. 
  # Custom registries and authentication
    #customRegistry: 'useNpmrc' # 'useNpmrc' | 'useFeed'. Optional. Use when command = install || command = custom. Registries to use. Default: useNpmrc.
    #customFeed: # string. Required when customRegistry = useFeed && command = install || command = custom. Use packages from this Azure Artifacts/TFS registry. 
    #customEndpoint: # string. Optional. Use when customRegistry = useNpmrc && command = install || command = custom. Credentials for registries outside this account/collection. 
  # Destination registry and authentication
    #publishRegistry: 'useExternalRegistry' # 'useExternalRegistry' | 'useFeed'. Optional. Use when command = publish. Registry location. Default: useExternalRegistry.
    #publishFeed: # string. Required when publishRegistry = useFeed && command = publish. Target registry. 
    #publishEndpoint: # string. Required when publishRegistry = useExternalRegistry && command = publish. External Registry.

輸入

command - 命令
string. 必要。 允許的值:ci、、、installpublishcustom 預設值:install

指定傳遞至 npm 以進行執行的命令和自變數。

如果您的自變數包含雙引號 (") ,請使用斜線 () \ 逸出,並以雙引號括住逸出字串 (") 。


command - 命令
string. 必要。 允許值:installpublishcustom。 預設值:install

指定傳遞至 npm 以進行執行的命令和自變數。

如果您的自變數包含雙引號 (") ,請使用斜線 () \ 逸出,並以雙引號括住逸出字串 (") 。


workingDir - 包含package.json的工作資料夾
string.

指定包含目標和package.json.npmrc檔案的資料夾路徑。 選取資料夾,而不是檔案。 範例: /packages/mypackage.


workingDir - 使用package.json工作資料夾
string.

指定包含目標和package.json.npmrc檔案的資料夾路徑。 選取資料夾,而不是檔案。 範例: /packages/mypackage.


verbose - 詳細信息記錄
boolean. 選擇性。 使用時機 command = install || command = ci || command = publish

在工作執行時,將詳細資訊列印到主控台。


verbose - 詳細信息記錄
boolean. 選擇性。 使用時機 command = install || command = publish

在工作執行時,將詳細資訊列印到主控台。


customCommand - 命令和自變數
string. 當 command = custom 時為必要。

執行自定義命令。 範例: dist-tag ls mypackage.


customRegistry - 要使用的登錄
string. 選擇性。 使用時機 command = install || command = ci || command = custom。 允許的值: useNpmrc (.npmrc) 中的登錄, useFeed (登錄我在這裡選取) 。 預設值:useNpmrc

指定要使用的登錄。 將檔案認可至原始程式碼存放 .npmrc 庫,並將其路徑設定為值,或從 Azure Artifacts 指定登錄作為值。


customRegistry - 要使用的登錄
string. 選擇性。 使用時機 command = install || command = custom。 允許的值: useNpmrc (.npmrc) 中的登錄, useFeed (登錄我在這裡選取) 。 預設值:useNpmrc

指定要使用的登錄。 將檔案認可至原始程式碼存放 .npmrc 庫,並將其路徑設定為值,或從 Azure Artifacts 指定登錄作為值。


customFeed - 使用此 Azure Artifacts/TFS 登錄中的套件
string. 當 customRegistry = useFeed && command = install || command = ci || command = custom 時為必要。

在產生的 .npmrc中包含選取的摘要。 針對專案範圍的摘要,請使用 ProjectName/FeedNameProjectID/FeedID。 對於組織範圍的摘要,此值應該是摘要名稱。


customFeed - 使用此 Azure Artifacts/TFS 登錄中的套件
string. 當 customRegistry = useFeed && command = install || command = custom 時為必要。

在產生的 .npmrc中包含選取的摘要。 針對專案範圍的摘要,請使用 ProjectName/FeedNameProjectID/FeedID。 對於組織範圍的摘要,此值應該是摘要名稱。


customEndpoint - 此組織/集合外部登錄的認證
string. 選擇性。 使用時機 customRegistry = useNpmrc && command = install || command = ci || command = custom

用於位於專案 之外部登錄的 .npmrc認證。 將此帳戶/集合中的登錄保留空白;工作會自動使用組建的認證。


customEndpoint - 此組織/集合外部登錄的認證
string. 選擇性。 使用時機 customRegistry = useNpmrc && command = install || command = custom

用於位於專案 之外部登錄的 .npmrc認證。 將此帳戶/集合中的登錄保留空白;工作會自動使用組建的認證。


customEndpoint - 此帳戶/集合外部登錄的認證
string. 選擇性。 使用時機 customRegistry = useNpmrc && command = install || command = custom

用於位於專案 之外部登錄的 .npmrc認證。 將此帳戶/集合中的登錄保留空白;工作會自動使用組建的認證。


publishRegistry - 登錄位置
string. 選擇性。 使用時機 command = publish。 允許的值: useExternalRegistry (外部 npm 登入 (包括其他帳戶/集合) ) , useFeed (登錄我在這裡選取) 。 預設值:useExternalRegistry

指定命令將鎖定的登錄。


publishFeed - 目標登錄
string. 當 publishRegistry = useFeed && command = publish 時為必要。

指定裝載於帳戶中的登錄。 您必須安裝套件管理並取得授權,才能在這裡選取登錄。


publishPackageMetadata - 發佈管線元數據
boolean. 選擇性。 使用時機 command = publish && publishRegistry = useFeed && command = install || command = ci || command = publish。 預設值:true

將組建/發行管線的元數據關聯 (run # 和原始程式碼資訊,) 套件。


publishPackageMetadata - 發佈管線元數據
boolean. 選擇性。 使用時機 command = publish && publishRegistry = useFeed && command = install || command = publish。 預設值:true

將建置/發行管線的元數據關聯 (run # 和原始程式碼資訊與套件) 。


publishEndpoint - 外部登錄
string. 當 publishRegistry = useExternalRegistry && command = publish 時為必要。

指定要用於發佈至外部登錄的認證。


工作控制選項

除了工作輸入之外,所有工作都有控制選項。 如需詳細資訊,請參閱 控制選項和一般工作屬性

輸出變數

無。

備註

注意

專案集合組建服務和專案的組建服務身分識別必須設定為參與者,才能使用 Azure Pipelines 將套件發佈至摘要。 如需詳細資訊,請參閱 新增使用者/群組

我可以在哪裡瞭解 npm 命令和自變數?

範例

規格需求

需求 描述
管線類型 YAML、傳統組建、傳統版本
在上執行 Agent、DeploymentGroup
要求 自我裝載代理程式必須具備符合下列需求的功能,才能執行使用此工作的作業:npm
Capabilities 此工作不符合作業中後續工作的任何需求。
命令限制 任何
可設定變數 任何
代理程式版本 2.115.0 或更新版本
工作類別 套件
需求 描述
管線類型 YAML、傳統組建、傳統版本
在上執行 Agent、DeploymentGroup
要求 自我裝載代理程式必須具備符合下列需求的功能,才能執行使用此工作的作業:npm
Capabilities 此工作不符合作業中後續工作的任何需求。
命令限制 任何
可設定變數 任何
代理程式版本 1.91.0 或更新版本
工作類別 套件