Share via


MavenAuthenticate@0 - Maven 인증 v0 작업

이 작업을 사용하여 Azure Artifacts 피드 및 외부 Maven 리포지토리에 대한 자격 증명을 제공합니다.

Syntax

# Maven Authenticate v0
# Provides credentials for Azure Artifacts feeds and external maven repositories.
- task: MavenAuthenticate@0
  inputs:
    #artifactsFeeds: # string. Feeds. 
    #mavenServiceConnections: # string. Credentials for repositories outside this organization/collection.

입력

artifactsFeeds - 피드
string.

Maven을 사용하여 인증할 Azure Artifacts 피드 이름의 쉼표로 구분된 목록을 지정합니다. 외부 Maven 리포지토리에 대한 인증만 필요한 경우 이 필드를 비워 둡니다.


mavenServiceConnections - 이 조직/컬렉션 외부의 리포지토리에 대한 자격 증명
string.

Maven을 사용하여 인증할 외부 조직의 Maven 서비스 연결 이름 목록을 쉼표로 구분하여 지정합니다. Azure Artifacts 피드에 대한 인증만 필요한 경우 이 필드를 비워 둡니다.


작업 제어 옵션

모든 작업에는 작업 입력 외에 제어 옵션이 있습니다. 자세한 내용은 컨트롤 옵션 및 일반적인 작업 속성을 참조하세요.

출력 변수

없음

설명

현재 사용자 settings.xml 파일의 Azure Artifacts 피드 및 외부 Maven 리포지토리에 대한 자격 증명을 지정합니다.

settings.xml 인증된 리포지토리가 포함된 파일은 어디에 있나요?

Maven 인증 태스크는 현재 사용자의 홈 디렉터리에서 파일을 검색 settings.xml 합니다. Linux 및 Mac의 경우 경로는 입니다 $HOME/.m2/settings.xml. Windows의 경우 경로는 입니다 %USERPROFILE%\.m2\settings.xml. settings.xml 파일이 없으면 해당 경로에 새 파일이 만들어집니다.

스위치를 mvn -s 사용하여 자체 settings.xml 파일을 지정합니다. Azure Artifacts 피드를 인증하려면 어떻게 해야 할까요?

Maven 인증 작업에는 스위치를 사용하여 -s 지정한 사용자 지정 settings.xml 파일에 액세스할 수 없습니다. 사용자 지정 settings.xml에 Azure Artifacts 인증을 추가하려면 파일 내에 서버 요소를 추가합니다 settings.xml .

<server>
  <id>feedName</id> <!-- Set this to the id of the <repository> element inside your pom.xml file. -->
  <username>AzureDevOps</username>
  <password>${env.SYSTEM_ACCESSTOKEN}</password>
</server>

액세스 토큰 변수는 다음 지침을 사용하여 파이프라인에서 설정할 수 있습니다.

내 파이프라인이 다른 프로젝트의 피드에 액세스해야 합니다.

파이프라인이 피드를 호스트하는 프로젝트와 다른 프로젝트에서 실행되는 경우 빌드 서비스에 대한 읽기/쓰기 액세스 권한을 부여하도록 다른 프로젝트를 설정해야 합니다. 자세한 내용은 Azure Pipelines의 패키지 권한을 참조하세요.

예제

조직 내에서 Maven 피드 인증

이 예제에서는 조직 내에서 두 개의 Azure Artifacts 피드를 인증합니다.

작업 정의

- task: MavenAuthenticate@0
  displayName: 'Maven Authenticate'
  inputs:
    artifactsFeeds: MyFeedInOrg1,MyFeedInOrg2

작업은 MavenAuthenticate 에 있는 에이전트 사용자의 .m2 디렉터리에 있는 {user.home}/.m2/settings.xml 파일을 업데이트 settings.xml 하여 요소 내에 <servers> 두 개의 항목을 추가합니다.

settings.xml

<servers>
  <server>
    <id>MyFeedInOrg1</id>
    <username>AzureDevOps</username>
    <password>****</password>
  </server>
  <server>
    <id>MyFeedInOrg2</id>
    <username>AzureDevOps</username>
    <password>****</password>
  </server>
</servers>

작업을 올바르게 인증하려면 프로젝트의 pom.xml 리포지토리를 Maven 작업에 지정된 이름과 동일하게 <id> 설정합니다.

pom.xml

프로젝트 범위 피드

 <repository>
   <id>MyFeedInOrg1</id>
   <url>https://pkgs.dev.azure.com/OrganizationName/ProjectName/_packaging/MyProjectScopedFeed1/Maven/v1</url>
   <releases>
     <enabled>true</enabled>
   </releases>
   <snapshots>
     <enabled>true</enabled>
   </snapshots>
 </repository>

조직 범위 피드

 <repository>
   <id>MyFeedInOrg1</id>
   <url>https://pkgs.dev.azure.com/OrganizationName/_packaging/MyOrgScopedFeed1/Maven/v1</url>
   <releases>
     <enabled>true</enabled>
   </releases>
   <snapshots>
     <enabled>true</enabled>
   </snapshots>
 </repository>

아티팩트 피드 URL은 프로젝트를 포함하거나 포함하지 않을 수 있습니다. 프로젝트 범위 피드의 URL은 프로젝트를 포함해야 하며 조직 범위 피드의 URL에는 프로젝트가 포함되어서는 안됩니다. 프로젝트 범위 피드에 대해 자세히 알아봅니다.

조직 외부의 Maven 피드 인증

이 예제에서는 두 개의 외부 Maven 리포지토리를 인증합니다.

작업 정의

- task: MavenAuthenticate@0
  displayName: 'Maven Authenticate'
  inputs:
    MavenServiceConnections: central,MavenOrg

작업은 MavenAuthenticate 에 있는 에이전트 사용자의 .m2 디렉터리에 있는 {user.home}/.m2/settings.xml 파일을 업데이트 settings.xml 하여 요소 내에 <servers> 두 개의 항목을 추가합니다.

settings.xml

<servers>
  <server>
    <id>central</id>
    <username>centralUsername</username>
    <password>****</password>
  </server>
  <server>
    <id>MavenOrg</id>
    <username>mavenOrgUsername</username>
    <password>****</password>
  </server>
</servers>

작업을 올바르게 인증하려면 프로젝트의 pom.xml 리포지토리를 Maven 작업에 지정된 이름과 동일하게 <id> 설정합니다.

pom.xml

<repository>
  <id>central</id>
  <url>https://repo1.maven.org/maven2/</url>
  <releases>
    <enabled>true</enabled>
  </releases>
  <snapshots>
    <enabled>true</enabled>
  </snapshots>
</repository>

요구 사항

요구 사항 Description
파이프라인 유형 YAML, 클래식 빌드, 클래식 릴리스
실행 중 에이전트, DeploymentGroup
요청 없음
Capabilities 이 작업은 작업의 후속 작업에 대한 요구 사항을 충족하지 않습니다.
명령 제한 사항 모두
설정 가능한 변수 모두
에이전트 버전 2.144.0 이상
작업 범주 패키지
요구 사항 Description
파이프라인 유형 YAML, 클래식 빌드, 클래식 릴리스
실행 중 에이전트, DeploymentGroup
요청 없음
Capabilities 이 작업은 작업의 후속 작업에 대한 요구 사항을 충족하지 않습니다.
명령 제한 사항 모두
설정 가능한 변수 모두
에이전트 버전 2.120.0 이상
작업 범주 패키지