cbaWorkflow : Nexus Installation and configuration

Installation of Nexus

1.Download nexus from https://help.sonatype.com/repomanager3/download/download-archives---repository-manager-3

2.create user nexus, group nexus and make him the owner of the tar

3. unarchive nexus into the /app

[nexus@r01edge  app] tar xzvf nexus-3.22.0-02-unix.tar.gz

Rename the directory to nexus

[nexus@r01edge app] mv nexus-3.22.0-02-unix nexus

[nexus@r01edge  app] cd nexus

[nexus@r01edge nexus] cd bin

Start nexus

[nexus@r01edge bin]$ ./nexus start

..Starting nexus

[nexus@r01edge log]$ tail -f /app/sonatype-work/nexus3/log/nexus.log


Login into the Repository manager at port 8081 as admin/admin123


Create proxy for maven-central clicking on Settings cogwheel, Repositories


Make the repository a proxy for Maven central:


Create a role "developer":

Grant nx-all and nx-component-upload to developer, you will figure out later how to fine grain the permissions

Create a user dataexplorer1 and grant a "developer" role to it:

communicating with Nexus using REST API (components and assets)

List components:

curl -u admin:pAsSwordHeRe -X GET 'http://192.168.2.22:8081/service/rest/v1/components?repository=cbareleases'

curl -u admin:pAsSwordHeRe -X GET 'http://192.168.2.22:8081/service/rest/v1/assets?repository=maven-releases'

curl -u admin:pAsSwordHeRe -X GET 'http://192.168.2.22:8081/service/rest/v1/components?repository=maven-releases'
{
"items" : [ {
"id" : "bWF2ZW4tcmVsZWFzZXM6ZDQ4MTE3NTQxZGNiODllYzg0Y2I0OTg5OTMwODBjY2Q",
"repository" : "maven-releases",
"format" : "maven2",
"group" : "com.cba.spark",
"name" : "cbaSpark",
"version" : "1.0.1",
"assets" : [ {
"downloadUrl" : "http://192.168.2.22:8081/repository/maven-releases/com/cba/spark/cbaSpark/1.0.1/cbaSpark-1.0.1.jar",
"path" : "com/cba/spark/cbaSpark/1.0.1/cbaSpark-1.0.1.jar",
"id" : "bWF2ZW4tcmVsZWFzZXM6ZjIxZmYzYjJhNGMyNGFhYWY4NmQ3OTU0YTg0OTI3ODg",
"repository" : "maven-releases",
"format" : "maven2",
"checksum" : {
"sha1" : "85bf1c138ea66a7a1952d5917991a20e3cffcffc",
"md5" : "15f044398cb591092dc42c98143dd221"
}
}, {

Get a component using the download URL and saving the output locally:

curl -u admin:pAsSwordHeRe -X GET 'http://192.168.2.22:8081/repository/maven-releases/com/cba/spark/cbaSpark/1.0.2/cbaSpark-1.0.2.jar' --output cbaSpark-1.0.2.jar

or 

wget http://192.168.2.22:8081/repository/maven-releases/com/cba/spark/cbaSpark/1.0.1/cbaSpark-1.0.1.jar

Uploading to Nexus from commandline:

curl -v -u admin:pAsSwordHeRe --upload-file cbaWorkflow-1.0.0-1.x86_64.rpm  http://192.168.2.22:8081/repository/cbareleases/com/cbaWorkflow/rpms/1.0.0/1/cbaWorkflow-1.0.0-1.x86_64.rpm