Klasse ReferenceRecorder
- Alle implementierten Schnittstellen:
ExtensionPoint
,Describable<Publisher>
,BuildStep
,SimpleBuildStep
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
Von Klasse geerbte verschachtelte Klassen/Schnittstellen io.jenkins.plugins.forensics.reference.SimpleReferenceRecorder
SimpleReferenceRecorder.SimpleReferenceRecorderDescriptor
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
ModifiziererKonstruktorBeschreibungprotected
Creates a new instance ofReferenceRecorder
.protected
ReferenceRecorder
(io.jenkins.plugins.util.JenkinsFacade jenkins) Creates a new instance ofReferenceRecorder
. -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungfind
(Run<?, ?> owner, Run<?, ?> lastCompletedBuildOfReferenceJob, edu.hm.hafner.util.FilteredLog logger) Returns the reference build for the given buildowner
.protected ReferenceBuild
findReferenceBuild
(Run<?, ?> run, edu.hm.hafner.util.FilteredLog logger) protected Optional
<jenkins.scm.api.SCMHead> findTargetBranchHead
(Job<?, ?> job) getScm()
boolean
void
setLatestBuildIfNotFound
(boolean latestBuildIfNotFound) If enabled, then the latest build of the reference job will be used if no other reference build has been found.void
Sets the SCM that should be used to find the reference build for.void
setTargetBranch
(String targetBranch) Sets the target branch formulti-branch projects
: the target branch is considered the base branch in your repository.Von Klasse geerbte Methoden io.jenkins.plugins.forensics.reference.SimpleReferenceRecorder
createEmptyReferenceBuild, findJob, getDescriptor, getLastBuild, getReferenceBuildWithRequiredStatus, getReferenceJob, getRequiredMonitorService, getRequiredResult, hasRequiredResult, isConsiderRunningBuild, logNoBuildFound, perform, readResolve, resolveReferenceJob, setConsiderRunningBuild, setReferenceJob, setRequiredResult
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
-
ReferenceRecorder
protected ReferenceRecorder()Creates a new instance ofReferenceRecorder
. -
ReferenceRecorder
protected ReferenceRecorder(io.jenkins.plugins.util.JenkinsFacade jenkins) Creates a new instance ofReferenceRecorder
.- Parameter:
jenkins
- facade to Jenkins
-
-
Methodendetails
-
setLatestBuildIfNotFound
@DataBoundSetter public void setLatestBuildIfNotFound(boolean latestBuildIfNotFound) If enabled, then the latest build of the reference job will be used if no other reference build has been found.- Parameter:
latestBuildIfNotFound
- iftrue
then the latest build of the reference job will be used if no matching reference build has been found, otherwise no reference build is returned.
-
isLatestBuildIfNotFound
public boolean isLatestBuildIfNotFound() -
setTargetBranch
Sets the target branch formulti-branch projects
: the target branch is considered the base branch in your repository. The builds of all other branches and pull requests will use this target branch as baseline to search for a matching reference build.- Parameter:
targetBranch
- the name of the default branch
-
getTargetBranch
-
setScm
Sets the SCM that should be used to find the reference build for. The reference recorder will select the SCM based on a substring comparison, there is no need to specify the full name.- Parameter:
scm
- the ID of the SCM to use (a substring of the full ID)
-
getScm
-
findReferenceBuild
- Setzt außer Kraft:
findReferenceBuild
in KlasseSimpleReferenceRecorder
-
findTargetBranchHead
-
find
protected Optional<Run<?,?>> find(Run<?, ?> owner, Run<?, ?> lastCompletedBuildOfReferenceJob, edu.hm.hafner.util.FilteredLog logger) Returns the reference build for the given buildowner
. The search should start with the last completed build of the reference build. This default implementation does nothing.- Parameter:
owner
- the owner to get the reference build forlastCompletedBuildOfReferenceJob
- the last completed build of the reference joblogger
- the logger to use- Gibt zurück:
- the reference build (if available)
-