SonarCloud is the SaaS model of SonarQube, a device to detect and repair points in your code by inspecting code high quality and safety vulnerabilities. I wanted to automate the onboarding of each customers and code tasks into SonarCloud to remove the necessity to manually provision this stuff into the system.
SonarCloud has a Internet API which facilitated a variety of what I wanted to realize, nonetheless with some vital gaps which initially appeared to imply a few of the onboarding would want to nonetheless be handbook. Developing in Half 2 and later of this story will characteristic how I reverse engineered the Internet API to fill within the lacking components of the puzzle, however in Half 1 I’ll deal with an introduction of the fundamentals.
Initially I assumed I’d solely want a number of API calls, nonetheless it become many, so I ended up making a PowerShell module, PSSonarCloud, to facilitate straightforward re-use of comparable calls.
Set up PSSonarCloud from the PowerShell Gallery:
Provide your SonarCloud API key to create a connection variable:
Retrieve an inventory of tasks belonging to your SonarCloud group:
Retrieve an inventory of customers belonging to your SonarCloud group:
The module at the moment accommodates 15 capabilities for working with the API:
This solely covers a comparatively small a part of the API, nonetheless as per most of my different PowerShell modules the capabilities are wrappers round a single operate
Invoke-SonarCloudRestMethod which suggests ought to you must work with an API name that isn’t at the moment lined by PSSonarCloud then it must be simple.
For instance the next API name to record the branches of a challenge will not be a part of PSSonarCloud but:
The next code would get you there although: