Workflow Automation: Publishing Artifacts to Nexus Repository using Jenkins Pipelines

The goal of this guide is to create a workflow where we can build, store, organize, and monitor the compiled artifacts by Maven through our CI server.
Before we begin, make sure that you already have Jenkins up and running. In case you haven’t set up Jenkins yet, then copy the below command and run it on your Docker enabled host/machine.
$ docker run -d --name jenkins-ci -p 8080:8080 jenkins/jenkins:lts
Once the Jenkins container is configured on your local/remote machine, go to your preferred browser and open the URL: 
On the very first page, Jenkins will ask you for the admin password, which you can find by running below mentioned command in your terminal:
$  docker exec -i jenkins-ci cat /var/jenkins_home/secrets/initialAdminPassword

Follow the guided steps to finish the configuration. Save the username and password securely for future use.

Installing Nexus Repository

Nexus is a repository manager that allows you to store and retrieve artifacts. It enables you to host your built artifacts in a private and secure repo. [Editor’s Note: Free Nexus Repository training is available here.]
You can always pull the Nexus Docker image using the following command:
$ docker pull sonatype/nexus3

Using default tag: latest
latest: Pulling from sonatype/nexus3
cb3c77f9bdd8: Pull complete
fd8daf2668d1: Pull complete
fd1ff82b00e8: Pull complete
2a05f7b573af: Pull complete
Digest: sha256:6570855dfbc3eb094fe5cbbacec87aa8b91d16394dab627177e1deeebb5ac8ee
Status: Downloaded newer image for sonatype/nexus3:latest
Now it’s time to run downloaded sonatype/nexus on the default port 8081. Follow these commands:
$ docker run -d --name nexus_repo -p 8081:8081 sonatype/nexus3
Usually it takes 1 to 2 minutes for the Nexus service to launch in your newly created Docker container. If you wish to follow the log to see if Nexus is up and ready, then run the following command:

*** This is a Security Bloggers Network syndicated blog from Sonatype Blog authored by Dmitriy Akulov. Read the original post at: