How to configure nexus using the approach "infrastructure as code"?

We configure nexus oss using GUI but we want to store all settings as code, is it able?
For example teamcity can store all preferences, builds, steps in git repository useing kotlin dsl. Can i do with nexus something similar? Maybe cfg/yml file or ect

You could write a script to use the REST API to setup nexus

Hi, we’re actually going through this now. It will be a combination of a few things:

  1. updating configuration/property files
  2. using the API (you can see what is available to your version by going to the API section). note that not everything is exposed, hence the next point
  3. groovy - items like base url, creating a backup task etc

If you really want a fully configured system, be ready to write a lot of tasks ;). You may even want to explore with something like:

Not that clean but doable.

Hope this helps. Let me know if you need anymore details. I know some of these forums can get a bit frustrating with folks citing the not so obvious :wink:



There are a couple of other options too.

  1. nexus3-oss Ansible role GitHub - ansible-ThoTeam/nexus3-oss: Ansible role to install and provision sonatype nexus3-oss
  2. Nexus casc plugin GitHub - AdaptiveConsulting/nexus-casc-plugin: Configuration as code plugin for Sonatype Nexus Repository Manager

Disclaimer: I’m one of the maintainers of the casc plugin.




I think you must be using an older version most configuration options have REST API endpoints now.


We just upgraded because there we some apis which are using that went from beta to proper.

We are using groovy for the following:

  • changing the admin password
  • setting the base url
  • setting http proxy
  • and creating the db-backup task


FYI, our the beta rest apis are mostly marked beta in the event we need to change the interface. So far I don’t think that’s happened very often and we’ve been putting in a redirect from the beta to the v1 version so you shouldn’t even need to change your scripts when the v1 version is released.

The CASC looks interesting. From the looks of it, it’s more friendly to config/drift management. We already have a jenkins casc though :slight_smile:

We may look at this soon. Thanks!

awesome! thank you for letting me know.

Hi! @brett.dellegrazie we try to use your casc plugin in our infra. All work fine but we can’t create S3 Blobe Store via casc plugin. We try to use following config(no configuration example in your
- name: ibi-bucket-nexus
type: S3
region: us-east-1
bucket: ibi-bucket-nexus

But it not working, S3 Blob Storage not created and other (file storage) too.
Can you help?


Please raise an issue on GitHub and I’ll take a look.



@brett.dellegrazie I can’t see possibility create issue for your repo in github:

Silly me.
Enabled, please go ahead and create an issue.

ok. I created Issue)

For reference only, the issue has been resolved and there is now a worked example configuration to use S3

Is it possible to apply Nexus Pro License file using nexus casc plugin or using IAC approaches above?
We are using nexus casc plugin

You can load it via the properties file, or via REST - How to Install a Nexus Repository Manager 3 License – Sonatype Support

See here for the options available for installing a license: