-
New Feature
-
Resolution: Fixed
-
Minor
-
None
-
Powered by SuggestiMate
At the moment there is REST api warningsResult/ that shows the combined warnings.
If the build counts gcc and lint warnings for example then it is impossible to know what each parsers value is since they get combined.
PC-lint's url is warnings0Result/
and
GCC's url is warnings17Result/
but there doesn't seem to be a way to find out what parsers was executed and what their values are beforehand. (without hardcoding and guessing urls)
So my request is for a REST api to provide a list of
names and urls
e.g.
[
,
{"parserName":"PC-Lint","url":"warnings0Result"}]
using this i can then go and query each url
[JENKINS-26113] REST api needed to get individual warnings values, not combined ones
sure, just point me to the relevant git location and java code to start and i will do some testing.
I made all project actions of analysis-core ready for remote API. So you just need to add your code to https://github.com/jenkinsci/warnings-plugin/blob/master/src/main/java/hudson/plugins/warnings/AggregatedWarningsProjectAction.java.
You can add elements using the @Exported annotation. The current result just returns the display name of the action (http://localhost:8080/job/[job-name]/warnings/api/xml):
<aggregatedWarningsProjectAction> <displayName>Compiler Warnings</displayName> <lastFinishedBuild> <number>57</number> <url>http://localhost:8080/job/Freestyle/57/</url> </lastFinishedBuild> </aggregatedWarningsProjectAction>
In that class you can read all project WarningProjectActions and return the IDs.
BTW: Rather than returning the URLs you can also return the actual aggregated results? Wouldn't that be more comfortable?
yes, that would be even better.
I will pull the code and see if i can get something going
i can't seem to get the list of warnings actions.....
I can see them in the debugger in the transientActions Vector but the values are protected
Can't you use
public <T extends Action> List<T> getActions(Class<T> type)
with the build or job object? Just use WarningsResultAction.class as type.
I added the following in AggregatedWarningsProjectAction.java
@Exported public List<WarningsResultAction> getWarningsResultAction() { List<WarningsResultAction> projectActions; // projectActions = this.getProject().getActions(WarningsResultAction.class); // can't use project, its actions list is allways empty // try getting the actions of the last build projectActions = this.getLastFinishedBuild().getActions(WarningsResultAction.class); return projectActions; }
Inside WarningsResultAction.java i then added the exported and visibility fields
@Exported(visibility = 2) @Override public String getUrlName() { return WarningsDescriptor.getResultUrl(parserName); } /** * Returns the parser group this result belongs to. * * @return the parser group */ @Exported(visibility = 2) public String getParser() { return parserName; } @Exported(visibility = 2) @Override public String getDisplayName() { return ParserRegistry.getParser(parserName).getLinkName().toString(); }
the ../warnings/api/xml REST api then gives me:
<aggregatedWarningsProjectAction> <displayName>Compiler Warnings</displayName> <lastFinishedBuild> <number>344</number> <url> http://localhost:8080/job/code_coverage/job/Build_L1PHY_el1c_task_test_MAT_gcc/344/ </url> </lastFinishedBuild> <warningsResultAction> <displayName>GNU C Compiler Warnings</displayName> <parser>GNU C Compiler 4 (gcc)</parser> <urlName>warnings18Result</urlName> </warningsResultAction> <warningsResultAction> <displayName>PC-Lint Warnings</displayName> <parser>PC-Lint</parser> <urlName>warnings0Result</urlName> </warningsResultAction> </aggregatedWarningsProjectAction>
So i now get the urlName and parser name i can use.
This is for a project, so to get the actual values for a particular build i can then do the calls to the particular parser urls.
if i do ../warnings/api/xml?depth=2 then i get the full value tree (for the last build)
<warningsResultAction> <name>warnings</name> <result> <newSuccessfulHighScore>false</newSuccessfulHighScore> <newZeroWarningsHighScore>false</newZeroWarningsHighScore> <numberOfFixedWarnings>0</numberOfFixedWarnings> <numberOfHighPriorityWarnings>0</numberOfHighPriorityWarnings> <numberOfLowPriorityWarnings>0</numberOfLowPriorityWarnings> <numberOfNewWarnings>0</numberOfNewWarnings> <numberOfNormalPriorityWarnings>2</numberOfNormalPriorityWarnings> <numberOfWarnings>2</numberOfWarnings> <pluginResult>SUCCESS</pluginResult> <referenceBuild> <number>343</number> <url> http://localhost:8080/job/code_coverage/job/Build_L1PHY_el1c_task_test_MAT_gcc/343/ </url> </referenceBuild> <successfulHighScore>0</successfulHighScore> <successfulSinceBuild>0</successfulSinceBuild> <successfulSinceDate>0</successfulSinceDate> <warning/> <warning/> <warningsDelta>0</warningsDelta> <zeroWarningsHighScore>1200233384</zeroWarningsHighScore> <zeroWarningsSinceBuild>0</zeroWarningsSinceBuild> <zeroWarningsSinceDate>0</zeroWarningsSinceDate> </result> <successful>true</successful> <displayName>GNU C Compiler Warnings</displayName> <parser>GNU C Compiler 4 (gcc)</parser> <urlName>warnings18Result</urlName> </warningsResultAction>
if i call .../buildNumber/warningsResult/api/xml
then i get the collated values for a particular build.
where do i need to add code to get the list of warnings actions in the /warningsResult/ call ?
The results are stored in AggregatedWarningsResultAction (one per parser per build). There you should add the code.
Note that at the project level you should ask for actions of type AggregatedWarningsProjectAction (one per parser per project). There are no AggregatedWarningsResultActions registered for a job (project).
ok, i have found a solution that gives me what i want with very minor changes
In WarningsResultAction i have just added 2 @Exported lines.
public WarningsResultAction(final AbstractBuild<?, ?> owner, final HealthDescriptor healthDescriptor, final WarningsResult result, final String parserName)
{ super(owner, new WarningsHealthDescriptor(healthDescriptor, ParserRegistry.getParser(parserName).getParserName()), result); this.parserName = parserName; } @Exported
@Override
public String getUrlName()
/**
- Returns the parser group this result belongs to.
* - @return the parser group
*/
@Exported
public String getParser() { return parserName; }
how do i get this back into the code ?
thanks,
I think i got it correct (i am a P4,svn guy...) but the builds are failing due to a dependency.
https://jenkins.ci.cloudbees.com/job/plugins/job/warnings-plugin/289/org.jvnet.hudson.plugins$warnings/console
hi, i just wanted to check if my change have actually made it into a release version ?
https://github.com/jenkinsci/warnings-plugin/commit/b39e09aeda5682c5e56b17d048cf2db6115050a9
Should be in 4.49, see https://github.com/jenkinsci/warnings-plugin/commits/master
That should be feasible. Interested in providing a pull request?