Klasse SimpleReferenceRecorder
- Alle implementierten Schnittstellen:
ExtensionPoint
,Describable<Publisher>
,BuildStep
,SimpleBuildStep
- Bekannte direkte Unterklassen:
ReferenceRecorder
Several plugins that report build statistics (test results, code coverage, metrics, static analysis warnings) typically show their reports in two different ways: either as absolute report (e.g., total number of tests or warnings, overall code coverage) or as relative delta report (e.g., additional tests, increased or decreased coverage, new or fixed warnings). In order to compute a relative delta report a plugin needs to carefully select the other build to compare the current results to (a so called reference build). For simple Jenkins jobs that build the main branch of an SCM the reference build will be selected from one of the previous builds of the same job. For more complex branch source projects (i.e., projects that build several branches and pull requests in a connected job hierarchy) it makes more sense to select a reference build from a job that builds the actual target branch (i.e., the branch the current changes will be merged into). Here one typically is interested what changed in a branch or pull request with respect to the main branch (or any other target branch): e.g., how will the code coverage change if the team merges the changes. Selecting the correct reference build is not that easy, since the main branch of a project will evolve more frequently than a specific feature or bugfix branch.
This recorder unifies the computation of the reference build so consuming plugins can simply use the resulting
ReferenceBuild
in order to get a reference for their delta reports.
- Autor:
- Arne Schöntag, Ullrich Hafner
-
Verschachtelte Klassen - Übersicht
Modifizierer und TypKlasseBeschreibungstatic class
Descriptor for this step: defines the context and the UI data binding and validation.Von Klasse geerbte verschachtelte Klassen/Schnittstellen hudson.tasks.Publisher
Publisher.DescriptorExtensionListImpl
Von Schnittstelle geerbte verschachtelte Klassen/Schnittstellen hudson.tasks.BuildStep
BuildStep.PublisherList
Von Schnittstelle geerbte verschachtelte Klassen/Schnittstellen hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
Von Schnittstelle geerbte verschachtelte Klassen/Schnittstellen jenkins.tasks.SimpleBuildStep
SimpleBuildStep.LastBuildAction, SimpleBuildStep.LastBuildActionFactory
-
Feldübersicht
Von Schnittstelle geerbte Felder hudson.tasks.BuildStep
BUILDERS, PUBLISHERS
-
Konstruktorübersicht
ModifiziererKonstruktorBeschreibungCreates a new instance ofSimpleReferenceRecorder
.protected
SimpleReferenceRecorder
(io.jenkins.plugins.util.JenkinsFacade jenkins) Creates a new instance ofReferenceRecorder
. -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungprotected ReferenceBuild
createEmptyReferenceBuild
(Run<?, ?> run, edu.hm.hafner.util.FilteredLog messages) Finds a job with the given name.protected ReferenceBuild
findReferenceBuild
(Run<?, ?> run, edu.hm.hafner.util.FilteredLog log) getLastBuild
(Job<?, ?> reference) Returns the last build of the specified reference job.protected Optional
<ReferenceBuild> getReferenceBuildWithRequiredStatus
(Run<?, ?> run, Run<?, ?> start, edu.hm.hafner.util.FilteredLog log) Returns a reference build that satisfied the required status.Returns the name of the reference job.protected boolean
hasRequiredResult
(Run<?, ?> referenceBuild) Returns whether the specified build has a result that is better or equal than the required result.boolean
protected void
logNoBuildFound
(Job<?, ?> reference, edu.hm.hafner.util.FilteredLog log) void
protected Object
Called after deserialization to retain backward compatibility.resolveReferenceJob
(edu.hm.hafner.util.FilteredLog log) Finds a reference job that should be used as a starting point to find the reference build.void
setConsiderRunningBuild
(boolean considerRunningBuild) If enabled, then running builds will be considered as reference build as well.void
setReferenceJob
(String referenceJob) Sets the reference job: this job will be used as a baseline to search for the best matching reference build.void
setRequiredResult
(Result requiredResult) Sets that required build result of the reference build.Von Klasse geerbte Methoden hudson.tasks.Publisher
all, getProjectAction, needsToRunAfterFinalized, prebuild
Von Klasse geerbte Methoden hudson.tasks.BuildStepCompatibilityLayer
getProjectAction, getProjectActions, perform, perform, prebuild
Von Klasse geerbte Methoden java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Von Schnittstelle geerbte Methoden hudson.tasks.BuildStep
getProjectAction, getProjectActions, perform, prebuild
Von Schnittstelle geerbte Methoden jenkins.tasks.SimpleBuildStep
perform, perform, requiresWorkspace
-
Konstruktordetails
-
SimpleReferenceRecorder
@DataBoundConstructor public SimpleReferenceRecorder()Creates a new instance ofSimpleReferenceRecorder
. -
SimpleReferenceRecorder
protected SimpleReferenceRecorder(io.jenkins.plugins.util.JenkinsFacade jenkins) Creates a new instance ofReferenceRecorder
.- Parameter:
jenkins
- facade to Jenkins
-
-
Methodendetails
-
readResolve
Called after deserialization to retain backward compatibility.- Gibt zurück:
- this
-
setReferenceJob
Sets the reference job: this job will be used as a baseline to search for the best matching reference build. If the reference job should be computed automatically (supported bymulti-branch projects
only), then let this field empty. If the reference job is not defined and cannot be computed automatically, then the current job will be used.- Parameter:
referenceJob
- the name of reference job
-
getReferenceJob
Returns the name of the reference job.- Gibt zurück:
- the name of reference job
-
setRequiredResult
Sets that required build result of the reference build. If the reference build has a worse status, then the selected reference build will not be used.- Parameter:
requiredResult
- the minimum required build result
-
getRequiredResult
-
hasRequiredResult
Returns whether the specified build has a result that is better or equal than the required result.- Parameter:
referenceBuild
- the reference build to check- Gibt zurück:
true
if the build has a result that is better or equal than the required result,false
otherwise
-
getRequiredMonitorService
- Angegeben von:
getRequiredMonitorService
in SchnittstelleBuildStep
-
getDescriptor
- Angegeben von:
getDescriptor
in SchnittstelleDescribable<Publisher>
- Setzt außer Kraft:
getDescriptor
in KlasseRecorder
-
perform
public void perform(@NonNull Run<?, ?> run, @NonNull FilePath workspace, @NonNull EnvVars env, @NonNull Launcher launcher, @NonNull TaskListener listener) - Angegeben von:
perform
in SchnittstelleSimpleBuildStep
-
setConsiderRunningBuild
@DataBoundSetter public void setConsiderRunningBuild(boolean considerRunningBuild) If enabled, then running builds will be considered as reference build as well. Otherwise, only completed builds are considered. Enabling this option might cause problems if the reference build has not yet all the required results available.- Parameter:
considerRunningBuild
- iftrue
then running builds will be considered as reference build as well
-
isConsiderRunningBuild
public boolean isConsiderRunningBuild() -
findReferenceBuild
-
logNoBuildFound
-
getReferenceBuildWithRequiredStatus
protected Optional<ReferenceBuild> getReferenceBuildWithRequiredStatus(Run<?, ?> run, Run<?, ?> start, edu.hm.hafner.util.FilteredLog log) Returns a reference build that satisfied the required status. Starting with the specifiedstart
build, the history of builds is searched for a build that satisfies the required status. If no such build is found, then a null object is returned.- Parameter:
run
- the run that is currently builtstart
- the first build to start the searchlog
- the logger- Gibt zurück:
- the reference build that satisfies the required status (or empty if no such build is found)
-
createEmptyReferenceBuild
protected ReferenceBuild createEmptyReferenceBuild(Run<?, ?> run, edu.hm.hafner.util.FilteredLog messages) -
resolveReferenceJob
Finds a reference job that should be used as a starting point to find the reference build.- Parameter:
log
- the logger- Gibt zurück:
- the reference job (if available)
-
findJob
Finds a job with the given name.- Parameter:
jobName
- the name of the joblog
- the logger- Gibt zurück:
- the job with the given name (if existing)
-
getLastBuild
Returns the last build of the specified reference job. If the reference build is not completed and the optionconsiderRunningBuild
is set, then the last running build is returned. Otherwise, the last completed build is returned.- Parameter:
reference
- the reference job- Gibt zurück:
- the last build of the reference job
-