Gamification: Using Quality Gates as "divisions"

85 views
Skip to first unread message

alix....@gmail.com

unread,
Oct 25, 2017, 3:34:08 AM10/25/17
to SonarQube
Hi,

I was at the Stockholm Meetup yesterday (nice presentations by the way, it's evident that you use your own product!) and had the opportunity to hear you talk about the roadmap for SonarQube and that you plan for "Gamification" (badges, ranking, etc).
I had similar thoughts in order to raise awareness/interest in code quality and did a proof of concept for a SonarQube plugin half a year ago: https://stackoverflow.com/questions/43256778/using-httpconnector-in-a-sonarqube-plugin 

My goal with the plugin was to create a sports-like division system where the projects with highest quality would be promoted to the "Champions League" (strictest) Quality Gat , whereas projects that do not have the quality necessary are demoted to lower divisions (more relaxed Quality Gates) automatically.

My implementation requires a HttpConnector with hard-coded credentials in the plugin in order to access the functionality needed to do what I intended to do (i.e. changing Quality Gate for a project automatically based on build result from the Compute Engine).
Is my old approach the only way to achieve this in SonarQube 6.x (proof of concept based on SQ 5.x)?

/ Alix

G. Ann Campbell

unread,
Oct 25, 2017, 9:21:48 AM10/25/17
to SonarQube
Hi Alix,

Thanks for sharing this. 

What triggers a reclassification? Analysis?


Ann

alix....@gmail.com

unread,
Oct 26, 2017, 4:23:38 AM10/26/17
to SonarQube
Hi Ann,

the plugin fetches the Quality Gate status after a project analysis has been completed:
  • If the status is ERROR it would demote the project to a lower Quality Gate if possible
  • If the status is OK it would promote the project to a higher Quality Gate if possible
  • If the status is WARN nothing happens
I would imagine that this simple behavior is perhaps to crude for real usage and that promotion/demotion would be triggered only after a longer period of failure/success but it's a start.

The plugin assumes that Quality Gates with these names exist: "Low", "Medium", "High".

To get this to work I needed to use the following web services:
api/qualitygates/list
api/qualitygates/project_status
api/projects/index
api/qualitygates/select

/ Alix

Julien Lancelot

unread,
Oct 26, 2017, 9:44:45 AM10/26/17
to SonarQube
Hi Alix,

I confirm that you need to do a HTTP connexion with credentials (note that you should use token) to do what you want to do, whatever the version of SonarQube you're using (5.X, 6.X).

But in 6.X, you may be interested in using the project tags to categorize projects.
And I don't know how you know that a project analysis has been done, but you also may be interested in the different hooks that are now provided by SonarQube.

Regards,
Julien Lancelot

alix....@gmail.com

unread,
Oct 26, 2017, 9:53:55 AM10/26/17
to SonarQube
Hi Julien,

Thanks for the info and advice. 
I can confirm that I used a hook (Plugin.Context.addExtension()) to add a custom PostProjectAnalysisTask.
Tags seems powerful. One way to improve on the plugin would be to let the hook tag the project depending on the build status(es) and then at a given time perform assignment of Quality Gates based on the tags.

/Alix

Julien Lancelot

unread,
Oct 26, 2017, 10:15:04 AM10/26/17
to alix....@gmail.com, SonarQube
On Thu, 26 Oct 2017 at 15:53 <alix....@gmail.com> wrote:
Hi Julien,

Thanks for the info and advice. 
I can confirm that I used a hook (Plugin.Context.addExtension()) to add a custom PostProjectAnalysisTask.
Tags seems powerful. One way to improve on the plugin would be to let the hook tag the project depending on the build status(es) and then at a given time perform assignment of Quality Gates based on the tags.

I understand, but we want to keep hook as simple as possible as everything is already possible by using web services.
 
--
You received this message because you are subscribed to the Google Groups "SonarQube" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonarqube+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonarqube/32974893-4f35-4b08-ad65-a03b51963518%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
Julien Lancelot | SonarSource

alix....@gmail.com

unread,
Oct 26, 2017, 10:19:43 AM10/26/17
to SonarQube
Oh, I only meant changes to the experimental plugin that I made. Not the hook itself.

Julien Lancelot

unread,
Oct 26, 2017, 10:55:59 AM10/26/17
to alix....@gmail.com, SonarQube
On Thu, 26 Oct 2017 at 16:19 <alix....@gmail.com> wrote:
Oh, I only meant changes to the experimental plugin that I made. Not the hook itself.

Ok !
 

For more options, visit https://groups.google.com/d/optout.

alix....@gmail.com

unread,
Nov 9, 2017, 9:17:35 AM11/9/17
to SonarQube
Here's a video of the concept: https://gofile.io/?c=XKqb5A

Some feedback that I received in my organization is that it's good to focus gamification on teams rather than individuals.

/ Alix

alix....@gmail.com

unread,
Nov 9, 2017, 4:55:06 PM11/9/17
to SonarQube
FYI: gofile.io seems to be infected with some cryptojacking javascript that I didn't notice when I uploaded the file. 

Here is a better link (valid 30 days): https://ufile.io/chcd6

My hope is that future versions of SonarQube would be more flexible to support this way of working with Quality Gates.
Hurdles today to achieve what is in the video:
- Hard-coded SQ credentials compiled into the plugin
- Not possible to say that a Quality Gate is related to another Quality Gate (stricter, more relaxed than) -> need to hard-code this relation into the plugin with hard-coded Quality Gate names to achieve the re-assignment

/ Alix

G. Ann Campbell

unread,
Nov 15, 2017, 3:29:30 PM11/15/17
to Alix Warnke, SonarQube
Hi Alix,

Super cute video! :-)

Thanks for sharing. No promises.


Ann



---
G. Ann Campbell | SonarSource
Product Manager
@GAnnCampbell

--
You received this message because you are subscribed to a topic in the Google Groups "SonarQube" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sonarqube/OLQ1Pglflpk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sonarqube+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonarqube/b56b9ba3-f8c5-4e2d-acf1-e2d6f6e9ee6e%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages