You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by DJViking <sv...@gmail.com> on 2014/10/08 11:14:26 UTC

Re: maven deploy artifacts to Nexus repository

I decided to start using HTTP/HTTPS instead of SCP for uploading and
downloading artefacts from my Nexus server.
However switching the URL didn't work.

I have created a user in Nexus called build.
In my settings.xml I have the following configuration taken from
http://books.sonatype.com/nexus-book/reference/maven-sect-single-group.html

    <server>
      <id>nexus</id>
      <username>build</username>
      <password>XXXXXXXXXXXXXXX</password>
    </server>

    <mirror>
      <id>nexus</id>
      <mirrorOf>*</mirrorOf>
      <url>http://maven-vm1:8081/nexus/content/groups/public</url>
    </mirror>

    <profile>
      <id>nexus</id>
      <repositories>
        <repository>
          <id>central</id>
          <url>http://central</url>
          <releases>
            <enabled>true</enabled>
            <updatePolicy>always</updatePolicy>
          </releases>
          <snapshots>
            <enabled>true</enabled>
            <updatePolicy>always</updatePolicy>
          </snapshots>
        </repository>
      </repositories>
      
      <pluginRepositories>
        <pluginRepository>
          <id>central</id>
          <url>http://central</url>
          <releases>
            <enabled>true</enabled>
          </releases>
          <snapshots>
            <enabled>true</enabled>
          </snapshots>
        </pluginRepository>
      </pluginRepositories>
    </profile>

  <activeProfiles>
    <activeProfile>nexus</activeProfile>
  </activeProfiles>

In my pom.xml I changed the following in distributionManagement
<url>scp://maven-vm1/srv/maven/snapshots</url> 
to
<url>http://maven-vm1:8081/nexus/content/repositories/snapshots</url>

Still I cannot get it to upload to Nexus:

