이 작업을 사용하여 npm 패키지를 설치 및 게시하거나 npm 명령을 실행합니다. Azure Artifacts와 같은 npmjs.com 및 인증된 레지스트리를 지원합니다.
비고
Azure Artifacts 피드를 사용하여 인증하려면 npm 인증 작업을 사용합니다. 작업이 Npm@1 더 이상 활성 개발 중이 아니고 중요한 버그만 해결됩니다.
구문론
# 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. 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 (command = install || command = ci || command = custom) && customRegistry = useFeed. Use packages from this Azure Artifacts/TFS registry.
#customEndpoint: # string. Optional. Use when (command = install || command = ci || command = custom) && customRegistry = useNpmrc. 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.
입력
command
-
명령
string; 필수 사항입니다. 허용되는 값: ci, install, publishcustom. 기본값은 install입니다.
실행을 위해 npm 전달되는 명령 및 인수를 지정합니다.
인수에 큰따옴표(")가 포함된 경우 슬래시(\)로 이스케이프하고 이스케이프된 문자열을 큰따옴표(")로 묶습니다.
기본적으로 패키지는 로컬로 설치됩니다. 패키지를 전역적으로 설치하려면 install -g 명령으로 지정합니다. 자세한 내용은 패키지를 전역적으로 다운로드 및 설치하고 패키지를 로컬로 다운로드 및 설치하는참조하세요.
package.json포함하는 workingDir - 작업 폴더
string;
대상 package.json 및 .npmrc 파일이 포함된 폴더의 경로를 지정합니다. 파일이 아닌 폴더를 선택합니다. 예: /packages/mypackage.
자세한 정보 로깅verbose -
boolean; 선택 사항.
command = install || command = ci || 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의 레지스트리를 값으로 지정합니다.
customFeed
-
이 Azure Artifacts/TFS 레지스트리 패키지 사용
string;
(command = install || command = ci || command = custom) && customRegistry = useFeed때 필요합니다.
생성된 .npmrc선택한 피드를 포함합니다. 프로젝트 범위 피드의 경우 ProjectName/FeedName 또는 ProjectID/FeedID사용합니다. 조직 범위 피드의 경우 이 값은 피드 이름이어야 합니다.
이 조직/컬렉션외부의 레지스트리에 대한 customEndpoint - 자격 증명
string; 선택 사항.
(command = install || command = ci || command = custom) && customRegistry = useNpmrc때 사용합니다.
프로젝트의 .npmrc있는 외부 레지스트리에 사용할 자격 증명입니다. 이 계정/컬렉션의 레지스트리에 대해 이 값을 비워 둡니다. 작업은 빌드의 자격 증명을 자동으로 사용합니다.
publishRegistry
-
레지스트리 위치
string; 선택 사항.
command = publish때 사용합니다. 허용되는 값: useExternalRegistry(외부 npm 레지스트리(다른 계정/컬렉션 포함), useFeed(여기서 선택한 레지스트리). 기본값은 useExternalRegistry입니다.
명령이 대상으로 지정할 레지스트리를 지정합니다.
publishFeed
-
대상 레지스트리
string;
publishRegistry = useFeed && command = publish때 필요합니다.
계정에 호스트되는 레지스트리를 지정합니다. 여기에서 레지스트리를 선택하려면 패키지 관리가 설치되고 라이선스가 있어야 합니다.
파이프라인 메타데이터 게시
boolean; 선택 사항.
command = publish && publishRegistry = useFeed때 사용합니다. 기본값은 true입니다.
빌드/릴리스 파이프라인의 메타데이터(실행 # 및 소스 코드 정보)를 패키지와 연결합니다.
publishEndpoint
-
외부 레지스트리
string;
publishRegistry = useExternalRegistry && command = publish때 필요합니다.
외부 레지스트리에 게시하는 데 사용할 자격 증명을 지정합니다.
작업 제어 옵션
모든 작업에는 작업 입력 외에 제어 옵션이 있습니다. 자세한 내용은 컨트롤 옵션 및 일반적인 작업 속성참조하세요.
출력 변수
없음.
비고
비고
Project Collection Build Service 프로젝트의 Build Service ID를 기여자 설정하여 Azure Pipelines를 사용하여 피드에 패키지를 게시해야 합니다. 자세한 내용은 새 사용자/그룹 추가를 참조하세요.
나열된 npm 명령에 대한 자세한 내용은 어디에서 확인할 수 있나요?
예시
요구 사항
| 요구 사항 | 설명 |
|---|---|
| 파이프라인 유형 | YAML, 클래식 빌드, 클래식 릴리스 |
| 다음에서 실행 | 에이전트, DeploymentGroup |
| 요구 | 자체 호스팅 에이전트에는 다음 요구 사항과 일치하는 기능이 있어야 이 작업을 사용하는 작업을 실행해야 합니다. npm |
| 기능 | 이 작업은 작업의 후속 작업에 대한 요구 사항을 충족하지 않습니다. |
| 명령 제한 | 어느 것이든 |
| settable 변수 | 어느 것이든 |
| 에이전트 버전 | 2.115.0 이상 |
| 작업 범주 | 패키지 |