RPM deploy in Neuxs

Nexus is a repository manager solution for Java. Similar to Archiva and Artifactory. If you are a Java developer probably you are familiar with this kind of solutions. Nexus is useful because acts like a proxy then you can improve download speed because you have a central cache and you have your deploys and binaries there.

There is feature is really cool on the DevOps context makes lots of sense is the RPM feature. Basically you are allowed to deploy RPM in Nexus, Artifactory has a similar feature too. This is very useful because sometimes you need to pack things that are not JARS and this is very useful to the operations point of view. So In this post I will show how to install Nexus on Linux and how to deploy an RPM in Nexus is pretty easy and there are more than one to do this.


How to Install Nexus on Ubuntu?

Download and Install Nexus

sudo wget http://www.sonatype.org/downloads/nexus-latest-bundle.zip
sudo chmod 777 nexus-2.11.4-01-bundle.zip
sudo unzip nexus-2.11.4-01-bundle.zip
cd nexus-2.11.4-01/bin
sudo RUN_AS_USER=root ./nexus start

Config nexus on Maven

sudo vim $M2_HOME/conf/settings.xml
    <server>
      <id>nexus</id>
      <username>admin</username>
      <password>admin123</password>
    </server>

Goto: http://127.0.0.1:8081/nexus/#welcome

view raw nexus.md hosted with ❤ by GitHub
Let's Generate some RPM using FPM

Install on Ubuntu

sudo apt-get install rpm
sudo apt-get install ruby-dev gcc make
sudo gem install fpm

Creating RPMs

sudo fpm -s dir -t rpm --prefix /tmp/diego -n "slashbin" -v 1.0 /bin

Check RPMs Content and Details

rpm -qpil slashbin-1.0-1.x86_64.rpm

Install the RPM

sudo rpm -ivh slashbin-1.0-1.x86_64.rpm

Check the FINAL installation

sudo ls /tmp/diego/bin/

Remove the RPM

sudo rpm -ev --nodeps  slashbin-1.0-1.x86_64
view raw fpm.md hosted with ❤ by GitHub
Deploy RPM to Nexus

#!/bin/bash
### Method 1
###
mvn deploy:deploy-file \
-DgroupId=com.github.diegopacheco.sandbox.devops \
-DartifactId=fpmtest \
-Dversion=1.0.0 \
-DgeneratePom=true \
-Dpackaging=rpm \
-DrepositoryId=nexus \
-Durl=http://127.0.0.1:8081/nexus/content/repositories/releases \
-Dfile=slashbin-1.0-1.x86_64.rpm
### Method 2
###
curl -v -u admin:admin123 --upload-file slashbin-1.0-1.x86_64.rpm http://127.0.0.1:8081/nexus/content/repositories/releases/com/github/diegopacheco/sandbox/devops/fpmtest/1.0.1/fpmtest-1.0.1.rpm
### Method 3
###
curl -v -F r=releases -F hasPom=false -F e=rpm -F g=com.github.diegopacheco.sandbox.devops -F a=fpmtest -F v=2.0 -F p=rpm -F file=@slashbin-1.0-1.x86_64.rpm -u admin:admin123 http://127.0.0.1:8081/nexus/service/local/artifact/maven/content
There are 2 ways to deploy on Nexus. You can use Maven(method1) and Curl(method 2 and 3). If you use maven you need make sure maven ins on your PATH and you added credentials for Nexus on the settings.xml file. That's it.

Cheers,
Diego Pacheco

Popular posts from this blog

Having fun with Zig Language

C Unit Testing with Check

Cool Retro Terminal