-
Notifications
You must be signed in to change notification settings - Fork 41
[JENKINS-24076] Add a configuration option for stable build comparison #24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,6 +54,13 @@ public class CppcheckResult implements Serializable { | |
* @since 1.15 | ||
*/ | ||
private CppcheckStatistics statistics; | ||
|
||
/** | ||
* Use stable builds only. | ||
* | ||
* @since 1.20 | ||
*/ | ||
private boolean stableBuild; | ||
|
||
/** | ||
* Constructor. | ||
|
@@ -68,6 +75,25 @@ public class CppcheckResult implements Serializable { | |
public CppcheckResult(CppcheckStatistics statistics, AbstractBuild<?, ?> owner) { | ||
this.statistics = statistics; | ||
this.owner = owner; | ||
this.stableBuild = false; | ||
} | ||
|
||
/** | ||
* Constructor. | ||
* | ||
* @param statistics | ||
* the Cppcheck report statistics | ||
* @param owner | ||
* the build owner | ||
* @param stableBuild | ||
* use only stable builds for deltas | ||
* | ||
* @since 1.15 | ||
*/ | ||
public CppcheckResult(CppcheckStatistics statistics, AbstractBuild<?, ?> owner, boolean stableBuild) { | ||
this.statistics = statistics; | ||
this.owner = owner; | ||
this.stableBuild = stableBuild; | ||
} | ||
|
||
/** | ||
|
@@ -230,6 +256,14 @@ public CppcheckResult getPreviousResult() { | |
*/ | ||
private CppcheckBuildAction getPreviousAction() { | ||
AbstractBuild<?, ?> previousBuild = owner.getPreviousBuild(); | ||
|
||
if (this.stableBuild) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Each build has its own stableBuild configuration at the moment, global configuration flag should be used here instead. |
||
// Iterate the build chain and find the last successful build. | ||
while (null != previousBuild && previousBuild.getResult().isWorseThan(hudson.model.Result.SUCCESS)) { | ||
previousBuild = previousBuild.getPreviousBuild(); | ||
} | ||
} | ||
|
||
if (previousBuild != null) { | ||
return previousBuild.getAction(CppcheckBuildAction.class); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,11 @@ | |
<label>${%Do not fail the build if the Cppcheck report is not found}</label> | ||
</f:entry> | ||
|
||
<f:entry field="stableBuild"> | ||
<f:checkbox name="cppcheck.stableBuild" checked="${config.stableBuild}"/> | ||
<label>${%Compare the Cppcheck report to the last stable build's Cppcheck report}</label> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Compare the report to the previous stable build's report |
||
</f:entry> | ||
|
||
<f:advanced> | ||
<u:thresholds id="cppcheck"/> | ||
</f:advanced> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<p style="margin-top: 0px;">By default, Cppcheck compares the report warnings | ||
and errors to that of the last build, which could be a build that was deemed | ||
unstable or that failed. To compare the results of this build against the last | ||
"stable" build instead, check this option.</p> | ||
|
||
<p>Note: When comparing against unstable builds, your builds could be marked as | ||
stable even when new errors or warnings have been introduced, because the delta | ||
between the last unstable build and current build could be zero. If the | ||
unstable build introduced a new error but resolve an error, then the total | ||
error count will still be within the permitted threshold. Another build with | ||
the same results will be marked as stable, allowing the new error to go | ||
unnoticed. Selecting this option will ensure all errors are accounted for.</p> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please update the help text, it is not fully correct in several statements. By default, the issues comparison is done between a build and the previous one independently to their status. To compare a build against the previous stable build, check this option. When computing a build status based on threshold of newly introduced issues without this option being checked, the build after an unstable one can be marked as stable even if no issue was fixed - the delta is zero. Enabling this option will ensure all builds after an unstable one will be unstable too until the threshold of new issues related to the last stable build is met. The plugin doesn't consider the source of build instability, it may and may not be the threshold. For example unit tests or code coverage can make the build unstable too. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stableBuild would be stored to build.xml together with all non-transient fields now. This data file should contain only data from the particular build, stableBuild is global configuration flag.