[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-deploy-plugin:2.8.1:deploy (default-deploy)
on project MyApp: Failed to deploy artifacts: Could not transfer artifact
no.company:MyApp:jar:2.5.1-20141008.085615-1 from/to snapshots
(http://maven-vm1:8081/nexus/content/repositories/snapshots): Failed to
transfer file:
http://maven-vm1:8081/nexus/content/repositories/snapshots/no/company/MyApp/2.5.1-SNAPSHOT/MyApp-2.5.1-20141008.085615-1.jar.
Return code is: 401, ReasonPhrase: Unauthorized. -> [Help 1]



--
View this message in context: http://maven.40175.n5.nabble.com/maven-deploy-artifacts-to-Nexus-repository-tp5751512p5808056.html
Sent from the Maven - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: maven deploy artifacts to Nexus repository

Posted by Manfred Moser <ma...@mosabuam.com>.
For some reason the build extension for Maven site deployment no longer works with latests Maven and site plugins. I found that the best way to configure it is to add the webdav support as a dependency to the site plugin. And have not yet been able to trace down where the problem lies.. 

I have documented this on the book and pushed it live now. 

http://books.sonatype.com/nexus-book/reference/_configuring_maven_for_site_deployment.html

Hope that helps.

manfred

DJViking wrote on 08.10.2014 04:11:

> Trying to also use http with Nexus site deployment didn't work.
> 
> [INFO] --- maven-site-plugin:3.4:deploy (default-deploy) @ MyApp ---
> http://maven-vm1:8081/nexus/content/sites/site/MyApp/ - Session: Opened  
> [INFO] Pushing /home/sverre/workspace/MyApp-R11/target/site
> [INFO]    >>> to http://maven-vm1:8081/nexus/content/sites/site/MyApp/./
> Uploading: .//source-repository.html to
> http://maven-vm1:8081/nexus/content/sites/site/MyApp/
> 
> ##http://maven-vm1:8081/nexus/content/sites/site/MyApp/./source-repository.html
> - Status code: 404
> http://maven-vm1:8081/nexus/content/sites/site/MyApp/ - Session:
> Disconnecting  
> http://maven-vm1:8081/nexus/content/sites/site/MyApp/ - Session:
> Disconnected
> [INFO]
> ------------------------------------------------------------------------
> [INFO] BUILD FAILURE
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Total time: 03:20 min
> [INFO] Finished at: 2014-10-08T13:03:21+01:00
> [INFO] Final Memory: 90M/2309M
> [INFO]
> ------------------------------------------------------------------------
> [ERROR] Failed to execute goal
> org.apache.maven.plugins:maven-site-plugin:3.4:deploy (default-deploy) on
> project MyApp: Error uploading site: File:
> http://maven-vm1:8081/nexus/content/sites/site/MyApp/./source-repository.html
> does not exist -> [Help 1]
> [ERROR] 
> 
> I didn't have anything under Nexus sites before this.
> 
> 
> http://books.sonatype.com/nexus-book/reference/_configuring_maven_for_site_deployment.html
> <http://books.sonatype.com/nexus-book/reference/_configuring_maven_for_site_deployment.html> 
> 
> 
>        <site>
>            <id>deployment</id>
>            <name>Sites</name>
>           
> <url>dav:http://meta-vm1:8081/nexus/content/sites/site/${project.artifactId}/${project.version}</url>
>        </site>
> 
> Added the following build extension:
>            <extension>
>                <groupId>org.apache.maven.wagon</groupId>
>                <artifactId>wagon-webdav-jackrabbit</artifactId>
>                <version>2.7</version>
>            </extension>
> 
> Anyhow: I'm not sure, but could this be a problem with Nexus and not Maven?
> 
> 
> 
> --
> View this message in context:
> http://maven.40175.n5.nabble.com/maven-deploy-artifacts-to-Nexus-repository-tp5751512p5808068.html
> Sent from the Maven - Users mailing list archive at Nabble.com.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: maven deploy artifacts to Nexus repository

Posted by DJViking <sv...@gmail.com>.
Trying to also use http with Nexus site deployment didn't work.

[INFO] --- maven-site-plugin:3.4:deploy (default-deploy) @ MyApp ---
http://maven-vm1:8081/nexus/content/sites/site/MyApp/ - Session: Opened  
[INFO] Pushing /home/sverre/workspace/MyApp-R11/target/site
[INFO]    >>> to http://maven-vm1:8081/nexus/content/sites/site/MyApp/./
Uploading: .//source-repository.html to
http://maven-vm1:8081/nexus/content/sites/site/MyApp/

##http://maven-vm1:8081/nexus/content/sites/site/MyApp/./source-repository.html
- Status code: 404
http://maven-vm1:8081/nexus/content/sites/site/MyApp/ - Session:
Disconnecting  
http://maven-vm1:8081/nexus/content/sites/site/MyApp/ - Session:
Disconnected
[INFO]
------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO]
------------------------------------------------------------------------
[INFO] Total time: 03:20 min
[INFO] Finished at: 2014-10-08T13:03:21+01:00
[INFO] Final Memory: 90M/2309M
[INFO]
------------------------------------------------------------------------
[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-site-plugin:3.4:deploy (default-deploy) on
project MyApp: Error uploading site: File:
http://maven-vm1:8081/nexus/content/sites/site/MyApp/./source-repository.html
does not exist -> [Help 1]
[ERROR] 

I didn't have anything under Nexus sites before this.


http://books.sonatype.com/nexus-book/reference/_configuring_maven_for_site_deployment.html
<http://books.sonatype.com/nexus-book/reference/_configuring_maven_for_site_deployment.html>  

        <site>
            <id>deployment</id>
            <name>Sites</name>
           
<url>dav:http://meta-vm1:8081/nexus/content/sites/site/${project.artifactId}/${project.version}</url>
        </site>

Added the following build extension:
            <extension>
                <groupId>org.apache.maven.wagon</groupId>
                <artifactId>wagon-webdav-jackrabbit</artifactId>
                <version>2.7</version>
            </extension>

Anyhow: I'm not sure, but could this be a problem with Nexus and not Maven?



--
View this message in context: http://maven.40175.n5.nabble.com/maven-deploy-artifacts-to-Nexus-repository-tp5751512p5808068.html
Sent from the Maven - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: maven deploy artifacts to Nexus repository

Posted by Manfred Moser <ma...@mosabuam.com>.
Rather than having two different server sections in settings.xml it is better to use one and the same id in the distribtutionMgt in the pom if they are for the same server. So e.g. if you deploy everything to nexus it could look like this

<distributionManagement>
   <repository>
      <id>nexus</id>
      <url>http://localhost:8081/nexus/content/repositories/releases</url>
    </repository>
    <snapshotRepository>
      <id>nexus</id>
      <url>http://localhost:8081/nexus/content/repositories/snapshots</url>
    </snapshotRepository>
    <site>
      <id>nexus</id>
      <url>dav:http://localhost:8081/nexus/content/sites/site-internal/example</url>
    </site>
  </distributionManagement>

and then settings just needs 

<server>
<id>nexus</id>
....

The same id is also used if you set up mirror in settings e.g.

  <mirror>
<id>nexus</id>

causes the same credentials to be used for accessing the mirror url. You can use that to e.g. disable anonymous access on Nexus and then require credentials.

manfred

DJViking wrote on 08.10.2014 03:06:

> That was it. 
>        <snapshotRepository>
>            <id>snapshots</id>
>           
> <url>http://maven-vm1:8081/nexus/content/repositories/snapshots</url>
>        </snapshotRepository>
>        <repository>
>            <id>releases</id>
>           
> <url>http://maven-vm1:8081/nexus/content/repositories/releases</url>
>        </repository>
> 
> I had to create two servers with both these Id's, then it worked just fine.
> 
> Maybe I missed it, but I couldn't find anywhere in the documentation that
> this id needed to match the id in the server.
> 
> 
> 
> --
> View this message in context:
> http://maven.40175.n5.nabble.com/maven-deploy-artifacts-to-Nexus-repository-tp5751512p5808061.html
> Sent from the Maven - Users mailing list archive at Nabble.com.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: maven deploy artifacts to Nexus repository

Posted by DJViking <sv...@gmail.com>.
That was it. 
        <snapshotRepository>
            <id>snapshots</id>
           
<url>http://maven-vm1:8081/nexus/content/repositories/snapshots</url>
        </snapshotRepository>
        <repository>
            <id>releases</id>
           
<url>http://maven-vm1:8081/nexus/content/repositories/releases</url>
        </repository>

I had to create two servers with both these Id's, then it worked just fine.

Maybe I missed it, but I couldn't find anywhere in the documentation that
this id needed to match the id in the server.



--
View this message in context: http://maven.40175.n5.nabble.com/maven-deploy-artifacts-to-Nexus-repository-tp5751512p5808061.html
Sent from the Maven - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: maven deploy artifacts to Nexus repository

Posted by Anders Hammar <an...@hammar.net>.
What's the id defined in the distributionMgmt section? It should map to the
id for the server creds defined in settings.xml ('nexus').

/Anders

On Wed, Oct 8, 2014 at 11:14 AM, DJViking <sv...@gmail.com> wrote:

> I decided to start using HTTP/HTTPS instead of SCP for uploading and
> downloading artefacts from my Nexus server.
> However switching the URL didn't work.
>
> I have created a user in Nexus called build.
> In my settings.xml I have the following configuration taken from
> http://books.sonatype.com/nexus-book/reference/maven-sect-single-group.html
>
>     <server>
>       <id>nexus</id>
>       <username>build</username>
>       <password>XXXXXXXXXXXXXXX</password>
>     </server>
>
>     <mirror>
>       <id>nexus</id>
>       <mirrorOf>*</mirrorOf>
>       <url>http://maven-vm1:8081/nexus/content/groups/public</url>
>     </mirror>
>
>     <profile>
>       <id>nexus</id>
>       <repositories>
>         <repository>
>           <id>central</id>
>           <url>http://central</url>
>           <releases>
>             <enabled>true</enabled>
>             <updatePolicy>always</updatePolicy>
>           </releases>
>           <snapshots>
>             <enabled>true</enabled>
>             <updatePolicy>always</updatePolicy>
>           </snapshots>
>         </repository>
>       </repositories>
>
>       <pluginRepositories>
>         <pluginRepository>
>           <id>central</id>
>           <url>http://central</url>
>           <releases>
>             <enabled>true</enabled>
>           </releases>
>           <snapshots>
>             <enabled>true</enabled>
>           </snapshots>
>         </pluginRepository>
>       </pluginRepositories>
>     </profile>
>
>   <activeProfiles>
>     <activeProfile>nexus</activeProfile>
>   </activeProfiles>
>
> In my pom.xml I changed the following in distributionManagement
> <url>scp://maven-vm1/srv/maven/snapshots</url>
> to
> <url>http://maven-vm1:8081/nexus/content/repositories/snapshots</url>
>
> Still I cannot get it to upload to Nexus:
>
> [ERROR] Failed to execute goal
> org.apache.maven.plugins:maven-deploy-plugin:2.8.1:deploy (default-deploy)
> on project MyApp: Failed to deploy artifacts: Could not transfer artifact
> no.company:MyApp:jar:2.5.1-20141008.085615-1 from/to snapshots
> (http://maven-vm1:8081/nexus/content/repositories/snapshots): Failed to
> transfer file:
>
> http://maven-vm1:8081/nexus/content/repositories/snapshots/no/company/MyApp/2.5.1-SNAPSHOT/MyApp-2.5.1-20141008.085615-1.jar
> .
> Return code is: 401, ReasonPhrase: Unauthorized. -> [Help 1]
>
>
>
> --
> View this message in context:
> http://maven.40175.n5.nabble.com/maven-deploy-artifacts-to-Nexus-repository-tp5751512p5808056.html
> Sent from the Maven - Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>