0

I installed the helm repo plugin for nexus3

Now I want to create the helm hosted repo via RestAPI command, in the same way as I do for raw repository

# RAW Repository

curl -X POST "${NEXUS_URL}/service/rest/v1/script" \
     --user "admin:admin123" \
     -H "accept: application/json" \
     -H "Content-Type: application/json" \
     -d "{ \"name\": \"create_raw_repo\", \"content\": \"repository.createRawHosted(args, 'default')\", \"type\": \"groovy\"}"

curl -X POST "${NEXUS_URL}/service/rest/v1/script/create_raw_repo/run" \
     --user "admin:admin123" \
     -H "accept: application/json" \
     -H "Content-Type: text/plain" \
     -d "raw-release"


# HELM Repo

curl -X POST "${NEXUS_URL}/service/rest/v1/script" \
     --user "admin:admin123" \
     -H "accept: application/json" \
     -H "Content-Type: application/json" \
     -d "{ \"name\": \"create_helm_repo\", \"content\": \"repository.createHelmHosted(args, 'default')\", \"type\": \"groovy\"}"

curl -X POST "${NEXUS_URL}/service/rest/v1/script/create_helm_repo/run" \
     --user "admin:admin123" \
     -H "accept: application/json" \
     -H "Content-Type: text/plain" \
     -d "helm-demo-release"

The problem is that the repository.createHelmHosted method doesn't exists.

What is the correct way to do it?

Shurik
  • 562
  • 1
  • 7
  • 19
  • 1
    A minor correction here. You are not using REST API to create a repository. You are using REST API to run a script that will creates a repository. The HELM plugin doesn't come with scripting API helpers, so you have to write your own script. You can find more info in documentation: https://help.sonatype.com/repomanager3/rest-and-integration-api/script-api/writing-scripts – Dawid Sawa Sep 04 '19 at 12:06

1 Answers1

0

From version 3.21 nexus support OOB the helm repo and has REST API to create the repo

http://you-nexus:8081/service/rest/beta/repositories/helm/hosted


curl -X POST "http://you-nexus:8081/service/rest/beta/repositories/helm/hosted" \
     -H "accept: application/json" \
     -H "Content-Type: application/json" \
     -d "{ \"name\": \"internal\", \"online\": true, \"storage\": { \"blobStoreName\": \"default\", \"strictContentTypeValidation\": true, \"writePolicy\": \"allow_once\" }, \"cleanup\": { \"policyNames\": \"weekly-cleanup\" }}"

Shurik
  • 562
  • 1
  • 7
  • 19