1

I'd like to tag certain issues as related in SonarQube. The rules are defined in various different repositories including the out of the box Java one.

I can manually add tags to rules through the api and any issues created from them will inherit the tag, but this is tedious.

Is it possible to add tags to existing issues or rules within a plugin in SonarQube 5.1? If so how?

G. Ann - SonarSource Team
  • 22,346
  • 4
  • 40
  • 76
henry
  • 5,923
  • 29
  • 46

1 Answers1

1

First, don't forget that you can bulk edit issue tags via the interface. But that's not what you asked about. :-)

The UI is based almost entirely on web services at this point, so if there's something you can do in the interface that you want to automate in some way, it's likely just a matter of finding the right web service. In this case, https://nemo.sonarqube.org/web_api/api/issues/set_tags is what you want and/or https://nemo.sonarqube.org/web_api/api/issues/bulk_change.

I have the impression you may be after a one-time action here, so it's likely you can do what you want via the web services without having to write a plugin. That will let you edit existing issues. Future issues can be handled proactively by adding the tags to the relevant rules (https://nemo.sonarqube.org/web_api/api/rules/tags). As you said, new issues created from those rules will inherit the new tags.

If for some reason you really want to write a plugin, then simply call the web services from it.

G. Ann - SonarSource Team
  • 22,346
  • 4
  • 40
  • 76
  • We'd like to add tags to rules on multiple instances. Tags against rules don't seem to be exported when quality profiles are backed up - so the easiest way to share them looks to be a plugin, or is there another way to import tags into an instance? – henry Apr 28 '16 at 15:26
  • Ah! We'll call that a "missing feature" (cause that's how it's handled in JIra: https://jira.sonarsource.com/browse/SONAR-5366). I still wouldn't create a plugin tho, but set up a little web services client. But that's an implementation detail. Either way, you'll use the web services. – G. Ann - SonarSource Team Apr 28 '16 at 16:16