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?
Let's Generate some RPM using FPM
Deploy RPM to Nexus
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
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?
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
sudo vim $M2_HOME/conf/settings.xml
<server>
<id>nexus</id>
<username>admin</username>
<password>admin123</password>
</server>
sudo apt-get install rpm
sudo apt-get install ruby-dev gcc make
sudo gem install fpm
sudo fpm -s dir -t rpm --prefix /tmp/diego -n "slashbin" -v 1.0 /bin
rpm -qpil slashbin-1.0-1.x86_64.rpm
sudo rpm -ivh slashbin-1.0-1.x86_64.rpm
sudo ls /tmp/diego/bin/
sudo rpm -ev --nodeps slashbin-1.0-1.x86_64
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Cheers,
Diego Pacheco