We have a Maven build/deploy configuration which we use to build/deploy Mulesoft API's. So the build configuration POM file and settings.xml file seems ok. We can create snapshots and releases without a problem and we can push the builds to the Azure devops artifact repository.
Now I have also created a Mulesoft Java SDK plugin conform this link. The builded jar can be loaded as a dependency in other Mulesoft API's.
The problem is that I can only create releases so with Maven version tags like this:
<version>0.0.11</version>
When I create a snapshot so with the -SNAPSHOT tag which in maven POM file look like this:
<version>0.0.11-SNAPSHOT</version>
Then I get an error when running this commandline:
mvn clean deploy -DskipTests --settings C:\tools\mavenmule\conf\settingsSecretsRemoved2.xml
The error I get looks like this:
(default-deploy) on project mule-excel-hyperlink-planning-module: Failed to deploy artifacts: Could not transfer artifact nl.mycompany.mule.modules:mule-excel-hyperlink-planning-module:pom:0.0.11-20240318.202914-1 from/to mule-snapshots (https://repository-master.mulesoft.org/nexus/content/repositories/snapshots): authentication failed for https://repository-master.mulesoft.org/nexus/content/repositories/snapshots/nl/mycompany/mule/modules/mule-excel-hyperlink-planning-module/0.0.11-SNAPSHOT/mule-excel-hyperlink-planning-module-0.0.11-20240318.202914-1.pom, status: 401 Unauthorized
the maven POM file of that API file looks something like this:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<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>nl.mycompany.mule.modules</groupId>
<artifactId>mule-excel-hyperlink-planning-module</artifactId>
<version>0.0.11-SNAPSHOT</version>
<packaging>mule-extension</packaging>
<name>Mule-excel-hyperlink-planning-module Extension</name>
<parent>
<groupId>org.mule.extensions</groupId>
<artifactId>mule-modules-parent</artifactId>
<version>1.1.3</version>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<mule.maven.plugin.version>3.8.2</mule.maven.plugin.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.mule.tools.maven</groupId>
<artifactId>mule-maven-plugin</artifactId>
<version>${mule.maven.plugin.version}</version>
<extensions>true</extensions>
<configuration>
<classifier>mule-plugin</classifier>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.15.3</version>
</dependency>
</dependencies>
<!-- Azure Devops repository to -->
<repositories>
<repository>
<id>Integraties</id>
<url>https://<Azuredevopslink>/_packaging/Integraties/maven/v1</url>
<layout>default</layout>
</repository>
</repositories>
<!-- Azure Devops repository to deploy artifacts to -->
<distributionManagement>
<repository>
<id>Integraties</id>
<url>https://<Azuredevopslink>/_packaging/Integraties/maven/v1</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</distributionManagement>
<pluginRepositories>
<pluginRepository>
<id>mulesoft-releases</id>
<name>MuleSoft Releases Repository</name>
<layout>default</layout>
<url>https://repository.mulesoft.org/releases/</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</project>
And my settingsSecretsRemoved2.xml file looks like this.
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<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">
<localRepository>C:/work/mavenrepositories/***company***</localRepository>
<pluginGroups/>
<proxies/>
<servers>
<server>
<id>anypoint-exchange-v3</id>
<username>***account***</username>
<password>***secret***</password>
</server>
<server>
<id>exchange-test</id>
<username>***account***</username>
<password>***secret***</password>
</server>
<server>
<id>MuleRepository</id>
<username>***account***</username>
<password>***secret***</password>
</server>
<server>
<id>Mule-EE</id>
<username>***account***</username>
<password>***secret***</password>
</server>
<server>
<id>releases-ee</id>
<username>***account***</username>
<password>***secret***</password>
</server>
<server>
<id>mulesoft-releases-ee</id>
<username>***account***</username>
<password>***secret***</password>
</server>
<server>
<id>Integraties</id>
<username>***account***</username>
<password>***secret***</password>
</server>
-->
</servers>
<profiles>
<profile>
<id>Mule-EE</id>
<properties>
<cloudhub-username>exchange-asset-company</cloudhub-username>
<cloudhub-password>***secret***</cloudhub-password>
</properties>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<id>MuleRepository</id>
<name>MuleRepository</name>
<url>https://repository.mulesoft.org/nexus-ee/content/repositories/releases-ee/</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>
<profile>
<id>archetype-repository</id>
<repositories>
<repository>
<id>archetype</id>
<name>Mule Repository</name>
<url>https://repository.mulesoft.org/nexus-ee/content/repositories/releases-ee/</url>
<releases>
<enabled>true</enabled>
<checksumPolicy>fail</checksumPolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<checksumPolicy>warn</checksumPolicy>
</snapshots>
</repository>
</repositories>
</profile>
<profile>
<id>Integraties</id>
<repositories>
<repository>
<id>Integraties</id>
<url>https://</azuredevopslink>/_packaging/Integraties/maven/v1</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>
</settings>
So the strange thing is that the error is pointed to this repo:
https://repository-master.mulesoft.org/nexus/content/repositories/public
But I don't use that in my configuration files.
That repository is coming from the parent pom <distributionManagement>
section of the parent pom. Child poms inherit that configuration from the parent pom. In your pom you overwrote the parent <repository>
but not the <snapshotRepository>
element. You need to add that sub element to the <distributionManagement>
of your pom.
Example:
<distributionManagement>
<repository>
<id>Integraties</id>
<url>https://<Azuredevopslink>/_packaging/Integraties/maven/v1</url>
...
</repository>
<snapshotRepository>
<id>Integraties-snapshots</id>
<name>Integraties Snapshot Repository</name>
<url>https://...</url>
</snapshotRepository>
</distributionManagement>