e-gineering / gitflow-helper-maven-plugin

An extension and plugin that teaches Maven to work well with gitflow projects and CI servers.
Apache License 2.0
76 stars 21 forks source link

"Unauthorized" Could not locate artifact catalog in remote repository #36

Closed almalki closed 7 years ago

almalki commented 8 years ago

On our jenkins server we use the same job to build all branches(using Folders Plugin), which means we use the same maven settings for all branches. The build for release branches are successfully deployed to artifactory (libs-stage-local) repo, which means the user has write access to the repo, however, when it comes to building the master branch, and when the plugin tries to promote-master, it fails with "Unauthorized" error when trying to get the artifact from the same repo..

In artifactory logs, it shows that the request is not authenticated:

20160823153848|2|REQUEST|[[redacted]]|non_authenticated_user|GET|/libs-stage-local/[[redacted]]-1.3-catalog.txt|HTTP/1.0|401|0

while the other request that are part of the deploy phase for release branches are authenticated:

20160823134403|180|REQUEST|[[redacted]]|jenkins|PUT|/libs-stage-local/[[redacted]]-1.3-catalog.txt.md5|HTTP/1.0|201|32

Here is the exception stacktrace:

[ERROR] Failed to execute goal com.e-gineering:gitflow-helper-maven-plugin:1.2.5:promote-master (default) on project [[redacted]]: Could not locate artifact catalog in remote repository. Could not transfer artifact [[redacted]]:txt:catalog:1.3 from/to stage (https://[[redacted]]/libs-stage-local/): Not authorized , ReasonPhrase:Unauthorized. -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.e-gineering:gitflow-helper-maven-plugin:1.2.5:promote-master (default) on project [[redacted]]: Could not locate artifact catalog in remote repository.
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
    at org.jvnet.hudson.maven3.launcher.Maven32Launcher.main(Maven32Launcher.java:132)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchStandard(Launcher.java:330)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:238)
    at jenkins.maven3.agent.Maven32Main.launch(Maven32Main.java:186)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at hudson.maven.Maven3Builder.call(Maven3Builder.java:136)
    at hudson.maven.Maven3Builder.call(Maven3Builder.java:71)
    at hudson.remoting.UserRequest.perform(UserRequest.java:120)
    at hudson.remoting.UserRequest.perform(UserRequest.java:48)
    at hudson.remoting.Request$2.run(Request.java:326)
    at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:68)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.maven.plugin.MojoExecutionException: Could not locate artifact catalog in remote repository.
    at com.e_gineering.maven.gitflowhelper.AbstractGitflowBasedRepositoryMojo.attachExistingArtifacts(AbstractGitflowBasedRepositoryMojo.java:282)
    at com.e_gineering.maven.gitflowhelper.PromoteMasterMojo.execute(PromoteMasterMojo.java:34)
    at com.e_gineering.maven.gitflowhelper.AbstractGitflowBranchMojo.logExecute(AbstractGitflowBranchMojo.java:59)
    at com.e_gineering.maven.gitflowhelper.AbstractGitflowBranchMojo.execute(AbstractGitflowBranchMojo.java:89)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
    ... 31 more
Caused by: org.eclipse.aether.resolution.ArtifactResolutionException: Could not transfer artifact [[redacted]]:txt:catalog:1.3 from/to stage (https://[[redacted]]/libs-stage-local/): Not authorized , ReasonPhrase:Unauthorized.
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:444)
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:246)
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:223)
    at com.e_gineering.maven.gitflowhelper.AbstractGitflowBasedRepositoryMojo.attachExistingArtifacts(AbstractGitflowBasedRepositoryMojo.java:266)
    ... 36 more
Caused by: org.eclipse.aether.transfer.ArtifactTransferException: Could not transfer artifact [[redacted]]:txt:catalog:1.3 from/to stage (https://[[redacted]]/artifactory/libs-stage-local/): Not authorized , ReasonPhrase:Unauthorized.
    at org.eclipse.aether.connector.basic.ArtifactTransportListener.transferFailed(ArtifactTransportListener.java:43)
    at org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.java:355)
    at org.eclipse.aether.util.concurrency.RunnableErrorForwarder$1.run(RunnableErrorForwarder.java:67)
    at org.eclipse.aether.connector.basic.BasicRepositoryConnector$DirectExecutor.execute(BasicRepositoryConnector.java:581)
    at org.eclipse.aether.connector.basic.BasicRepositoryConnector.get(BasicRepositoryConnector.java:249)
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.performDownloads(DefaultArtifactResolver.java:520)
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:421)
    ... 39 more
Caused by: org.apache.maven.wagon.authorization.AuthorizationException: Not authorized , ReasonPhrase:Unauthorized.
    at org.apache.maven.wagon.providers.http.AbstractHttpClientWagon.fillInputData(AbstractHttpClientWagon.java:1005)
    at org.apache.maven.wagon.providers.http.AbstractHttpClientWagon.fillInputData(AbstractHttpClientWagon.java:960)
    at org.apache.maven.wagon.StreamWagon.getInputStream(StreamWagon.java:116)
    at org.apache.maven.wagon.StreamWagon.getIfNewer(StreamWagon.java:88)
    at org.apache.maven.wagon.StreamWagon.get(StreamWagon.java:61)
    at org.eclipse.aether.transport.wagon.WagonTransporter$GetTaskRunner.run(WagonTransporter.java:560)
    at org.eclipse.aether.transport.wagon.WagonTransporter.execute(WagonTransporter.java:427)
    at org.eclipse.aether.transport.wagon.WagonTransporter.get(WagonTransporter.java:404)
    at org.eclipse.aether.connector.basic.BasicRepositoryConnector$GetTaskRunner.runTask(BasicRepositoryConnector.java:447)
    at org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.java:350)
    ... 44 more
[ERROR] 
[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
maurrysonn commented 8 years ago

Hi, I encounter exactly the same problem... My settings allows me to deploy the release build on the stage repo but impossible to download catalog.txt from the same stage repo.

Is it possible that artifactResolver.resolveArtifact(...) call from AbstractGitflowBasedRepositoryMojoattachExistingArtifacts() method doesn't care about auth settings ?

bvarner commented 8 years ago

Did you have the uniqueVersion of your stage URI (the last boolean) set to ::false, as you would your release repository?

maurrysonn commented 8 years ago

Hi, The uniqueVersion property is well set to false for my release and stage repos. And the resulting error is : Access denied to http://(stage repo)/..../my-artefact-version-catalog.txt Cause : Error code 401, Unauthorized (with exceptions explained earlier)

My configuration :

<configuration>
<developmentBranchPattern>develop</developmentBranchPattern>
<releaseBranchPattern>release/(.*)</releaseBranchPattern>
<hotfixBranchPattern>hotfix/(.*)</hotfixBranchPattern>
<masterBranchPattern>master</masterBranchPattern>
<gitBranchExpression>${scmBranch}</gitBranchExpression>
<releaseDeploymentRepository>nexus::default::http://.../releases/::false</releaseDeploymentRepository>
<stageDeploymentRepository>nexus-Stage::default::http://.../stages/::false</stageDeploymentRepository>
<snapshotDeploymentRepository>nexus-Snapshot::default::http://.../snapshots/::true</snapshotDeploymentRepository>
<gitURLExpression>${project.scm.connection}</gitURLExpression>
</configuration>

Thanks for your time !

bvarner commented 8 years ago

@maurrysonn If you wanted to play around in the code, or if you could provide details on your nexus setup (user account rights / roles / ssl vs. no ssl, repo setup) that would be super helpful.