I'm setting up a deployment pipeline for my companys mulesoft APIs using bitbucket-pipelines. This technology is attractive to us because of the built in integrations with Jira. The problem is that we are using a domain project. All of the other dependencies get downloaded from anypoint exchange, but the domain project cannot be hosted there, so I get this error:
[ERROR] Failed to execute goal on project sourceControlDemo: Could not resolve dependencies for project com.mycompany:sourceControlDemo:mule-application:1.0.0-SNAPSHOT: Could not find artifact com.mycompany:[mycompany]-domain:jar:mule-domain:1.0.0 in anypoint-exchange (https://maven.anypoint.mulesoft.com/api/v1/maven) -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal on project sourceControlDemo: Could not resolve dependencies for project com.mycompany:sourceControlDemo:mule-application:1.0.0-SNAPSHOT: Could not find artifact com.mycompany:[mycompany]-domain:jar:mule-domain:1.0.0 in anypoint-exchange (https://maven.anypoint.mulesoft.com/api/v1/maven)
In our current process, which involves building the projects locally, the domain project is included in the workspace and this error does not occur.
It seems as though there are a few strategies here: * Create a custom docker image with the dependency included - This options seems overkill, and presents the biggest skill gap for me, as I have never used docker. * Host the domain project on a private maven repo to be referenced in the dependent project pom.xml - This seems like the "normal" way to do it. However, it again seems like overkill for one dependency. * Clone the domain project repo in the pipeline file, install the project in the local repository automatically - this is the option I'd really like to go with. I've managed to clone the repo and run mvn install in its root, but upon running mule deploy in the next step, it still cannot find the dependency. I'm not sure what the file structure really looks like in the pipeline, and can't figure out how to configure the pom to look in the right place.
My bitbucket-pipelines.yml file
image: maven:3.6.1-jdk-8
pipelines:
branches:
DEV:
- step:
name: install domain project
trigger: automatic
caches:
- maven
script:
- apt-get update -y
- apt-get install -y git
- cd ..
- git clone [email protected]:[mycompany]/[mycompany]-domain.git
- cd [mycompany]-domain
- mvn install
- cd ../build
- step:
name: Build and Deploy
trigger: automatic
caches:
- maven
deployment: DEV
script:
- mvn deploy -e -DmuleDeploy
My pom.xml file for the non domain project
<?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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany</groupId>
<artifactId>sourceControlDemo</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>mule-application</packaging>
<name>sourceControlDemo</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<app.runtime>4.1.5</app.runtime>
<mule.maven.plugin.version>3.2.7</mule.maven.plugin.version>
</properties>
<build>
<finalName>${artifactId}-${BITBUCKET_BUILD_NUMBER}</finalName>
<plugins>
<plugin>
<groupId>org.mule.tools.maven</groupId>
<artifactId>mule-maven-plugin</artifactId>
<version>${mule.maven.plugin.version}</version>
<extensions>true</extensions>
<configuration>
<armDeployment>
<uri>https://anypoint.mulesoft.com</uri>
<target>${target}</target>
<targetType>${target_type}</targetType>
<username>${username}</username>
<password>${password}</password>
<environment>${environment}</environment>
<muleVersion>4.1.5</muleVersion>
</armDeployment>
</configuration>
<executions>
<execution>
<id>default-deploy</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.mycompany</groupId>
<artifactId>[mycompany]-domain</artifactId>
<version>1.0.0</version>
<classifier>mule-domain</classifier>
<scope>provided</scope>
</dependency>
</dependencies>
<repositories>
<repository>
<id>anypoint-exchange</id>
<name>Anypoint Exchange</name>
<url>https://maven.anypoint.mulesoft.com/api/v1/maven</url>
<layout>default</layout>
</repository>
<repository>
<id>mulesoft-releases</id>
<name>MuleSoft Releases Repository</name>
<url>https://repository.mulesoft.org/releases/</url>
<layout>default</layout>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>mulesoft-releases</id>
<name>mulesoft release repository</name>
<layout>default</layout>
<url>https://repository.mulesoft.org/releases/</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</project>
I've also tried this in the pom:
<dependency>
<groupId>com.mycompany</groupId>
<artifactId>[mycompany]-domain</artifactId>
<version>1.0.0</version>
<scope>system</scope>
<type>jar</type>
<classifier>mule-domain</classifier>
<systemPath>${basepath}/.m2/repository</systemPath>
</dependency>
and got this error
[ERROR] Failed to execute goal on project sourceControlDemo: Could not resolve dependencies for project com.mycompany:sourceControlDemo:mule-application:1.0.0-SNAPSHOT: Could not find artifact com.mycompany:[mycompany]-domain:jar:mule-domain:1.0.0 at specified path /root/.m2/repository -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal on project sourceControlDemo: Could not resolve dependencies for project com.mycompany:sourceControlDemo:mule-application:1.0.0-SNAPSHOT: Could not find artifact com.mycompany:[mycompany]-domain:jar:mule-domain:1.0.0 at specified path /root/.m2/repository
In case it's not clear, I've censored my company's name.
The expected result is for the project to successfully build and deploy.