Skip to content

About

SonarQube API client CLI & Golang SDK

Topics

Resources

Contributing

Stars

6 stars

Watchers

0 watching

Forks

Repository files navigation

SonarQube Go Client

Go Reference codecov License

A comprehensive, type-safe Go client library and command-line interface for the SonarQube Web API. Whether you're building automation tools, integrating SonarQube into your CI/CD pipeline, or managing your SonarQube instance from the terminal - this project has you covered.

📖 Documentation: https://boxboxjason.github.io/sonarqube-client-go/ · 📚 API reference: pkg.go.dev

Watch the sonarqube-client-go video

Features

  • Go SDK: strongly typed options and responses for every SonarQube V1 and V2 API service, token or basic authentication, opt-in retries with backoff, HTTP middleware for logging and tracing.
  • CLI (sonar-cli): every service and method as a subcommand, JSON / YAML / table output, automatic pagination with --all, shell completion.
  • Tested with unit tests and integration tests against real SonarQube Community and Enterprise instances.

Quick start

CLI

go install github.com/boxboxjason/sonarqube-client-go/v2/cmd/sonar-cli@latest

export SONAR_CLI_URL=https://sonar.example.com
export SONAR_CLI_TOKEN=mytoken
sonar-cli issues search --projects my-project --severities CRITICAL,MAJOR --all

Go SDK

go get github.com/boxboxjason/sonarqube-client-go/v2/sonar
client, err := sonar.NewClient(nil,
	sonar.WithBaseURL("https://sonarqube.example.com/api/"),
	sonar.WithToken("my-token"),
)
if err != nil {
	log.Fatal(err)
}

projects, _, err := client.Projects.Search(context.Background(), &sonar.ProjectsSearchOptions{
	Query: "my-service",
})

The documentation covers the CLI, the SDK, client configuration, errors and pagination and the list of services. It is built from the docs directory, and updated together with the code.

Contributing

Contributions are welcome: read the Contributing Guide, which covers the development setup, the tests and the documentation.

Reporting Issues

  • Report a bug with the steps to reproduce, the Go, OS and SonarQube versions, and a minimal reproducer.
  • Request a feature.
  • Do not open a public issue for a security vulnerability: email the maintainers privately with the details.

License

Licensed under the Apache License 2.0, see LICENSE.

About

SonarQube API client CLI & Golang SDK

Topics

Resources

Contributing

Stars

6 stars

Watchers

0 watching

Forks

Releases

Used by

Contributors

Languages