Especially when demonstrating the Plugin Catalog functionality, a Nexus server is needed. The Plugin Catalog also requires a special Maven2 proxy repository to be configured. This example shows how to start a Nexus server (as a Docker container) et to configure the needed repository via the Nexus CLI.
The example directory contains the various command files in the directory example as well as a working Ansible role in the ansible-role directory.
nexus_docker-compose.yml
version: '3'
services:
nexus:
# The version must be pinned: later version have random default
# password which make automation more complicated.
image: sonatype/nexus3:3.16.2
ports:
- "8081:8081"
volumes:
- nexus-data:/nexus-data
volumes:
nexus-data:
driver: localNote the pinned image version.
start_nexus.sh
#!/usr/bin/env bash
docker-compose up -dstop_nexus.sh
#!/usr/bin/env bash
docker-compose downThe configuration is done with a groovy script that is loaded and then executed via the Nexus REST API.
The bash scripts are expected to run on the machine hosting the Docker containers (curl loacalhost).
load_nexus_script.sh
#!/usr/bin/env bash
curl -X POST -u admin:admin123 --header 'Content-Type: application/json' \
http://127.0.0.1:8081/service/rest/v1/script \
-d '{"name":"jenkins","type":"groovy","content":"repository.createMavenProxy('\''jenkins'\'','\''https://repo.cloudbees.com/content/repositories/dev-connect/'\'')"}'