Class AnalysisHistory
- java.lang.Object
-
- io.jenkins.plugins.analysis.core.model.AnalysisHistory
-
- All Implemented Interfaces:
History
,Iterable<edu.hm.hafner.echarts.BuildResult<AnalysisBuildResult>>
public class AnalysisHistory extends Object implements History
Provides a history of static analysis results. The history starts from a baseline build and provides access to a historical build result of the same type (or to all historical results using the providedinterator
implementation). The results are filtered by aResultSelector
, so a history returns only results of the same type. This history can be configured to ignore the overall result of the associated Jenkins builds (seeJobResultEvaluationMode
). Additionally, this history can be configured to ignore the builds that did not pass the quality gate (seeQualityGateEvaluationMode
). Note that the baseline run might still be in progress and thus has not yet a result attached: i.e., the result of thegetPrevious*
methods may return different results on subsequent calls.- Author:
- Ullrich Hafner
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AnalysisHistory.JobResultEvaluationMode
static class
AnalysisHistory.QualityGateEvaluationMode
Determines how the evaluation of theQualityGateEvaluator
is taken into account when the previous result is searched for.
-
Constructor Summary
Constructors Constructor Description AnalysisHistory(Run<?,?> baseline, ResultSelector selector)
Creates a new instance ofAnalysisHistory
.AnalysisHistory(Run<?,?> baseline, ResultSelector selector, AnalysisHistory.QualityGateEvaluationMode qualityGateEvaluationMode, AnalysisHistory.JobResultEvaluationMode jobResultEvaluationMode)
Creates a new instance ofAnalysisHistory
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Optional<ResultAction>
getBaselineAction()
Returns the baseline action (if already available).Optional<AnalysisResult>
getBaselineResult()
Returns the baseline result (if already available).Optional<Run<?,?>>
getBuild()
Returns the build that contains the historical result (if there is any).edu.hm.hafner.analysis.Report
getIssues()
Returns the issues of the historical result.Optional<AnalysisResult>
getResult()
Returns the historical result (if there is any).boolean
hasMultipleResults()
Returns whether this history has more than one result.Iterator<edu.hm.hafner.echarts.BuildResult<AnalysisBuildResult>>
iterator()
String
toString()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Constructor Detail
-
AnalysisHistory
public AnalysisHistory(Run<?,?> baseline, ResultSelector selector)
Creates a new instance ofAnalysisHistory
. This history ignores theQualityGateStatus
of the quality gate and theResult
of the associatedRun
.- Parameters:
baseline
- the build to start the history fromselector
- selects the associated action from a build
-
AnalysisHistory
public AnalysisHistory(Run<?,?> baseline, ResultSelector selector, AnalysisHistory.QualityGateEvaluationMode qualityGateEvaluationMode, AnalysisHistory.JobResultEvaluationMode jobResultEvaluationMode)
Creates a new instance ofAnalysisHistory
.- Parameters:
baseline
- the run to start the history fromselector
- selects the type of the result (to get a result for the same type of static analysis)qualityGateEvaluationMode
- If set toAnalysisHistory.QualityGateEvaluationMode.IGNORE_QUALITY_GATE
, then the result of the quality gate is ignored when selecting a reference build. If set toAnalysisHistory.QualityGateEvaluationMode.SUCCESSFUL_QUALITY_GATE
a failing quality gate will be passed from build to build until the original reason for the failure has been resolved.jobResultEvaluationMode
- If set toAnalysisHistory.JobResultEvaluationMode.NO_JOB_FAILURE
, then only successful or unstable reference builds will be considered (since analysis results might be inaccurate if the build failed). If set toAnalysisHistory.JobResultEvaluationMode.IGNORE_JOB_RESULT
, then every build that contains a static analysis result is considered, even if the build failed.
-
-
Method Detail
-
getBaselineAction
public Optional<ResultAction> getBaselineAction()
Description copied from interface:History
Returns the baseline action (if already available).- Specified by:
getBaselineAction
in interfaceHistory
- Returns:
- the baseline action
-
getBaselineResult
public Optional<AnalysisResult> getBaselineResult()
Description copied from interface:History
Returns the baseline result (if already available).- Specified by:
getBaselineResult
in interfaceHistory
- Returns:
- the baseline result
-
getResult
public Optional<AnalysisResult> getResult()
Description copied from interface:History
Returns the historical result (if there is any).
-
getBuild
public Optional<Run<?,?>> getBuild()
Description copied from interface:History
Returns the build that contains the historical result (if there is any).
-
getIssues
public edu.hm.hafner.analysis.Report getIssues()
Description copied from interface:History
Returns the issues of the historical result. If there is no historical build found, then an empty set of issues is returned.
-
hasMultipleResults
public boolean hasMultipleResults()
Description copied from interface:History
Returns whether this history has more than one result.- Specified by:
hasMultipleResults
in interfaceHistory
- Returns:
true
if there are multiple results,false
otherwise
-
iterator
@NonNull public Iterator<edu.hm.hafner.echarts.BuildResult<AnalysisBuildResult>> iterator()
- Specified by:
iterator
in interfaceHistory
- Specified by:
iterator
in interfaceIterable<edu.hm.hafner.echarts.BuildResult<AnalysisBuildResult>>
-
-