Module: Sonarqube::Client::Projects

Included in:
Sonarqube::Client
Defined in:
lib/sonarqube/client/projects.rb

Overview

Defines methods related to projects.

Instance Method Summary collapse

Instance Method Details

#create_project(name, key = nil, options = {}) ⇒ Sonarqube::ObjectifiedHash Also known as: project_create

Creates a new project.

Examples:

Sonarqube.create_project('sonarqube','sonarqube)
Sonarqube.create_project('viking', 'ragnar' { visibility: 'private' })

Parameters:

  • name (String)

    The name of a project.

  • key (String) (defaults to: nil)

    The key of a project.

  • options (Hash) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • :visibility (String)

    Visibility of a project (public or private).

Returns:



40
41
42
43
# File 'lib/sonarqube/client/projects.rb', line 40

def create_project(name, key = nil, options = {})
  key = name if key.nil?
  post('/api/projects/create', body: { name: name, project: key }.merge(options))
end

#delete_project(key) ⇒ Sonarqube::ObjectifiedHash Also known as: project_delete

Deletes a project.

Examples:

Sonarqube.delete_project(4)

Parameters:

  • key (String)

    The key of project.

Returns:



53
54
55
# File 'lib/sonarqube/client/projects.rb', line 53

def delete_project(key)
  post('/api/projects/delete', body: { project: key })
end

#project_update_key(key_ori, key_new) ⇒ Array<Sonarqube::ObjectifiedHash> Also known as: update_key_project

Update project key.

Examples:

Sonarqube.project_update_key(42)
Sonarqube.project_update_key('sonarqube')

Parameters:

  • key_ori (String)

    The original key of a project.

  • key_new (String)

    The New key of a project.

Returns:



67
68
69
# File 'lib/sonarqube/client/projects.rb', line 67

def project_update_key(key_ori, key_new)
  post('/api/projects/update_key', body: { from: key_ori, to: key_new })
end

#project_update_visibility(project, visibility) ⇒ Sonarqube::ObjectifiedHash Also known as: update_visibility_project

Update project visibility.

Examples:

project_update_visibility('sonarqube', 'public')

Parameters:

  • project (String)

    The name fo project.

  • visibility (String)

    The visibility of a project.

Returns:



80
81
82
# File 'lib/sonarqube/client/projects.rb', line 80

def project_update_visibility(project, visibility)
  post('/api/projects/update_visibility', body: { project: project, visibility: visibility })
end

#projects_bulk_delete(options = {}) ⇒ Array<Sonarqube::ObjectifiedHash> Also known as: delete_bulk_projects

Bulk delete projects.

(Any provided options will be passed to Sonarqube. See https://SONAR_URL/web_api/api/projects/bulk_delete

Examples:

Sonarqube.project_bulk_delete()
Sonarqube.project_bulk_delete({ p: 2 })
Sonarqube.project_bulk_delete({ ps: 42, p: 5 })

Parameters:

  • options (Hash) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • :analyzedBefore (String)

    Filter the projects for which last analysis is older than the given date.

  • :onProvisionedOnly (Boolean)

    Filter the projects that are provisioned

  • :qualifiers (String)

    Filter the results with the specified qualifiers (TRK,VW,APP)

  • :q (String)

    Limit search to component names that contain the supplied string or component keys that contain the supplied string

  • :projects (String)

    Comma-separated list of project keys

Returns:



100
101
102
103
104
105
106
# File 'lib/sonarqube/client/projects.rb', line 100

def projects_bulk_delete(options = {})
  if options[:analyzedBefore].nil? && options[:projects].nil? && options[:q].nil?
    raise ArgumentError, 'Missing required parameters'
  end

  post('/api/projects/bulk_delete', body: options)
end

#projects_search(options = {}) ⇒ Array<Sonarqube::ObjectifiedHash> Also known as: search_projects

Search for projects by name.

(Any provided options will be passed to Sonarqube. See https://SONAR_URL/web_api/api/projects/search

Examples:

Sonarqube.project_search()
Sonarqube.project_search({ p: 2 })
Sonarqube.search_projects({ ps: 42, p: 5 })

Parameters:

  • options (Hash) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • :analyzedBefore (String)

    Filter the projects for which last analysis is older than the given date

  • :onProvisionedOnly (Boolean)

    Filter the projects that are provisioned

  • :ps (Integer)

    Page size number of projects to return per page

  • :p (Integer)

    The page to retrieve

  • :qualifiers (String)

    Filter the results with the specified qualifiers (TRK,VW,APP)

  • :q (String)

    Limit search to component names that contain the supplied string or component keys that contain the supplied string

  • :projects (String)

    Comma-separated list of project keys

Returns:



24
25
26
# File 'lib/sonarqube/client/projects.rb', line 24

def projects_search(options = {})
  get('/api/projects/search', query: options)
end