Access denied error when deploying artifact to Archiva remote repo - maven-3

I am trying to deploy project artifact into Archiva remote repository but keeps getting this error:
Error Message:
[INFO] --- maven-deploy-plugin:2.8.1:deploy (default-deploy) # mavenandroidapplication ---
Downloading: http://192.168.10.29:8080/archiva/repository/snapshots/com/stm/idg/android/mavenandroidapplication/1.0-SNAPSHOT/maven-metadata.xml
Uploading: http://192.168.10.29:8080/archiva/repository/snapshots/com/stm/idg/android/mavenandroidapplication/1.0-SNAPSHOT/mavenandroidapplication-1.0-20131105.013101-1.apk
Uploading: http://192.168.10.29:8080/archiva/repository/snapshots/com/stm/idg/android/mavenandroidapplication/1.0-SNAPSHOT/mavenandroidapplication-1.0-20131105.013101-1.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.707s
[INFO] Finished at: Tue Nov 05 09:31:01 SGT 2013
[INFO] Final Memory: 16M/39M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8.1:deploy (default-deploy) on project mavenandroidapplication: Failed to deploy artifacts: Could not transfer artifact com.stm.idg.android:mavenandroidapplication:apk:1.0-20131105.013101-1 from/to archiva.snapshots (http://192.168.10.29:8080/archiva/repository/snapshots/): Access denied to http://192.168.10.29:8080/archiva/repository/snapshots/com/stm/idg/android/mavenandroidapplication/1.0-SNAPSHOT/mavenandroidapplication-1.0-20131105.013101-1.apk. Error code 401, Unauthorized -> [Help 1]
I am using Maven 3.0.5, Archiva 1.3.6, Android Development Kit. This is a maven project and I execute via Run As --> Maven build --> (Goals) deploy.
Below are the configurations:
Settings.xml
Note:
<server>
<id>archiva.internal</id>
<username>admin</username>
<password>123</password>
</server>
<server>
<id>archiva.snapshots</id>
<username>admin</username>
<password>123</password>
</server>
Pom.xml
<distributionManagement>
<repository>
<id>archiva.internal</id>
<name>Internal Release Repository</name>
<url>http://192.168.10.29:8080/archiva/repository/internal/</url>
</repository>
<snapshotRepository>
<id>archiva.snapshots</id>
<name>Internal Snapshot Repository</name>
<url>http://192.168.10.29:8080/archiva/repository/snapshots/</url>
</snapshotRepository>
</distributionManagement>
Really appreciate your help. Thank you.

A few suggestions:
1.) Ensure that you have all your servers listed in your Maven settings.xml. This gets me sometimes.
2.) Ensure that your snapshot repo id matches the repo id defined within Archiva.
3.) Ensure that you have access to the snapshots repo, even as admin. Permissions can be revoked.
4.) Ensure that you have the right password.
5.) I've had a restart of Archiva fix this problem before.
6.) And, finally, ensure that you have the following settings.xml config in place. This solution doesn't quite fit your scenario, but it's good to list nonetheless. The following config will allow you to deploy snapshots to a custom snapshots repo that's part of a repository group (i.e. - a snapshots repo for a particular team):
<mirror>
<id><repo_group_id></id>
<mirrorOf>*, !<team_snapshot_repo_id></mirrorOf>
<name>My Team's Maven Repository</name>
<url>http://<HOST>:<PORT>/archiva/repository/<repo_group_id>/</url>
</mirror>

Related

Gitlab-runner docker executor trying to download maven dependencies

