Method: NexusCli::RepositoryActions#create_repository

Defined in:
lib/nexus_cli/mixins/repository_actions.rb

#create_repository(name, proxy, url, id, policy, provider) ⇒ Boolean

Creates a repository that the Nexus uses to hold artifacts.

Parameters:

  • name (String)

    the name of the repository to create

  • proxy (Boolean)

    true if this is a proxy repository

  • url (String)

    the url for the proxy repository to point to

  • id (String)

    the id of repository

  • policy (String)

    repository policy (RELEASE|SNAPSHOT)

  • provider (String)

    repo provider (maven2 by default)

Returns:

  • (Boolean)

    returns true on success



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/nexus_cli/mixins/repository_actions.rb', line 17

def create_repository(name, proxy, url, id, policy, provider)
  json = if proxy
    create_proxy_repository_json(name, url, id, policy, provider)
  else
    create_hosted_repository_json(name, id, policy, provider)
  end
  response = nexus.post(nexus_url("service/local/repositories"), :body => json, :header => DEFAULT_CONTENT_TYPE_HEADER)
  case response.status
  when 201
    return true
  when 400
    raise CreateRepsitoryException.new(response.content)
  else
    raise UnexpectedStatusCodeException.new(response.status)
  end
end