I’m setting up a CircleCI pipeline for deploying a multi-module Maven project. The project structure includes a parent project (packaged as JAR) and several service modules, all of which refer to the parent project. I have successfully set up a private Nexus repository and deployed the parent project to Nexus. Everything works fine locally, and I can download dependencies from Nexus during local builds.
However, when building the project on CircleCI using Maven 3.9.3, I’m encountering a 401 Unauthorized error when trying to access the private Nexus repository. I understand that starting from Maven 3.8.1, HTTP traffic is restricted, so I added the necessary mirror configuration in the settings.xml file to allow HTTP traffic.
Even I’m using correct credentials in the settings.xml, the build fails with the following error:
Could not resolve dependencies for project org.organization.ecommerce:shop_service:jar:1.0.0: Failed to collect dependencies at com.organization.ecommerce:parent:jar:1.0.0: Failed to read artifact descriptor for com.organization.ecommerce:parent:jar:1.0.0: The following artifacts could not be resolved: com.organization.ecommerce:parent:pom:1.0.0 (absent): Could not transfer artifact com.organization.ecommerce:parent:pom:1.0.0 from/to allow-organization-release (http://IP_ADDRESS/repository/organization-release/): status code: 401, reason phrase: Unauthorized
Nexus Repository
Settings.xml file
<settings xmlns="http://maven.apache.org/SETTINGS/1.2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.2.0 https://maven.apache.org/xsd/settings-1.2.0.xsd">
<pluginGroups>
</pluginGroups>
<proxies>
</proxies>
<servers>
<server>
<id>organization-release</id>
<username>NEXUS_USERNAME</username>
<password>NEXUS_PASSWORD</password>
</server>
<server>
<id>organization-snapshot</id>
<username>NEXUS_USERNAME</username>
<password>NEXUS_PASSWORD</password>
</server>
</servers>
<mirrors>
<mirror>
<id>central</id>
<mirrorOf>central</mirrorOf>
<url>https://repo.maven.apache.org/maven2</url>
</mirror>
<mirror>
<id>allow-organization-release</id>
<mirrorOf>*</mirrorOf>
<url>http://IP_ADDRESS:8081/repository/organization-release/</url>
<blocked>false</blocked>
</mirror>
<mirror>
<id>allow-organization-snapshot</id>
<mirrorOf>*</mirrorOf>
<url>http://IP_ADDRESS:8081/repository/organization-snapshot/</url>
<blocked>false</blocked>
</mirror>
</mirrors>
<profiles>
<profile>
<id>nexus-profile</id>
<repositories>
<repository>
<id>maven-central</id>
<url>https://repo.maven.apache.org/maven2/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>organization-release</id>
<url>http://IP_ADDRESS:8081/repository/organization-release/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>organization-snapshot</id>
<url>http://IP_ADDRESS:8081/repository/organization-snapshot/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>nexus-profile</activeProfile>
</activeProfiles>
Common libraries pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.organization.ecommerce</groupId>
<artifactId>common-libraries</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.2.4</version>
</parent>
<dependencies>
<!-- spring dependencies -->
</dependencies>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<distributionManagement>
<snapshotRepository>
<id>organization-snapshot</id>
<name>organization snapshot</name>
<url>http://IP_ADDRESS:8081/repository/organization-snapshot/</url>
</snapshotRepository>
<repository>
<id>organization-release</id>
<name>organization release</name>
<url>http://IP_ADDRESS:8081/repository/organization-release/</url>
</repository>
</distributionManagement>
</project>
Parent pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.organization.ecommerce</groupId>
<artifactId>parent</artifactId>
<version>1.0.0</version>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-bom</artifactId>
<version>1.11.1000</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>com.organization.ecommerce</groupId>
<artifactId>common-libraries</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-secretsmanager</artifactId>
</dependency>
</dependencies>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<distributionManagement>
<snapshotRepository>
<id>organization-snapshot</id>
<name>organization snapshot</name>
<url>http://IP_ADDRESS:8081/repository/organization-snapshot/</url>
</snapshotRepository>
<repository>
<id>organization-release</id>
<name>organization release</name>
<url>http://IP_ADDRESS:8081/repository/organization-release/</url>
</repository>
</distributionManagement>
</project>
Child project pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.organization.ecommerce</groupId>
<artifactId>service</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>shop-service</module>
<module>product-service</module>
<module>user-service</module>
</modules>
<dependencies>
<dependency>
<groupId>com.organization.ecommerce</groupId>
<artifactId>parent</artifactId>
<version>1.0.0</version> <!-- This artifact is not found in private nexus repository -->
</dependency>
</dependencies>
</project>
1