Difference between revisions of "Nexus"
Line 10: | Line 10: | ||
− | + | ||
+ | =Installation= | ||
+ | |||
+ | |||
+ | ==Create user / group== | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
Line 21: | Line 25: | ||
− | + | ==Prepare work folder== | |
+ | |||
+ | You need to create a root folder to host all the artifacts. !!! This will be bigger and bigger over time !!! | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
Line 30: | Line 36: | ||
− | + | ==Get binaries== | |
− | |||
− | = | ||
Download '''Nexus OSS''' as ''Nexus Open-Source Server'' - take the ZIP format | Download '''Nexus OSS''' as ''Nexus Open-Source Server'' - take the ZIP format | ||
Line 46: | Line 50: | ||
− | Set rights | + | ==Set rights== |
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
Line 52: | Line 56: | ||
chown -R nexus:nexus /opt/nexus-2.11.4-01 | chown -R nexus:nexus /opt/nexus-2.11.4-01 | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
− | |||
− | |||
− | |||
Line 78: | Line 78: | ||
runtime=${bundleBasedir}/nexus/WEB-INF | runtime=${bundleBasedir}/nexus/WEB-INF | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
Line 86: | Line 85: | ||
ln -s /opt/nexus/logs/wrapper.log /var/log/nexus.log | ln -s /opt/nexus/logs/wrapper.log /var/log/nexus.log | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
Line 104: | Line 102: | ||
#The PID directory must be a directory where you the runtime user can Read/Write | #The PID directory must be a directory where you the runtime user can Read/Write | ||
PIDDIR="/opt/nexus" | PIDDIR="/opt/nexus" | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | |||
+ | ==Start / stop server== | ||
+ | |||
+ | To start|stop the server: | ||
+ | |||
+ | <syntaxhighlight lang="bash"> | ||
+ | /opt/nexus/bin/nexus start | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 138: | Line 145: | ||
<syntaxhighlight lang="apache"> | <syntaxhighlight lang="apache"> | ||
## Proxy to NEXUS | ## Proxy to NEXUS | ||
− | <Location /nexus > | + | <Location /nexus/ > |
ProxyPass http://localhost:9081/nexus/ | ProxyPass http://localhost:9081/nexus/ | ||
ProxyPassReverse http://localhost:9081/nexus/ | ProxyPassReverse http://localhost:9081/nexus/ | ||
Line 149: | Line 156: | ||
=Nexus server access= | =Nexus server access= | ||
+ | |||
+ | You can access your server on http://myServer/nexus/ (Don't forget the end '/') | ||
The default user and password are: | The default user and password are: | ||
Line 159: | Line 168: | ||
=Maven client configuration= | =Maven client configuration= | ||
− | + | All repositories of type “proxy” need to change “Download Remote Indexes” property to true in the configuration tab. | |
+ | |||
+ | As you see there are several types of repositories. | ||
+ | * '''proxy''' – acts as proxy for external repository. | ||
+ | * '''hosted''' – repository that managed artifact produced by you | ||
+ | * '''virtual''' – kind of adapter for e.g transforming maven1 to maven 2 format. | ||
+ | * '''group''' – maybe not a repository in sonatyp’s terminology but behaves like one. A group groups several repositories to one exposing result as single URI. | ||
+ | |||
− | |||
− | + | ==Global configuration (settings.xml)== | |
− | + | To set the Global configuration, edit your <code>Maven/conf/settings.xml</code> and add: | |
− | |||
− | |||
− | |||
− | + | <syntaxhighlight lang="xml"> | |
<mirrors> | <mirrors> | ||
<mirror> | <mirror> | ||
<id>nexus</id> | <id>nexus</id> | ||
<mirrorOf>*</mirrorOf> | <mirrorOf>*</mirrorOf> | ||
− | <url> | + | <url>https://dev.daxiongmao.eu/nexus/content/groups/public</url> |
</mirror> | </mirror> | ||
</mirrors> | </mirrors> | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | |||
+ | ==Project POM update== | ||
+ | |||
+ | As an alternative you can update the project's POM to ensure everyone uses your repository. | ||
+ | |||
− | + | Put this before the [BUILD] section of your POM. | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | <syntaxhighlight lang="xml"> | |
− | < | + | <distributionManagement> |
− | + | <repository> | |
− | </ | + | <id>nexus</id> |
+ | <url>https://dev.daxiongmao.eu/nexus/content/repositories/releases/</url> | ||
+ | <layout>default</layout> | ||
+ | <snapshots> | ||
+ | <updatePolicy>always</updatePolicy> | ||
+ | </snapshots> | ||
+ | <releases> | ||
+ | <updatePolicy>always</updatePolicy> | ||
+ | </releases> | ||
+ | </repository> | ||
+ | <snapshotRepository> | ||
+ | <id>nexus</id> | ||
+ | <url>https://dev.daxiongmao.eu/nexus/content/repositories/snapshots/</url> | ||
+ | <layout>default</layout> | ||
+ | <snapshots> | ||
+ | <updatePolicy>always</updatePolicy> | ||
+ | </snapshots> | ||
+ | <releases> | ||
+ | <updatePolicy>always</updatePolicy> | ||
+ | </releases> | ||
+ | </snapshotRepository> | ||
+ | </distributionManagement> | ||
+ | <repositories> | ||
+ | <repository> | ||
+ | <id>dev.daxiongmao.eu</id> | ||
+ | <url>https://dev.daxiongmao.eu/nexus/content/repositories/public/</url> | ||
+ | </repository> | ||
+ | </repositories> | ||
− | + | </syntaxhighlight> | |
− | |||
− | + | Now your maven client knows only your nexus and everything it needs and how it gets it, should be controlled by nexus. |
Revision as of 00:32, 12 September 2015
This page explains how to setup and configure NEXUS Maven repositories.
Contents
Requirements
a) You need to setup Maven
Installation
Create user / group
# Create group
addgroup --system "nexus"
# Create Nexus user (home directory must be Nexus)
adduser --home /opt/nexus --disabled-login --disabled-password nexus
Prepare work folder
You need to create a root folder to host all the artifacts. !!! This will be bigger and bigger over time !!!
mkdir -p /home/nexus
chmod -R 777 /home/nexus
chown -R nexus:nexus /home/nexus
Get binaries
Download Nexus OSS as Nexus Open-Source Server - take the ZIP format
cd /opt
wget http://www.sonatype.org/downloads/nexus-latest-bundle.tar.gz
tar xzvf nexus-latest-bundle.tar.gz
rm nexus-latest-bundle.tar.gz
ln -s /opt/nexus-2.11.4-01/ /opt/nexus
Set rights
chown -R nexus:nexus /opt/nexus
chown -R nexus:nexus /opt/nexus-2.11.4-01
Set nexus parameters
Adjust the port number and root context path, if required
vim /opt/nexus/conf/nexus.properties
Set:
application-port=9081
application-host=127.0.0.1
nexus-webapp-context-path=/nexus
## Nexus section
## nexus-work ==>> folders where the artifacts are going to be saved. You must choose a folder with a lot of disk!
nexus-work=/home/nexus
runtime=${bundleBasedir}/nexus/WEB-INF
Log symlink
ln -s /opt/nexus/logs/wrapper.log /var/log/nexus.log
Set Nexus user and rights
vim /opt/nexus/bin/nexus
# Set the correct home
NEXUS_HOME="/opt/nexus"
#uncomment and adjust
RUN_AS_USER="nexus"
#The PID directory must be a directory where you the runtime user can Read/Write
PIDDIR="/opt/nexus"
Start / stop server
To start|stop the server:
/opt/nexus/bin/nexus start
ERROR Fix
If you encounter the Failed to start Nexus OSS
error, then you need to:
chown -R nexus:nexus /opt/sonatype-work
Run Nexus from anywhere
Set the NEXUS_HOME into the start script. Without it you cannot run Nexus as a service!
ln -s /opt/nexus/bin/nexus /usr/bin/nexus
ln -s /opt/nexus/bin/nexus /etc/init.d/nexus
vim /opt/nexus/bin/nexus
Apache2 proxy
Put the following lines into your Apache2 proxy configuration:
## Proxy to NEXUS
<Location /nexus/ >
ProxyPass http://localhost:9081/nexus/
ProxyPassReverse http://localhost:9081/nexus/
Require all granted
satisfy any
</Location>
Nexus server access
You can access your server on http://myServer/nexus/ (Don't forget the end '/')
The default user and password are:
- User: admin
- Pwd: admin123
Maven client configuration
All repositories of type “proxy” need to change “Download Remote Indexes” property to true in the configuration tab.
As you see there are several types of repositories.
- proxy – acts as proxy for external repository.
- hosted – repository that managed artifact produced by you
- virtual – kind of adapter for e.g transforming maven1 to maven 2 format.
- group – maybe not a repository in sonatyp’s terminology but behaves like one. A group groups several repositories to one exposing result as single URI.
Global configuration (settings.xml)
To set the Global configuration, edit your Maven/conf/settings.xml
and add:
<mirrors>
<mirror>
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>https://dev.daxiongmao.eu/nexus/content/groups/public</url>
</mirror>
</mirrors>
Project POM update
As an alternative you can update the project's POM to ensure everyone uses your repository.
Put this before the [BUILD] section of your POM.
<distributionManagement>
<repository>
<id>nexus</id>
<url>https://dev.daxiongmao.eu/nexus/content/repositories/releases/</url>
<layout>default</layout>
<snapshots>
<updatePolicy>always</updatePolicy>
</snapshots>
<releases>
<updatePolicy>always</updatePolicy>
</releases>
</repository>
<snapshotRepository>
<id>nexus</id>
<url>https://dev.daxiongmao.eu/nexus/content/repositories/snapshots/</url>
<layout>default</layout>
<snapshots>
<updatePolicy>always</updatePolicy>
</snapshots>
<releases>
<updatePolicy>always</updatePolicy>
</releases>
</snapshotRepository>
</distributionManagement>
<repositories>
<repository>
<id>dev.daxiongmao.eu</id>
<url>https://dev.daxiongmao.eu/nexus/content/repositories/public/</url>
</repository>
</repositories>
Now your maven client knows only your nexus and everything it needs and how it gets it, should be controlled by nexus.