Mac OS users can install using Homebrew (may not be the latest version):
brew install sonarqube-gem
Usage
Configuration example
Sonarqube.configure do |config|
config.endpoint = 'https://example.net:9000' # API endpoint URL, default: ENV['SONARQUBE_API_ENDPOINT']
config.private_token = 'Dfrt938dSgAOWd4' # user's private token, default: ENV['SONARQUBE_API_PRIVATE_TOKEN']
# Optional
# config.user_agent = 'Custom User Agent' # user agent, default: 'Sonarqube Ruby Gem [version]'
end
Usage examples
# set an API endpoint
Sonarqube.endpoint = 'https://example.net:9000'
# => "https://example.net:9000"
# set a user private token
Sonarqube.private_token = 'Dfrt938dSgAOWd4'
# => "Dfrt938dSgAOWd4"
# configure a proxy server
Sonarqube.http_proxy('proxyhost', 8888)
# proxy server with basic auth
Sonarqube.http_proxy('proxyhost', 8888, 'proxyuser', 'strongpasswordhere')
# set timeout for responses
ENV['SONARQUBE_API_HTTPARTY_OPTIONS'] = '{read_timeout: 60}'
groups = Sonarqube.search_groups({ q: 'sonar-users' })
# => #<Sonarqube::ObjectifiedHash:46520 {hash: {"paging"=>{"pageIndex"=>1, "pageSize"=>100, "total"=>1}, "groups"=>[{"uuid"=>"AXOt93S3gMZPhbn-E_O7", "name"=>"sonar-users", "description"=>"Any new users created will automatically join this group", "membersCount"=>5, "default"=>true}]}}
groups.groups.each do | group |
puts "name: #{group.name}"
puts "login: #{group.description}"
puts "membersCount: #{group.membersCount}"
end
# name: sonar-users
# description: Any new users created will automatically join this group
# MembersCount: 5
Sonarqube
website | documentation
Sonarqube is a Ruby wrapper and CLI for the Sonarqube API As of version
1.2.1this gem only supports Sonarqube 7.9.Installation
Install it from rubygems:
Or add to a Gemfile:
Mac OS users can install using Homebrew (may not be the latest version):
Usage
Configuration example
Usage examples
initialize a new client with custom headers
Projects
Create Project
Users
Create User
Groups
Search Group
For more information, refer to documentation.
Development
With a dockerized Sonarqube instance
After a while, your Sonarqube instance will be accessible on http://localhost:9000.
You can login with the admin/admin user/password.
You can now setup a personal access token here: http://localhost:9000
Once you have your token, set the variables to the correct values in the
docker.envfile.Then, launch the tool:
To launch the specs:
With an external Sonarqube instance
First, set the variables to the correct values in the
docker.envfile.Then, launch the tool:
To launch the specs,
For more information see CONTRIBUTING.md.
License
Released under the BSD 2-clause license. See LICENSE.txt for details.