This guide explains how to use the server as a repository for the Apache Maven build tool.
More precisely, I will show how to setup a private remote internal maven repository using the free Artifactory implementation.

Step 1 - Prepare environment

Relevant config files:

  • /home/artifactory/artifactory_base/etc/ (datasource name, if using mysql)
  • /home/artifactory/artifactory_base/etc/repo/filesystem-mysql/repo.xml (datasource, if using mysql)
  • /home/artifactory/tomcat/conf/server.xml
  • /etc/apache2/ (MountJk worker definition)
  • /etc/apache2/sites-available/default (MountJk entry)

A separate artifactory-user will be created, who will control the server.
The server software is installed in his home directory. This encapsulation provides more flexibility and a higher level of security.
The artifactory web application will be deployed into a tomcat servlet container.
How to setup a tomcat installation is described in this article: PostgreSQL and JBoss AS

Create artifactory user

Set up a new user called artifactory:

root@jiffybox # useradd -d /home/artifactory -m artifactory
root@jiffybox # usermod -a -G artifactory artifactory
root@jiffybox # chsh artifactory -s /bin/zsh

Setup a web container for the artifactory.war

Create a tomcat instance as described in PostgreSQL and JBoss AS, using the artifactory user and his home directory.
Tomcat will is now installed here: /home/artifactory/tomcat
Make sure your tomcat instance is configured to use unique ports.

Access the app on the default web port

If you want to access Artifactory on Port 80, mount it via JkMount to the apache HTTP server.

  1. Define/Enable the Connector in your <ARTIFACTORY_TOMCAT>/conf/server.xml
    <Connector port="8010" protocol="AJP/1.3" redirectPort="8443" address="localhost"/>
  2. Add a worker that is used for the artifactory tomcat in: /etc/apache2/
    # ... <EXISTING-WORKERS> ...
  3. Mount the worker to "/artifactory* in: /etc/apache2/sites-available/default
    <VirtualHost *:80>
      # artifactory tomcat instance: (maven repo)
      JkMount /artifactory* artifactorytomcat

Step 2 - Install and configure Artifactory

Relevant config files:

  • /home/artifactory/bin/tomcat_base/bin/

Unzip and deploy the software

Download and unzip the artifactory software in the home directory:

artifactory@jiffybox $ wget "" -O
artifactory@jiffybox $ unzip
The contents of the archive were unpacked in the directory artifactory- This is the directory that needs to be configure as "artifactory.home".
Let's create a link to highlight this fact:
artifactory@jiffybox $ ln -s artifactory- artifactory_base

Then link the war file contained in the artifactory_base to tomcat's webapps dir to deploy the war file. Set the "artifactory.home" Java variable in /home/artifactory/bin/tomcat_base/bin/ to configure the base dir.

export JAVA_OPTS="$JAVA_OPTS -Dartifactory.home=/home/artifactory/artifactory_base"'

Configure Artifactory to use MySql Database (Optional)

By default, Artifactory uses the Apache-Derby in-memory database for the backend. Since we have MySql installed, we can save some memory (just a few megs) by using that database for artifactory.

In this example, a separate database user will be created for the backend.
(If you prefer, you can do this with the PhpMyAdmin tool.)

root@jiffybox # mysql -u root -p
GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER,INDEX on artifactory.* TO 'artifactory'@'localhost' IDENTIFIED BY 'password1';

The next step installs the JDBC driver to the servlet container:

artifactory@jiffybox $ cd /tmp/
artifactory@jiffybox $ wget "" -O
artifactory@jiffybox $ unzip
artifactory@jiffybox $ cp /tmp/mysql-connector-java-5.1.19/mysql-connector-java-5.1.19-bin.jar /home/artifactory/tomcat/lib/

Then, create the datasource definition in the servlet container by adding this section to /home/artifactory/artifactory_base/etc/repo/filesystem-mysql/repo.xml:

<!-- MySQL Datasource -->
    <DataSource name="ds">
        <param name="driver" value="com.mysql.jdbc.Driver"/>
        <param name="url" value="jdbc:mysql://localhost:3306/artifactory?useUnicode=true&characterEncoding=UTF-8"/>
        <param name="user" value="artifactory"/>
        <param name="password" value="password1"/>
        <param name="databaseType" value="mysql"/>
        <!-- Unlimited when not specified -->
        <!--<param name="maxPoolSize" value="80"/>-->

Finally, configure the artifactory instance to use this database. Register the datasource name in the artifactory configuration.
Edit /home/artifactory/artifactory_base/etc/ and add/set this variable:


Start and test Artifactory

by starting the servlet container with the formerly created tomcat-script:

artifactory@jiffybox $ /etc/init.d/ start
Then, browse to the web console, login as 'admin' with 'password' (and change the password).

Step 3 - Configure the Maven client

Relevant config files:

  • ~/.m2/settings.xml
  • pom.xml's

Basic Configuration (Readonly Access)

Maven client configuration is quite simple. Browse to the artifactory console, and navigate to Client Settings / Maven Settings.
Then click on Generate Settings, and paste the content into your ~/.m2/settings.xml.
You shoud now be able to run maven builds that use your repo!

Configuration for a deployer

First, perform the basic configuration step. :-)
Login to the artifactory console as admin, and create a user.
In this example "andre" is created as someone that is allowed to deploy artifacts to the repository. (Read+Annotate+Deploy)

Next, login with the deployer-user. Click on the link that is labelled with the users name, and enter the password.
Copy the config snippet to your ~/.m2/settings.xml.
We will also set an ID to the server, so the pom's can later refer to this configuration.
It should look like this:

          <id></id> <!-- referenced by the poms -->
Then, we add this section to the pom.xml we want to deploy.
(I defined it in my super-pom)
        <id></id><!-- use credentials in settings.xml -->
        <id></id><!-- use credentials in settings.xml -->

This way, every developer can use the same pom.xml files, and needs to configure just his own settings.xml.

Done, now try to deploy something with a simple

mvn deploy:deploy