Sonarqube Update Rule through Web-API - sonarqube

I am currently trying to update update a rule through the web api of sonarqube. I was trying to pass information like Serverity, Description and Remediation Function with the post request with the parameters according to the web api documentation. Everytime I tried to do that I got a response of 400.
But when I edited the request parameters to pass only the markdown_note and the key it worked and the note was set.
I honestly don't know what I am missing. According to the documentation it should work.

The description of the api/rules web services is :
Get and update some details of automatic rules, and manage custom
rules.
You can only update custom rules, not rules provided by language plugins.
The only exception to this is indeed the fact that you can add some notes on all rules.

Related

TeamCity REST API - update 'settings' for build configuration

I'm trying to use the TeamCity REST API to update settings against a build configuration. Specifically, the checkoutDirectory that in the UI is in the "Version Control Settings->Additional Options->Checkout directory" textbox...
The documentation talks about updating the "parameters", but not the settings.
If I do a GET on /app/rest/buildTypes/<id>, the results include both settings and parameters...
I've tried various combinations of PUT request to try to update this, but having no luck.
Interestingly, if I do a GET on /app/rest/buildTypes/<id>/parameters, I get this...
Which includes the ID in the URL.
But if I do /app/rest/buildTypes/<id>/settings, I get this...
Which doesn't include the ID. Not sure if that's a bug - or I've completely misunderstood the scope of these settings, and they're global, not per build config - but that's certainly not what I'm seeing in the UI.
Any ideas how to use the REST API to update these settings?

Can anyone help me in exporting Sonarqube rules which are Inactive using Web API?

I'm currently using SonarQube v5.6 and I'm trying to export the list of the rules that are inactive.
We can take "BackUp" of the rules that are active through the UI, but I'm trying to do this using Web API supported by Sonarqube on command line.
For Example:
I'm trying to export the rules which are not active in sonarqube:
http://$sonarqubeServer/coding_rules#qprofile=$key|activation=false
Can anyone please help me how to go about this ?
SonarQube Web API is pretty well documented (accessible from the footer of your server). api/rules offers api/rules/search which takes a bunch of parameters, including:
activation - Filter rules that are activated or deactivated on the selected Quality profile. Ignored if the parameter 'qprofile' is not
set.
qprofile - Key of Quality profile to filter on. Used only if the parameter 'activation' is set.
Bottom line, this request in the UI:
https://sonarqube.com/coding_rules#activation=false|qprofile=js-sonar-way-56838
Is equivalent to this Web API request:
https://sonarqube.com/api/rules/search?activation=no&qprofile=js-sonar-way-56838

SonarQube web-service api for rules

/api/rules?language=java is returning: page you are looking for does not exist.
Other apis are working fine but I want a list of rules with description for a particular profile.
How do I get that?
The correct URL for this Web Service is: /api/rules/search?languages=java
For instance on Nemo: http://nemo.sonarqube.org/api/rules/search?languages=java

REST Web API URL to update a resource property

To update the resource i have exposed following reset web api url -
http://server.com/api/v1/{companyid}/resources/{resourceid}
and request body contains the resource to be updated.
I have also exposed a seperate API to update a property of same resource. From business rule perspective this is special property and cannot be updated/retrieved along with normal resource api.
So using following url to expose separate api as below -
http://server.com/api/v1/{companyid}/resources/{resourceid}/property?propertyKey=propertyValue
this does not sound good. Is there better approach?
Answer from the comments for others
PUT api/v1/{companyid}/resources/{resourceid}/{property} with the Body containing the value of the property is one way.
PUT api/v1/{companyid}/resources/{resourceid}/{property}/{propertyvalue} is another way if you want the value entirely in the URL.
Of course, http://server.com/api/v1/{companyid}/resources/{resourceid}/property?propertyKey=propertyValue is also probably fine.
As #David-Brabant mentioned don't version your API's in the URL

How do I setup an external status page in TeamCity like their standard one that won't require me to login?

We have just moved from CCNET to TeamCity for Continuous Integration.
In TeamCity, I can use the ExternalStatus page/widget fine.
We run Cradiator (http://cradiator.codeplex.com) as a build radiator and notifier in our room and I have modified the Team Piazza TeamCity plug-in to return XML in the CCNET format so Cradiator can read it.
The problem I have is that the modified TeamPiazza page needs authentication, whereas the TeamCity externalstatus page doesn't.
So my question is: how can I make the custom page I have not require authentication?
TeamCity provides the AuthorizationInterceptor interface in their Open API that you can inject into your plugin code which allows you to control the authorisation requirement.
shamelessPlug This is what I used when writing the tcMonitor status page. /shamelessPlug
Here is example code on how to use it:
/* Add the objects into the constructor and spring will make them
available for you */
public StatusPageController(SBuildServer server,
AuthorizationInterceptor authorizationInterceptor,
UrlMapping urlMapper) {
// Tell teamcity that auth is not required for this page.
authorizationInterceptor.addPathNotRequiringAuth(myUrl);
you should post directly to the support forum http://www.jetbrains.net/devnet/community/teamcity/teamcity and post the answer back here if you want.
If a Guest User is enabled in TeamCity you can access the page with the HTTP access pattern for guest authentication.
For example if your page is
http://buildserver/teamcity/piazza.htm
you can access it by appending a /guestAuth into the URL:
http://buildserver/teamcity/guestAuth/piazza.htm

Resources