micha149 / gulp-maven-deploy

Gulp wrapper for the maven-deploy plugin
MIT License
12 stars 11 forks source link

How can i deploy artifacts from jenkins to nexus with a user not anonymos ? #18

Closed hatem-hadrich closed 6 years ago

hatem-hadrich commented 7 years ago

I have 3 zip files in the workspace of jenkins inside the directory target and i'm using a job with free-style project for a php application. I want to deploy those artifacts to my repository Nexus but when i use an anonymos user this task works very well, but in the other way when i use a user that have a username and password in this step i get an error Not authorized , ReasonPhrase:Unauthorized.

var gulp = require('gulp'), maven = require('gulp-maven-deploy');

gulp.task('deploy', function() { return gulp.src(['./target/artifact1.zip', './target/artifact2.zip', './target/artifact3.zip']) .pipe(maven.deploy({ 'groupId': 'group-id', 'version': util.env.tagsVersion, 'repositories': [{ 'id': 'repo-id', 'url': 'http://...:8081/repository/repo-id' }] })) });

how can we handle this problem to deploy those artifacts without using an anonymos user ?

micha149 commented 7 years ago

This question seems more related to maven itself. Off the top of my head, I think there was the possibility to place a special file in your user folder (on jenkins) with the credentials you want to use. But I am not that maven pro 😉

Maybe this will help you: https://maven.apache.org/settings.html

hatem-hadrich commented 7 years ago

In this way, i use a file named settings.xml (on jenkins)

`

repo-id
   <username>xxxx</username>
   <password>xxxx123</password>

`

but always the same problem and i get this error :

Executing command: mvn -B deploy:deploy-file -Dpackaging=zip -Dfile=/tmp/s-117313-24861-yjj6md.5abrt138fr -DgroupId=my-group-id -DartifactId=artifact1 -Dversion=0.2.23 -DgeneratePom=true -DrepositoryId=repo-id -Durl=http://.....:8081/repository/repo-id/ [INFO] Scanning for projects... [INFO]
[INFO] ------------------------------------------------------------------------ [INFO] Building Maven Stub Project (No POM) 1 [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-deploy-plugin:2.7:deploy-file (default-cli) @ standalone-pom --- Downloading: http://.....:8081/repository/repo-id/my-group-id/artifact1/0.2.23/maven-metadata.xml [WARNING] Could not transfer metadata my-group-id:artifact1:0.2.23/maven-metadata.xml from/to repo-id (http://.....:8081/repository/repo-id/): Not authorized , ReasonPhrase:Unauthorized. [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 2.963s [INFO] Finished at: Thu Apr 13 11:59:07 CET 2017 [INFO] Final Memory: 8M/108M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy-file (default-cli) on project standalone-pom: Failed to retrieve remote metadata my-group-id:artifact1:0.2.23/maven-metadata.xml: Could not transfer metadata my-group-id:artifact1:0.2.23/maven-metadata.xml from/to repo-id (http://.......:8081/repository/repo-id/): Not authorized , ReasonPhrase:Unauthorized. -> [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/MojoExecutionException

BilelKrichen commented 7 years ago

+1

micha149 commented 6 years ago

Is this problem solved?

smolnikov commented 6 years ago

@micha149 nope, having the same issue. Where to put username/password to enable authentication when deploying to repo?

smolnikov commented 6 years ago

Fixed it by using basic auth http://username:password@nexus.url/repo

micha149 commented 6 years ago

With a quick google I found this: https://little418.com/2009/07/maven-minimal-settingsxml-for-authenticated-repository.html

@smolnikov can you please check if this works?!

hatem-hadrich commented 6 years ago

This problem is fixed by using basic auth http://username:password@nexus.url/repo