Elan Kavi
Elan Kavi

Reputation: 1

GitHub package authentication with Maven to private package registry of other repository

The project setup is as follows:

Both are built with Maven. Project B publishes its package to the GitHub package of its private repository. Project A has a dependency on the artifact from Project B in the pom.xml.

Error

Could not resolve dependencies for project com.company.security:security:jar:0.0.1-SNAPSHOT: Failed to collect dependencies at com.company:common-util:jar:0.0.1-SNAPSHOT: Failed to read artifact descriptor for com.company:common-util:jar:0.0.1-SNAPSHOT: Could not transfer artifact com.company:common-util:pom:0.0.1-SNAPSHOT from/to github (https://maven.pkg.github.com/company/common-util): authentication failed for https://maven.pkg.github.com/username/common-util/com/company/common-util/0.0.1-SNAPSHOT/common-util-0.0.1-SNAPSHOT.pom,

I have generated the PAT with read & write access, but no luck.

Is anything I'm missing or wrong? Help me to resolve this.

Settings.xml

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                              http://maven.apache.org/xsd/settings-1.0.0.xsd">

    <servers>
       
        <server>
            <id>github</id> 
            <username>company</username> 
            <password>************</password> 
        </server>
    </servers>

    <profiles>
        <profile>
            <id>github</id> 
            <repositories>
                <repository>
                    <id>github</id> 
                    <url>https://maven.pkg.github.com/company/common-util</url> 
                    <snapshots>
                        <enabled>true</enabled>
                    </snapshots>
                </repository>
            </repositories>

            <pluginRepositories>
                <pluginRepository>
                    <id>github</id>
                    <url>https://maven.pkg.github.com/company/common-util</url>  
                </pluginRepository>
            </pluginRepositories>
        </profile>
    </profiles>

    <activeProfiles>
        <activeProfile>github</activeProfile> 
    </activeProfiles>
</settings>

project A dependency

<repositories>
        <repository>
            <id>github</id>
            <url>https://maven.pkg.github.com/company/common-util</url>
        </repository>
    </repositories>
    

Project B dependency

<distributionManagement>
        <repository>
            <id>github</id>
            <url>https://maven.pkg.github.com/company/common-util</url>
        </repository>
    </distributionManagement>

Upvotes: 0

Views: 32

Answers (0)

Related Questions