How to modify settings of POM file to support access tokens on Artifactory using Maven

4.7k Views Asked by At

I have a pom.xml file. How do I setup the username & password using pom.xml?

<servers>
  <server>
    <id>what needs to passed in id </id>
    <username>usename</username>
    <password>Apikey</password>
  </server>
</servers>    
1

There are 1 best solutions below

0
On

Put the <servers> block to ~/.m2/settings.xml and repositories params to pom.xml

in pom.xml:

<distributionManagement>
    <repository>
        <id>repo1</id>
        <name>our-project-releases</name>
        <url>https://our-project.artifactoryonline.com/our-project/snapshots-local</url>
    </repository>
    <snapshotRepository>
        <id>repo2</id>
        <name>our-project-snapshots</name>
        <url>https://our-project.artifactoryonline.com/our-project/snapshots-local</url>
    </snapshotRepository>
</distributionManagement>

in ~/.m2/settings.xml

<servers>
  <server>
    <id>repo1</id>
    <username>usename</username>
    <password>Apikey</password>
  </server>
  <server>
    <id>repo2</id>
    <username>usename</username>
    <password>Apikey</password>
  </server>
</servers>

Reference:

https://maven.apache.org/plugins/maven-deploy-plugin/usage.html