Git Product home page Git Product logo

nexus-claim's Introduction

Nexus Claim

Define your Sonatype Nexus repository structure as code. This script defaults to interact with a nexus server running on localhost.

Syntax of nexus-claim on nexus 3

$ nexus-claim plan -i input.hcl -o output.json
$ nexus-claim apply -i output.json

If in case of doubt, issue nexus-claim --help to get going.

Global Options

--server value, -s value    Url to the nexus server (default: "http://localhost:8081") [$NEXUS_SERVER]
--username value, -u value  Username of a nexus admin user (default: "admin") [$NEXUS_USER]
--password value, -p value  Password of the nexus user (default: "admin123") [$NEXUS_PASSWORD]
--nexus2                    use this flag to use nexus-claim with nexus 2 [$NEXUS_V2]
--help, -h                  show help
--version, -v               print the version

Testing with nexus 3

  1. Have a decent version of Golang installed
  2. Install Golang dependencies with go mod vendor && go mod tidy
  3. Build the software in the target/ directory
    • make clean && make
  4. Start up a local nexus
    • docker run -d -p 8081:8081 --name nexus sonatype/nexus3
    • Access docker container and extract admin password docker exec -it nexus sh than cat /nexus-data/admin.password
  5. Plan a custom repository .hcl file
    • target/nexus-claim --password "<password>" plan -i resources/nexus3/nexus_custom_example.hcl -o targetState.json
    • this reads existing repositories from the nexus, changes from the given .hcl file will make up the target state as JSON
    • the target state is supposed to be created within the nexus-claim application
  6. Apply target state .json file to nexus
    1. an auto-generated .groovy file responsible for interacting with the nexus API in terms of creating will be uploaded in the nexus.
    2. the .groovy file responsible for creation will be called with the target .json being the argument
  7. The repository changes are being written. Check the nexus frontend for changes.

Things to consider for .hcl of nexus 3

  • on maven2-hosted- and maven2-proxy-repository there must be a maven sector in addition(with versionPolicy and writePolicy)
  • Note the autogenerated .groovy files are only an interaction layer and should not contain larger application logic

Configuration Examples

nexus 3

Examples can be found in the nexus 3 resources directory. Also available in the same directory are resulting target .json files for reference.

nexus 2

Examples can be found in the nexus 2 resources directory

nexus-claim's People

Contributors

cbeyer42 avatar jbartscher avatar mbehlendorf avatar ppxl avatar robertauer avatar sdorra avatar tlnbs2405 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nexus-claim's Issues

Cope with structure change of Nexus repo cleanup policies

Problem

Sonatype introduced in Nexus 3.19 a structural change of its repository definition which leads to an error if the .hcl repositiory descriptor uses the cleanup object

  "cleanup": {
     "policyName": "None"
   },

This affects mainly the groovy meta script which tries to access the repo attribute.

The current policy object is no longer a single entry (mapped to a String) but instead a Multiselect (mapped to a List)

Workaround

If no cleanup is necessary it is possible to leave it out. No cleanup structure will then be generated, thusly the error is circumvented.

[Security] Introduce another way of providing nexus admin credentials

Currently (Nexus 3.23.0-6), the Nexus dogu exports an environment variable that contains an technical admin credential. nexus-claim reads this environment variable and uses it. As the environment variable is exported, all new processes are supplied with that environment variable.

It seems that this credential is only exported because of the usage of nexus-claim.

This imposed security risk of unwarranted users accessing this variable should be reduced. I propose a flag that take credentials like this:

nexus-claim plan -p ${unexportedCredential} -i "${PLAN}" -o "-" | nexus-claim apply -p ${unexportedCredential} -i "-"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.