I've got a gitalb-runner running as a docker container.
This is my failed job for a mvn test command:
Running with gitlab-runner 10.4.0 (857480b6)
on mvn-build (ae93a255)
Using Docker executor with image maven:3.3.9-jdk-8 ...
Using docker image sha256:b4b185fdfd711067c07e8a1df1257645aff2781402dc147e52d9a09636f9a139 for predefined container...
Pulling docker image maven:3.3.9-jdk-8 ...
Using docker image maven:3.3.9-jdk-8 ID=sha256:9997d8483b2fc521a4159feab922546dda0c5c22b5084f86dfab48f123ae4364 for build container...
Running on runner-ae93a255-project-2-concurrent-0 via 49682264df2f...
Fetching changes...
HEAD is now at e197d19 Fixed yml
Checking out e197d191 as dev...
Skipping Git submodules setup
$ echo "Building project with maven"
Building project with maven
$ mvn $MAVEN_OPTS test
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building rest-client
[INFO] ------------------------------------------------------------------------
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-resources-plugin/2.6/maven-resources-plugin-2.6.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 21.626 s
[INFO] Finished at: 2018-02-21T15:00:07+00:00
[INFO] Final Memory: 9M/118M
[INFO] ------------------------------------------------------------------------
[ERROR] Plugin org.apache.maven.plugins:maven-resources-plugin:2.6 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin:jar:2.6: Could not transfer artifact org.apache.maven.plugins:maven-resources-plugin:pom:2.6 from/to central (https://repo.maven.apache.org/maven2): Connect to repo.maven.apache.org:443 [repo.maven.apache.org/151.101.12.215] failed: Connection refused (Connection refused) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException
ERROR: Job failed: exit code 1
My question is do I really need to set up a proxy and have an internet connection?
Or there is any other option to provide maven with that missing plugin?
I mention that I've already configured repo mapping in config.toml:
oncurrent = 1
check_interval = 0
[[runners]]
name = "mvn-build"
url = "http://192.168.233.128/"
token = "ae93a255f60d0e1abdb26cc9f72cd5"
executor = "docker"
[runners.docker]
tls_verify = false
image = "maven:3.3.9-jdk-8"
privileged = false
disable_cache = false
volumes = ["/cache","/var/run/docker.sock:/var/run/docker.sock","/root/.m2/repository/:/root/.m2/repository/"]
shm_size = 0
[runners.cache]
The Maven plugins are locally cached in the .m2/repository folder so you can make sure that all the needed plugins and dependencies are available in the /root/.m2/repository/ folder of the server/VM hosting the gitlab-runner. For example by running once the mvn test on the server.
You would probably want to avoid that as any time a dependency is changed you would need to ssh into the build server and update the local Maven cache there.
Considering this, setting up a proxy and internet connection once would not be that bad. Unless you have some other restrictions and/or would like to avoid downloading dependencies from external maven repos.
In this case maybe it is best to setup a maven repository within the organization which caches any external dependencies from Maven central

How to publish/use SNAPSHOT Maven Archetypes

I'm trying to generate a SNAPSHOT maven archetype, publish it to Sonatype's OSS repo: https://oss.sonatype.org/content/repositories/snapshots/funcatron/starter/
The publishing happens correctly. However, when I try to mvn archetype:generate from the SNAPSHOT, things do not work:
mvn archetype:generate -B \
-DarchetypeGroupId=funcatron \
-DarchetypeArtifactId=starter \
-DarchetypeVersion=0.3.0-SNAPSHOT \
-DgroupId=my.stellar \
-DartifactId=thang \
-DarchetypeRepository=https://oss.sonatype.org/content/repositories/snapshots/
The archetype is not found:
[INFO] Generating project in Batch mode
[WARNING] Archetype not found in any catalog. Falling back to central repository.
[WARNING] Add a repsoitory with id 'archetype' in your settings.xml if archetype's repository is elsewhere.
[WARNING] The POM for funcatron:starter:jar:0.3.0-SNAPSHOT is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
So... what am I doing wrong? Is there something I should be adding to the pom.xml to publish the SNAPSHOT artifact so it can be found via mvn archetype:generate?
Thanks!
In your settings.xml add archetype repository:
<repository>
<id>archetype</id>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</repository>

The SonarQube Post-build Action is deprecated

Using Jenkins 1.642.2 for code analysis with SonarQube 5.6.1 for all my maven projects.
When I use maven goal sonar:sonar they take more time to analyse files (more than 7 seconds by file) :
[INFO] Sensor SCM Sensor
[INFO] SCM provider for this project is: svn
[INFO] 1079 files to be analyzed
[INFO]
[INFO] 2/1079 files analyzed
[INFO] 3/1079 files analyzed
[INFO] 4/1079 files analyzed
[INFO] 5/1079 files analyzed
When I use the SonarQube Scanner with this config :
then i have this error :
WARN: Property 'sonar.jdbc.url' is not supported any more. It will be ignored. There is no longer any DB connection to the SQ database.
WARN: Property 'sonar.jdbc.username' is not supported any more. It will be ignored. There is no longer any DB connection to the SQ database.
WARN: Property 'sonar.jdbc.password' is not supported any more. It will be ignored. There is no longer any DB connection to the SQ database.
INFO: User cache: /var/lib/jenkins/.sonar/cache
INFO: Load plugins index
INFO: Load plugins index (done) | time=43ms
INFO: SonarQube server 5.6.1
INFO: Default locale: "en_US", source code encoding: "UTF-8" (analysis is platform dependent)
INFO: Process project properties
INFO: ---------------------------------------------------------------------- --
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 1.621s
INFO: Final Memory: 39M/132M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarQube Scanner execution
ERROR: You must define the following mandatory properties for 'Unknown': sonar.projectKey, sonar.projectName, sonar.projectVersion, sonar.sources
ERROR:
ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging.
Build step 'Execute SonarQube Scanner' marked build as failure
Finished: FAILURE
My settings file :
<profile>
<id>sonar</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<sonar.jdbc.url>
jdbc:mysql://11.230.5.88:3306/sonar
</sonar.jdbc.url>
<sonar.jdbc.username>sonar</sonar.jdbc.username>
<sonar.jdbc.password>sonar</sonar.jdbc.password>
<!-- Optional URL to server. Default value is http://localhost:9000 -->
<sonar.host.url>
http://sonarqube-groupe.com/
</sonar.host.url>
</properties>
</profile>
Any idea to solve this problem because i have a problem to understand the new sonarqube use
i must make a sonar-project.properties file for the maven project?
You can and should still analyze with Maven, using a Build Step. As stated in the docs, you should first "Enable injection of SonarQube server configuration" at the global configuration level, and then in your build enable the Build Environment Option "Prepare SonarQube Scanner environment". Then you can set your Maven goal to the following:
$SONAR_MAVEN_GOAL -Dsonar.host.url=$SONAR_HOST_URL -Dsonar.login=$SONAR_AUTH_TOKEN

Non-resolvable parent POM: When building Maven 3 Project Site

I am currently facing the following problem with Maven 3 when I am trying to build the site. I will appreciate you help on this.
mvn clean site
..........
[INFO] Reactor Summary:
[INFO]
[INFO] Project A ......................................... SUCCESS [15.383s]
[INFO] Project B ......................................... SUCCESS [2.232s]
[INFO] My Site ........................................... FAILURE [0.105s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 24.769s
[INFO] Finished at: Fri Jun 29 14:26:04 AMT 2012
[INFO] Final Memory: 18M/150M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-site-plugin:3.1:site (default-site) on project site: SiteToolException: Unable to read local module-POM: 1 problem was encountered while building the effective model for my.com:projA:0.1-SNAPSHOT
[ERROR] [FATAL] Non-resolvable parent POM: Could not find artifact my.com:parent-pom:pom:0.1-SNAPSHOT and 'parent.relativePath' points at no local POM # line 12, column 13
[ERROR] for project my.com:projA:0.1-SNAPSHOT
.............
First here is the configuration:
Apache Maven 3.0.4 (r1232337; 2012-01-17 12:44:56+0400)
Java version: 1.7.0_04, vendor: Oracle Corporation
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.7.4", arch: "x86_64", family: "mac"
Nexus repository: 2.0.6
The parent POM:
<modelVersion>4.0.0</modelVersion>
<name>Parent POM</name>
<groupId>my.com</groupId>
<artifactId>parent-pom</artifactId>
<version>0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.1</version>
<configuration>
<reportPlugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.4</version>
</plugin>
</reportPlugins>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
The aggregation project pom:
<modelVersion>4.0.0</modelVersion>
<name>My Site</name>
<groupId>my.com</groupId>
<artifactId>site</artifactId>
<version>0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<parent>
<groupId>my.com</groupId>
<artifactId>parent-pom</artifactId>
<version>0.1-SNAPSHOT</version>
<relativePath/>
</parent>
<modules>
<module>projA</module>
<module>projB</module>
</modules>
The pom of Project A:
<modelVersion>4.0.0</modelVersion>
<name>Project A</name>
<groupId>my.com</groupId>
<artifactId>projA</artifactId>
<version>0.1-SNAPSHOT</version>
<parent>
<groupId>my.com</groupId>
<artifactId>parent-pom</artifactId>
<version>0.1-SNAPSHOT</version>
<relativePath/>
</parent>
The pom of Project B:
4.0.0
<name>Project B</name>
<groupId>my.com</groupId>
<artifactId>projB</artifactId>
<version>0.1-SNAPSHOT</version>
<parent>
<groupId>my.com</groupId>
<artifactId>parent-pom</artifactId>
<version>0.1-SNAPSHOT</version>
<relativePath/>
</parent>
Here is the structure of the folder where I run "mvn clean site":
./pom.xml (aggregation project)
./projA/pom.xml (Project A)
./projB/pom.xml (Project B)
parent-pom is successfully deployed to NEXUS repository before the execution of mvn clean site with following command mvn deploy -DaltDeploymentRepository=snapshots::default::http://MyServer:8081/nexus/content/repositories/snapshots
And finally the problem itself:
When I run mvn clean site right after the deployment of parent-pom site is built successfully. If I delete the folder (with its content) "my" (it contains the parent-pom) from the local repository (~/.m2/repository) and then try to build the site with mvn clean site I am getting the error described at the beginning. Actually Maven downloads the parent-pom from the NEXUS. I have compared the downloaded files and files which have been generated after the deployment and have realized that few are missing, for instance maven-metadata-local.xml near to "0.1-SNAPSHOT" folder.
So when I am trying to run the site building job from Jenkins I am getting the error described above, because the parent-pom is not deployed from the machine where Jenkins run.
How can I come up with this problem or what I did wrong?
Thank you.
As pointed out by this answer, there is a bug in the site plugin, which only looks for dependencies in what it thinks is Maven central.
I am having the same problem in Maven 3.0.4 and site-plugin 3.3 . I also have the issue that it works in my development machine which is running Windows 7, but not in the CI-Server which is running Jenkins on Debian.
The problem is not in your pom files. When I built your aggregation-pom, Maven downloaded normally the parent-pom from the remote repo (after I deleted from my local repo).
Try this:
mvn -U clean install site dependency:purge-local-repository
Additionally, you could do some clean up:
remove <relativePath/> from all of them
remove <version>0.1-SNAPSHOT</version> and <groupId>my.com</groupId> from projA and ProjB (they are inherited from the parent)
I got the same problem... works on my developer MacBook, but fails on my Jenkins running on RHEL7 when running mvn site using maven-site-plugin:3.7. I did not test to downgrade the site plugin.
I found another solution. The problem in my case was the maven-project-info-reports-plugin especially the goal dependencies. If I skip the goal with -Dmpir.skip=true my site get's generated (without the dependencies :( report).

Not created by default settings.xml in $/user/.m2/repository path using Maven

I tried below command its work properly
C:\Documents and Settings\users>mvn -v
Apache Maven 3.0 (r1004208; 2010-10-04 17:20:56+0530)
Java version: 1.6.0_21
Java home: C:\Program Files\Java\jdk1.6.0_21\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows xp" version: "5.1" arch: "x86" Family: "windows"
and once I tried to compile simple HelloWorld.java program. Its give me below error...
C:\my-app>mvn compile
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Quick Start Archetype 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
Downloading: repo1.maven.org/maven2/org/apache/maven/plugins/maven-resour
ces-plugin/2.4.3/maven-resources-plugin-2.4.3.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.454s
[INFO] Finished at: Thu Nov 18 13:08:50 IST 2010
[INFO] Final Memory: 1M/15M
[INFO] ------------------------------------------------------------------------
[ERROR] Plugin org.apache.maven.plugins:maven-resources-plugin:2.4.3 or one of i
ts dependencies could not be resolved: Could not transfer artifact org.apache.ma
ven.plugins:maven-resources-plugin:jar:2.4.3 from central (http://repo1.maven.or
g/maven2): Error transferring file: Connection refused: connect -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
ch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResoluti
onException
Please any one update me with proper solutions.
First, you really should format your questions better. Just cutting and pasting without any regard what it would look like when submitted doesn't help you in getting a quick and concise answer.
Second, what exactly is your question? You subject says one thing, but your text says another.
Now I'll take a stab at both your subject and your text.
As far as the subject is concerned, the settings.xml file is not automatically created by Maven. You have to create this and configure it the way you want. See this website for more info about the settings.xml.
As far as the text is concerned, looks like you do not have access to the Maven repo. This can because by a number things. The most obvious ones are:
The repository is not specified in the project's pom.xml file as described here.
The server you are running this on does not have access to http://repo1.maven.org/maven2/ due to firewall or internet connectivity reasons.
Double check that:
this was not an intermittent problem
you didn't get bad metadata (and clean up the entire ~/.m2/repository/org/apache/maven/plugins/maven-resources-plugin/)

Resources