BitBucket Pipeline is failing to download maven module from Azure Artifacts feed
Asked by Victor Scurtu:

Hello,

I would like to use azure artifacts maven feed to build Spring boot app in my existing BitBucket Pipelines. The project pom is parented from artifact stored in Azure artifacts feed.  
How can I do it?

Thank you.


Answers:
author: Norbert C
body: Hello Victor,

I'm Norbert from Atlassian Support, it's nice to meet with you.

You mentioned that the project pom is parented from artifact stored in Azure artifacts feed, but it's failing to download maven module from Azure Artifacts feed.

Could you let us know what's the error message you receive when you try to do this but fails?

We're looking forward to hear from you.

comments: author: Victor Scurtu
body: Hi Norbert,  
Here is my bitbucket-pipeline.yml:  

```

image: maven:3.6.3 # Use a Maven image for building the Java app

pipelines:

default:

 - step:

script:

 - mvn -B verify -s azure-artifacts/settings.xml 

```


author: Victor Scurtu
body: The pipeline looks for parent artifact in the default location. It ignores the setting.xml I instructed maven to use.  
The error I see when pipeline fails:  

+ mvn -B verify -s azure-artifacts/settings.xml  
2  
\[INFO\] Scanning for projects...  
3  
\[INFO\] Downloading from central: <https://repo.maven.apache.org/maven2/ca/mb/wcb/wcb-azure-parent/1.0.2/>**wcb-azure-parent-1.0.2.pom**   
4  
\[ERROR\] \[ERROR\] Some problems were encountered while processing the POMs:  
5  
\[FATAL\] Non-resolvable parent POM for ca.mb.wcb:worker-service-api:0.0.1-SNAPSHOT: Could not find artifact ca.mb.wcb:wcb-azure-parent:pom:1.0.2 in central (<https://repo.maven.apache.org/maven2>) and 'parent.relativePath' points at no local POM @ line 6, column 10  
6  
@  
7  
\[ERROR\] The build could not read 1 project -\> \[Help 1\]  
8  
\[ERROR\]  
9  
\[ERROR\] The project ca.mb.wcb:worker-service-api:0.0.1-SNAPSHOT (/opt/atlassian/pipelines/agent/build/pom.xml) has 1 error  
10  
\[ERROR\] Non-resolvable parent POM for ca.mb.wcb:worker-service-api:0.0.1-SNAPSHOT: Could not find artifact ca.mb.wcb:wcb-azure-parent:pom:1.0.2 in central (<https://repo.maven.apache.org/maven2>) and 'parent.relativePath' points at no local POM @ line 6, column 10 -\> \[Help 2\]  
11  
\[ERROR\]  
12  
\[ERROR\] To see the full stack trace of the errors, re-run Maven with the -e switch.  
13  
\[ERROR\] Re-run Maven using the -X switch to enable full debug logging.  
14  
\[ERROR\]  
15  
\[ERROR\] For more information about the errors and possible solutions, please read the following articles:  
16  
\[ERROR\] \[Help 1\] <http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException>  
17  
\[ERROR\] \[Help 2\] <http://cwiki.apache.org/confluence/display/MAVEN/UnresolvableModelException>


author: Norbert C
body: Thank you for this!

The error message indicates that during the build, Maven is trying to retrieve the parent POM (`wcb-azure-parent-1.0.2.pom`) from Maven Central (<https://repo.maven.apache.org/maven2>). However, since this POM is hosted on Azure Artifacts, it's not available in Maven Central, which leads to the build failure.

Ensure that the `settings.xml` you're providing with `-s azure-artifacts/settings.xml` contains the correct repository information for Azure Artifacts. It should have something like:  

```
<repositories>
<repository>
<id>azure-maven-feed</id>
<url>YOUR_AZURE_ARTIFACTS_FEED_URL</url>
</repository>
</repositories>
```

Also, ensure authentication details for Azure Artifacts are provided, usually through `<servers>` configuration.

Please let us know if that helps.


author: Victor Scurtu
body: Thanks Norbert.  
It helped when for a single repository.   
Is there a way to make that custom settings.xml accessed globally for all the repositories?  
For example in Azure pipelines I have used a global secure settings.xml file to download and used it to call maven task to build.

Victor.


author: Norbert C
body: Hi Victor,

Unfortunately that's not possible in Bitbucket Cloud. Alternatively what you could do is you could upload the settings.xml into one of the repository's Downloads section and download it within the build: [Download artifact link](https://developer.atlassian.com/cloud/bitbucket/rest/api-group-downloads/#api-repositories-workspace-repo-slug-downloads-filename-get)


Tags: bitbucket-cloud

cloud