Install Artifactory OSS private maven repository

Upasana | March 12, 2018 | 2 min read | 308 views


JFrog’s Artifactory open source project was created to speed up development cycles using binary repositories. It’s the world’s most advanced repository manager, creating a single place for teams to manage all their binary artifacts efficiently.

JFrog Artifactory OSS

Artifactory OSS can be very helpful tool when you want to host your own private maven repository for sharing common code within company premises.

private hosted repository

Installation on Ubuntu 16.04

gpg --keyserver pgpkeys.mit.edu --recv-key 6B219DCCD7639232
gpg -a --export 6B219DCCD7639232 | sudo apt-key add -
sudo apt-get update
sudo dpkg -i jfrog-artifactory-oss-5.8.3.deb
cd /opt/jfrog/artifactory/bin/
sudo ./configure.mysql.sh
Set Proper Permissions in Mysql
GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,REFERENCES,ALTER,INDEX on artdb.* TO 'artifactory'@'localhost' IDENTIFIED BY 'password';
flush priviledges;
Manage Service for Artifactory
systemctl enable artifactory.service
systemctl start artifactory.service
systemctl stop artifactory.service
Uninstall Artifactory OSS
sudo apt-get remove jfrog-artifactory-oss

Create User, User Group and Permissions

Using Artifactory in your Gradle Project

gradle.properties
artifactory_user=${security.getCurrentUsername()}
artifactory_password=${security.getEncryptedPassword()!"AP9vEVsG9KunZzo6w7P1xwUhxBx"}
artifactory_contextUrl=http://oss.shunyafoundation.com/artifactory
build.gradle [Top Level]
buildscript {
    repositories {
        maven {
            url 'http://oss.shunyafoundation.com/artifactory/libs-release'
            credentials {
                username = "${artifactory_user}"
                password = "${artifactory_password}"
            }
        }

    }
    dependencies {
        //Check for the latest version here: http://plugins.gradle.org/plugin/com.jfrog.artifactory
        classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4+"
    }
}

allprojects {
    apply plugin: "com.jfrog.artifactory"
}

artifactory {
    contextUrl = "${artifactory_contextUrl}"   //The base Artifactory URL if not overridden by the publisher/resolver
    publish {
        repository {
            repoKey = 'libs-snapshot-local'
            username = "${artifactory_user}"
            password = "${artifactory_password}"
            maven = true

        }
    }
    resolve {
        repository {
            repoKey = 'libs-snapshot'
            username = "${artifactory_user}"
            password = "${artifactory_password}"
            maven = true

        }
    }
}

Publishing Artifacts from common module to OSS

A shared library can be published to Artifactory OSS so that the other microservices/projects can start using this versioned library using maven dependency.

We can easily configure an artifact to publish it onto OSS.

apply plugin: "com.jfrog.artifactory"

version = '0.0.1-SNAPSHOT'
group = 'com.shunya'

artifactory {
    contextUrl = "${artifactory_contextUrl}"
    publish {
        repository {
            repoKey = 'libs-snapshot-local'
            username = "${artifactory_username}"
            password = "${artifactory_password}"
            maven = true
        }
        defaults {
            publications ('mavenJava')
        }
    }
}

publishing {
    publications {
        mavenJava(MavenPublication) {
            from components.java
        }
    }
}

Upgrade Artifactory to Latest Version

sudo systemctl stop artifactory.service

wget https://bintray.com/artifact/download/jfrog/artifactory-debs/pool/main/j/jfrog-artifactory-oss-deb/jfrog-artifactory-oss-5.9.0.deb
sudo dpkg -i jfrog-artifactory-oss-5.9.0.deb

sudo systemctl start artifactory.service

Top articles in this category:
  1. Installing nginx on macOS Mojave using brew
  2. Install ElasticSearch 7 on Ubuntu 20.04
  3. Install & configure Redis on Ubuntu
  4. Install Cassandra 4 on Ubuntu 20.04
  5. Install RabbitMQ and Erlang 23 on Ubuntu 20
  6. MySql 8 installation on Ubuntu 20
  7. DevOps interview questions - Basic Concepts, Microservices, Databases, AWS

Recommended books for interview preparation:

Find more on this topic:
Buy interview books

Java & Microservices interview refresher for experienced developers.