Je reçois une erreur 401 lors du déploiement dans Nexus. Je n'apporte aucune modification au lien installé. Nexus fonctionne sur localhost:8080/nexus
et je peux me connecter avec un utilisateur/mot de passe par défaut. Lorsque je lance mvn deploy
, j'obtiens cette erreur.
Voici mon POM.
<groupId>testproject</groupId>
<artifactId>testproject</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>testproject</name>
<url>http://maven.Apache.org</url>
<distributionManagement>
<repository>
<id>releases</id>
<url>http://localhost:8080/nexus/content/repositories/releases</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<url>http://localhost:8080/nexus/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>
<dependencies>
.........
</dependencies>
et ~/.m2/settings.xml
<servers>
<server>
<id>snapshots</id>
<username>deployment</username>
<password>deployment123</password>
</server>
<server>
<id>releases</id>
<username>deployment</username>
<password>deployment123</password>
</server>
</servers>
Exception:
Failed to execute goal org.Apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default- deploy) on project testproject: Failed to deploy artifacts: Could not transfer artifact testproject:testproject:jar:1.0-20131213.150615-1 from/to snapshots (http://localhost:8080/nexus/content/repositories/snapshots): Failed to transfer file: http://localhost:8080/nexus/content/repositories/snapshots/testproject/testproject/1.0-SNAPSHOT/testproject-1.0-20131213.150615-1.jar.
Return code is: 401 -> [Help 1]
Aidez-moi, s'il vous plaît.
Ça marche maintenant. Besoin de modifier $M2_HOME/conf/settings.xml
au lieu de /home/user/.m2/settings.xml
HTTP 401 est le code d'état pour "non autorisé", ce qui implique que votre utilisateur deployment
n'est pas autorisé à télécharger des artefacts vers ce référentiel particulier dans Nexus. Connectez-vous à Nexus et donnez à l'utilisateur deployment
le (s) rôle (s) nécessaire (s) pour modifier ce référentiel d'instantané.
Il me manquait la balise
<servers>
sur mon.m2/settings.xml
sous Gitlab-ci + MAVEN + Jfrog Artifactory:
Mon gitlab-ci.yxml
Artifactory_deploy:
stage: install
only:
- desarrollo
script:
- echo "Deploying to Artifactory"
- cd $CLONE_DIR
- mvn -X deploy
Mon .m2/settings.xml
<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
https://maven.Apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<username>${ARTIFACTORY_USER}</username>
<password>${ARTIFACTORY_PASSWORD}</password>
<id>central</id>
</server>
<server>
<username>${ARTIFACTORY_USER}</username>
<password>${ARTIFACTORY_PASSWORD}</password>
<id>snapshots</id>
</server>
</servers>
<profiles>
<profile>
<id>develop</id>
<properties>
<artifactory.ip>${ARTIFACTORY_IP}</artifactory.ip>
<artifactory.port>${ARTIFACTORY_PORT}</artifactory.port>
</properties>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>libs-release</name>
<username>admin</username>
<password>THISWASMYENCRYPTEDPASSWORD</password>
<url>http://${ARTIFACTORY_IP}:${ARTIFACTORY_PORT}/artifactory/libs-release</url>
</repository>
<repository>
<snapshots />
<id>snapshots</id>
<name>libs-snapshot</name>
<username>admin</username>
<password>THISWASMYENCRYPTEDPASSWORD</password>
<url>http://${ARTIFACTORY_IP}:${ARTIFACTORY_PORT}/artifactory/libs-snapshot</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>libs-release</name>
<username>admin</username>
<password>password</password>
<url>http://${ARTIFACTORY_IP}:${ARTIFACTORY_PORT}/artifactory/libs-release</url>
</pluginRepository>
<pluginRepository>
<snapshots />
<id>snapshots</id>
<name>libs-snapshot</name>
<username>admin</username>
<password>password</password>
<url>http://${ARTIFACTORY_IP}:${ARTIFACTORY_PORT}/artifactory/libs-snapshot</url>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>develop</activeProfile>
</activeProfiles>
</settings>
<servers>
<server>
<id>snapshots</id>
<username>deployment</username>
<password>deployment123</password>
</server>
<server>
<id>releases</id>
<username>deployment</username>
<password>deployment123</password>
</server>
</servers>