Maven build failing on Bamboo with Unauthorized error
Asked by Rohit:

Hello,

We have some dependencies in our project defined in a particular repository and while doing build on Bamboo server it fails with Unauthorized error.

This particular respository isn't defined in settings.xml of Maven_Home file so its failing with Unauthorized error. Below are bamboo build error logs.

> *build 26-Jun-2018 09:29:39 \[INFO\] Downloaded from Central: [http://repo1.maven.org/maven2/org/apache/ant/ant-parent/1.9.6/ant-parent-1.9.6.pom](http://scanmail.trustwave.com/?c=7422&d=rJCy2xZM9rXAeyovSUrK4um74uqptD1pbMILsnPr9A&u=http%3a%2f%2frepo1%2emaven%2eorg%2fmaven2%2forg%2fapache%2fant%2fant-parent%2f1%2e9%2e6%2fant-parent-1%2e9%2e6%2epom) (5.6 kB at 28 kB/s)*
>
> *build 26-Jun-2018 09:29:39 \[INFO\] Downloading from Central: [http://repo1.maven.org/maven2/org/apache/ant/ant-launcher/1.9.6/ant-launcher-1.9.6.pom](http://scanmail.trustwave.com/?c=7422&d=rJCy2xZM9rXAeyovSUrK4um74uqptD1pbMAHuSLs_g&u=http%3a%2f%2frepo1%2emaven%2eorg%2fmaven2%2forg%2fapache%2fant%2fant-launcher%2f1%2e9%2e6%2fant-launcher-1%2e9%2e6%2epom)*
>
> *build 26-Jun-2018 09:29:39 \[INFO\] Downloaded from Central: [http://repo1.maven.org/maven2/org/apache/ant/ant-launcher/1.9.6/ant-launcher-1.9.6.pom](http://scanmail.trustwave.com/?c=7422&d=rJCy2xZM9rXAeyovSUrK4um74uqptD1pbMAHuSLs_g&u=http%3a%2f%2frepo1%2emaven%2eorg%2fmaven2%2forg%2fapache%2fant%2fant-launcher%2f1%2e9%2e6%2fant-launcher-1%2e9%2e6%2epom) (2.3 kB at 12 kB/s)*
>
> *build 26-Jun-2018 09:29:39 \[INFO\] ------------------------------------------------------------------------*
>
> *build 26-Jun-2018 09:29:39 \[INFO\] BUILD FAILURE*
>
> *build 26-Jun-2018 09:29:39 \[INFO\] ------------------------------------------------------------------------*
>
> *build 26-Jun-2018 09:29:39 \[INFO\] Total time: 01:46 min*
>
> *build 26-Jun-2018 09:29:39 \[INFO\] Finished at: 2018-06-26T09:29:39Z*
>
> *build 26-Jun-2018 09:29:39 \[INFO\] Final Memory: 22M/249M*
>
> *build 26-Jun-2018 09:29:39 \[INFO\] ------------------------------------------------------------------------*
>
> ***build 26-Jun-2018 09:29:39 \[ERROR\] Failed to execute goal on project cs-monitor-p: Could not resolve dependencies for project com.mycompany:cs-monitor-p:mule:1.0.0-SNAPSHOT: Failed to collect dependencies at com.mulesoft.muleesb:mule-core-ee:jar:3.9.0: Failed to read artifact descriptor for com.mulesoft.muleesb:mule-core-ee:jar:3.9.0: Could not transfer artifact com.mulesoft.muleesb:mule-core-ee:pom:3.9.0 from/to mule-ee-releases ([https://repository-master.mulesoft.org/nexus/content/repositories/releases-ee/](http://scanmail.trustwave.com/?c=7422&d=rJCy2xZM9rXAeyovSUrK4um74uqptD1pbJRRsiXv-g&u=https%3a%2f%2frepository-master%2emulesoft%2eorg%2fnexus%2fcontent%2frepositories%2freleases-ee%2f)): Not authorized , ReasonPhrase:Unauthorized. -\> \[Help 1\]***
>
> *build 26-Jun-2018 09:29:39 \[ERROR\]*
>
> *build 26-Jun-2018 09:29:39 \[ERROR\] To see the full stack trace of the errors, re-run Maven with the -e switch.*
>
> *build 26-Jun-2018 09:29:39 \[ERROR\] Re-run Maven using the -X switch to enable full debug logging.*
>
> *build 26-Jun-2018 09:29:39 \[ERROR\]*
>
> *build 26-Jun-2018 09:29:39 \[ERROR\] For more information about the errors and possible solutions, please read the following articles:*
>
> *build 26-Jun-2018 09:29:39 \[ERROR\] \[Help 1\] [http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException](http://scanmail.trustwave.com/?c=7422&d=rJCy2xZM9rXAeyovSUrK4um74uqptD1pbMJXsHPs_Q&u=http%3a%2f%2fcwiki%2eapache%2eorg%2fconfluence%2fdisplay%2fMAVEN%2fDependencyResolutionException)*
>
> *simple 26-Jun-2018 09:29:39 Failing task since return code of \[/usr/share/apache-maven/bin/mvn --batch-mode -Djava.io.tmpdir=/opt/atlassian/atlassian-bamboo-6.5.0/temp/IM-CSMON-JOB1 clean test\] was 1 while expected 0*
>
> *simple 26-Jun-2018 09:29:39 Parsing test results under /efs/bamboo/xml-data/build-dir/IM-CSMON-JOB1...*

Is it possible to pass the repository as Environmental Variables and then execute build plan? I wanted to execute Maven build without changing settings.xml on Bamboo server and pass the server details as some sort of arguments. Below are server details from settings.xml from local and this needs to be added to Maven build on server at runtime of build plan.
> \<server\>
>
> \<id\>MuleRepository\</id\>
>
> \<username\>xxxxxxxxxx\</username\>
>
> \<password\>xxxxxxx\</password\>
>
> \</server\>

[@Gabriel Ribeiro](/t5/user/viewprofilepage/user-id/352687)

Please let me know how to achieve this


Answers:
author: Rohit
body: [@bhagyashree khedkar](/t5/user/viewprofilepage/user-id/1874657) its resolved, can you share the error logs ? is Maven configured on Bamboo server i.e in settings.xml ?

comments: author: bhagyashree khedkar
body: Below is the error,

Its mule application and I want to setup CICD using bitbucket pipeline.![Screenshot 2018-10-29 at 14.30.49.png](https://community.atlassian.com/t5/image/serverpage/image-id/36159i87C1D02F609DDFD7/image-size/large?v=v2&px=999 "Screenshot 2018-10-29 at 14.30.49.png")  


author: Rohit
body: we have been using Bamboo for CI/CD and what you are using is quite different Bitbucket Pipepline for CI/CD.

But the issue looks same, the project couldn't fetch the dependencies required for Maven build. You need to update settings.xml file with nexus repository credentials.

As you set up Maven on your local machine do the same on the bitbucket server pipeline also.

check if this helps

<https://community.atlassian.com/t5/Bitbucket-questions/settings-xml-configuration-on-Pipelines/qaq-p/167693>


author: bhagyashree khedkar
body: Hi Rohit,

Have you solved above issue?

I am getting the same error, please help


author: Gonchik Tsymzhitov
body: Hello,

Instead of work with paramaters in this situation, to my understand, it will be better if you setup maven proxy.

* <https://medium.com/@petehouston/execute-maven-behind-a-corporate-proxy-network-5e08d075f744>
* <https://maven.apache.org/repository-management.html>
* <https://github.com/timboudreau/tiny-maven-proxy>

Then you can achieve central place for manage settings.

Cheers,

Gonchik Tsymzhitov

comments: author: Rohit
body: [@Gonchik Tsymzhitov](/t5/user/viewprofilepage/user-id/1131802) I'm sorry, i didn't understand what you are trying to say above.

Maven build is failing since my build plan needs access to remote repository which is not mentioned in settings.xml file on Bamboo server.

As far i know i need to add server configuration to settings.xml on bamboo server but without doing above how can i specify directly in my build plan about the remote respository ?

Hope you got what i'm trying to say.

Thanks


author: Rohit
body: [@Marcin Gardias](/t5/user/viewprofilepage/user-id/781649) [@Foong](/t5/user/viewprofilepage/user-id/502088)