Class AbstractReportPublisher
- java.lang.Object
-
- hudson.tasks.BuildStepCompatibilityLayer
-
- hudson.tasks.Publisher
-
- hudson.tasks.Recorder
-
- de.tracetronic.jenkins.plugins.ecutest.report.AbstractReportPublisher
-
- All Implemented Interfaces:
ExtensionPoint
,Describable<Publisher>
,BuildStep
,SimpleBuildStep
- Direct Known Subclasses:
AbstractToolPublisher
,ATXPublisher
,ETLogPublisher
,TRFPublisher
public abstract class AbstractReportPublisher extends Recorder implements SimpleBuildStep
Common base class for all report publishers.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class hudson.tasks.Publisher
Publisher.DescriptorExtensionListImpl
-
Nested classes/interfaces inherited from interface hudson.tasks.BuildStep
BuildStep.PublisherList
-
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
Nested classes/interfaces inherited from interface jenkins.tasks.SimpleBuildStep
SimpleBuildStep.LastBuildAction, SimpleBuildStep.LastBuildActionFactory
-
-
Field Summary
-
Fields inherited from interface hudson.tasks.BuildStep
BUILDERS, PUBLISHERS
-
-
Constructor Summary
Constructors Constructor Description AbstractReportPublisher()
Instantiates a newAbstractReportPublisher
.AbstractReportPublisher(boolean allowMissing, boolean runOnFailed, boolean archiving, boolean keepAll)
Instantiates a newAbstractReportPublisher
.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected boolean
canContinue(Result result)
Returns whether this publisher can continue processing.protected ETInstallation
configureToolInstallation(String toolName, Computer computer, TaskListener listener, EnvVars envVars)
Configures the tool installation for functioning in the node and the environment.protected FilePath
getArchiveTarget(Run<?,?> run)
Gets the archive target.boolean
getArchiving()
Equivalent getter withboolean
return type.AbstractReportDescriptor
getDescriptor()
protected long
getDirectorySize(FilePath directory)
Gets the total size of given directory recursively.protected long
getFileSize(FilePath file)
Gets the size of given file.static FilePath
getFirstReportFile(FilePath reportDir)
Gets the first TRF file found in given report directory.boolean
getKeepAll()
Equivalent getter withboolean
return type.protected TTConsoleLogger
getLogger()
Gets the logger instance.protected List<FilePath>
getProjectReportFiles(Run<?,?> run, FilePath workspace, Launcher launcher)
Builds a list of project report files for report generation.String
getReportDir()
protected List<FilePath>
getReportDirs(Run<?,?> run, FilePath workspace, Launcher launcher)
Gets the report directories either from test environment actions or downstream workspace.protected List<FilePath>
getReportFiles(Run<?,?> run, FilePath workspace, Launcher launcher)
Builds a list of TRF files for report generation.protected List<FilePath>
getReportFiles(String includes, String excludes, Run<?,?> run, FilePath workspace, Launcher launcher)
Builds a list of report files for report generation.BuildStepMonitor
getRequiredMonitorService()
protected String
getSettingsDir(Run<?,?> run, FilePath workspace)
Gets the settings directory, either previous ecu.test settings or default one.protected ETClient
getToolClient(String toolName, Run<?,?> run, FilePath workspace, Launcher launcher, TaskListener listener)
Configures an ecu.test client with given workspace settings.ETInstallation.DescriptorImpl
getToolDescriptor()
Gets the tool descriptor holding the installations.ETInstallation
getToolInstallation(String toolName, EnvVars envVars)
Gets the tool installation by descriptor and tool name.protected abstract String
getUrlName()
Gets the URL name that will be used for archiving and linking the reports.String
getWorkspace()
protected String
getWorkspaceDir(Run<?,?> run, FilePath workspace)
Gets the workspace directory, either previous ecu.test workspace or default one.boolean
isAllowMissing()
Returns whether missing reports are allowed.Boolean
isArchiving()
Returns whether archiving artifacts is enabled.boolean
isDownstream()
Returns whether this publisher is part ofDownStreamPublisher
actions.protected boolean
isETRunning(Launcher launcher, TaskListener listener)
Checks whether an ecu.test instance is still running.Boolean
isKeepAll()
Returns whether artifacts are archived for all successful builds, otherwise only the most recent.boolean
isRunOnFailed()
Returns whether this publisher can run for failed builds, too.protected boolean
isSkipped(boolean checkOS, Run<?,?> run, Launcher launcher)
Determines whether this publisher will be skipped depending on OS architecture and current build result.void
perform(Run<?,?> run, FilePath workspace, Launcher launcher, TaskListener listener)
protected abstract void
performReport(Run<?,?> run, FilePath workspace, Launcher launcher, TaskListener listener)
Performs the report-specific post-build operations.static String
randomId()
Generates a random alphanumeric id to be used for linking reports.static void
removePreviousReports(Run<?,?> run, Class<? extends AbstractReportAction> clazz)
Removes the report actions from all previous builds which published at project level.void
setAllowMissing(boolean allowMissing)
void
setArchiving(boolean archiving)
void
setDownstream(boolean downstream)
Transient setter to inform this publisher that it is part of aDownStreamPublisher
.void
setKeepAll(boolean keepAll)
void
setReportDir(String reportDir)
Transient setter for the downstream report directory.void
setRunOnFailed(boolean runOnFailed)
void
setWorkspace(String workspace)
Transient setter for the downstream workspace.-
Methods inherited from class hudson.tasks.Publisher
all, getProjectAction, needsToRunAfterFinalized, prebuild
-
Methods inherited from class hudson.tasks.BuildStepCompatibilityLayer
getProjectAction, getProjectActions, perform, perform, prebuild
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface hudson.tasks.BuildStep
getProjectAction, getProjectActions, perform, prebuild
-
Methods inherited from interface jenkins.tasks.SimpleBuildStep
perform, perform, requiresWorkspace
-
-
-
-
Constructor Detail
-
AbstractReportPublisher
public AbstractReportPublisher()
Instantiates a newAbstractReportPublisher
.
-
AbstractReportPublisher
public AbstractReportPublisher(boolean allowMissing, boolean runOnFailed, boolean archiving, boolean keepAll)
Instantiates a newAbstractReportPublisher
.- Parameters:
allowMissing
- specifies whether missing reports are allowedrunOnFailed
- specifies whether this publisher even runs on a failed buildarchiving
- specifies whether archiving artifacts is enabledkeepAll
- specifies whether artifacts are archived for all successful builds, otherwise only the most recent
-
-
Method Detail
-
getFirstReportFile
@CheckForNull public static FilePath getFirstReportFile(FilePath reportDir) throws IOException, InterruptedException
Gets the first TRF file found in given report directory.- Parameters:
reportDir
- the report directory- Returns:
- the first report file or
null
if not found - Throws:
IOException
- signals that an I/O exception has occurredInterruptedException
- if the build gets interrupted
-
removePreviousReports
public static void removePreviousReports(Run<?,?> run, Class<? extends AbstractReportAction> clazz) throws IOException
Removes the report actions from all previous builds which published at project level.- Parameters:
run
- the runclazz
- the report action class to remove- Throws:
IOException
- signals that an I/O exception has occurred
-
isAllowMissing
public boolean isAllowMissing()
Returns whether missing reports are allowed.- Returns:
true
if missing reports are allowed,false
otherwise
-
setAllowMissing
@DataBoundSetter public void setAllowMissing(boolean allowMissing)
-
isRunOnFailed
public boolean isRunOnFailed()
Returns whether this publisher can run for failed builds, too.- Returns:
true
if this publisher can run for failed builds,false
otherwise
-
setRunOnFailed
@DataBoundSetter public void setRunOnFailed(boolean runOnFailed)
-
isArchiving
public Boolean isArchiving()
Returns whether archiving artifacts is enabled.- Returns:
true
if archiving artifacts is enabled,false
otherwise
-
getArchiving
public boolean getArchiving()
Equivalent getter withboolean
return type.- Returns:
true
if archiving artifacts is enabled,false
otherwise- See Also:
isArchiving()
-
setArchiving
@DataBoundSetter public void setArchiving(boolean archiving)
-
isKeepAll
public Boolean isKeepAll()
Returns whether artifacts are archived for all successful builds, otherwise only the most recent.- Returns:
true
if artifacts should be archived for all successful builds,false
otherwise
-
getKeepAll
public boolean getKeepAll()
Equivalent getter withboolean
return type.- Returns:
true
if artifacts should be archived for all successful builds,false
otherwise- See Also:
isKeepAll()
-
setKeepAll
@DataBoundSetter public void setKeepAll(boolean keepAll)
-
isDownstream
public boolean isDownstream()
Returns whether this publisher is part ofDownStreamPublisher
actions.- Returns:
true
, if downstream-based,false
otherwise
-
setDownstream
public void setDownstream(boolean downstream)
Transient setter to inform this publisher that it is part of aDownStreamPublisher
.- Parameters:
downstream
- the downstream flag
-
getWorkspace
public String getWorkspace()
-
setWorkspace
public void setWorkspace(String workspace)
Transient setter for the downstream workspace.- Parameters:
workspace
- the downstream workspace
-
getReportDir
public String getReportDir()
-
setReportDir
public void setReportDir(String reportDir)
Transient setter for the downstream report directory.- Parameters:
reportDir
- the downstream report directory
-
perform
public void perform(@Nonnull Run<?,?> run, @Nonnull FilePath workspace, @Nonnull Launcher launcher, @Nonnull TaskListener listener) throws InterruptedException, IOException
- Specified by:
perform
in interfaceSimpleBuildStep
- Throws:
InterruptedException
IOException
-
performReport
protected abstract void performReport(Run<?,?> run, FilePath workspace, Launcher launcher, TaskListener listener) throws InterruptedException, IOException, ETPluginException
Performs the report-specific post-build operations.- Parameters:
run
- the runworkspace
- the workspacelauncher
- the launcherlistener
- the listener- Throws:
InterruptedException
- the interrupted exceptionIOException
- signals that an I/O exception has occurredETPluginException
- in case of report operation errors
-
getLogger
protected TTConsoleLogger getLogger()
Gets the logger instance.- Returns:
- the logger
-
isSkipped
protected boolean isSkipped(boolean checkOS, Run<?,?> run, Launcher launcher) throws ETPluginException
Determines whether this publisher will be skipped depending on OS architecture and current build result.- Parameters:
checkOS
- specifies whether to check OSrun
- the runlauncher
- the launcher- Returns:
true
when to skip,false
otherwise- Throws:
ETPluginException
- if Unix-based launcher
-
canContinue
protected boolean canContinue(Result result)
Returns whether this publisher can continue processing. Returnstrue
if the propertyrunOnFailed
is set or if the build is not aborted or failed.- Parameters:
result
- the run result- Returns:
true
if the build can continue
-
isETRunning
protected boolean isETRunning(Launcher launcher, TaskListener listener) throws IOException, InterruptedException
Checks whether an ecu.test instance is still running.- Parameters:
launcher
- the launcherlistener
- the listener- Returns:
true
if ecu.test is running,false
otherwise- Throws:
IOException
- signals that an I/O exception has occurredInterruptedException
- the interrupted exception
-
getToolClient
protected ETClient getToolClient(String toolName, Run<?,?> run, FilePath workspace, Launcher launcher, TaskListener listener) throws IOException, InterruptedException, ETPluginException
Configures an ecu.test client with given workspace settings.- Parameters:
toolName
- the tool namerun
- the runworkspace
- the workspacelauncher
- the launcherlistener
- the listener- Returns:
- the ecu.test client
- Throws:
IOException
- signals that an I/O exception has occurredInterruptedException
- the interrupted exceptionETPluginException
- in case of a COM exception
-
configureToolInstallation
protected ETInstallation configureToolInstallation(String toolName, Computer computer, TaskListener listener, EnvVars envVars) throws IOException, InterruptedException, ETPluginException
Configures the tool installation for functioning in the node and the environment.- Parameters:
toolName
- the tool name identifying the specific toolcomputer
- the computerlistener
- the listenerenvVars
- the environment variables- Returns:
- the tool installation
- Throws:
IOException
- signals that an I/O exception has occurredInterruptedException
- if the build gets interruptedETPluginException
- if the selected tool installation is not configured
-
getToolInstallation
public ETInstallation getToolInstallation(String toolName, EnvVars envVars)
Gets the tool installation by descriptor and tool name.- Parameters:
toolName
- the tool name identifying the specific toolenvVars
- the environment variables- Returns:
- the tool installation
-
getToolDescriptor
public ETInstallation.DescriptorImpl getToolDescriptor()
Gets the tool descriptor holding the installations.- Returns:
- the tool descriptor
-
getWorkspaceDir
protected String getWorkspaceDir(Run<?,?> run, FilePath workspace)
Gets the workspace directory, either previous ecu.test workspace or default one.- Parameters:
run
- the runworkspace
- the workspace- Returns:
- the workspace directory
-
getSettingsDir
protected String getSettingsDir(Run<?,?> run, FilePath workspace)
Gets the settings directory, either previous ecu.test settings or default one.- Parameters:
run
- the runworkspace
- the workspace- Returns:
- the settings directory
-
getArchiveTarget
protected FilePath getArchiveTarget(Run<?,?> run)
Gets the archive target.- Parameters:
run
- the run- Returns:
- the archive target
-
getUrlName
protected abstract String getUrlName()
Gets the URL name that will be used for archiving and linking the reports.- Returns:
- the URL name
-
getReportDirs
protected List<FilePath> getReportDirs(Run<?,?> run, FilePath workspace, Launcher launcher) throws IOException, InterruptedException
Gets the report directories either from test environment actions or downstream workspace.- Parameters:
run
- the runworkspace
- the workspacelauncher
- the launcher- Returns:
- the report directories
- Throws:
IOException
- signals that an I/O exception has occurred.InterruptedException
- the interrupted exception
-
getReportFiles
protected List<FilePath> getReportFiles(Run<?,?> run, FilePath workspace, Launcher launcher) throws IOException, InterruptedException
Builds a list of TRF files for report generation. Includes the TRF files generated during separate sub-project execution.- Parameters:
run
- the runworkspace
- the workspacelauncher
- the launcher- Returns:
- the list of report files
- Throws:
IOException
- signals that an I/O exception has occurredInterruptedException
- if the build gets interrupted
-
getReportFiles
protected List<FilePath> getReportFiles(String includes, String excludes, Run<?,?> run, FilePath workspace, Launcher launcher) throws IOException, InterruptedException
Builds a list of report files for report generation. Includes the report files generated during separate sub-project execution.- Parameters:
includes
- the includesexcludes
- the excludesrun
- the runworkspace
- the workspacelauncher
- the launcher- Returns:
- the list of report files
- Throws:
IOException
- signals that an I/O exception has occurredInterruptedException
- if the build gets interrupted
-
getProjectReportFiles
protected List<FilePath> getProjectReportFiles(Run<?,?> run, FilePath workspace, Launcher launcher) throws IOException, InterruptedException
Builds a list of project report files for report generation. Includes the TRF files generated during separate sub-project execution and excludes all package report files.- Parameters:
run
- the runworkspace
- the workspacelauncher
- the launcher- Returns:
- the list of project report files
- Throws:
IOException
- signals that an I/O exception has occurredInterruptedException
- if the build gets interrupted
-
getFileSize
protected long getFileSize(FilePath file) throws IOException, InterruptedException
Gets the size of given file.- Parameters:
file
- the file- Returns:
- the file size
- Throws:
IOException
- signals that an I/O exception has occurredInterruptedException
- the interrupted exception
-
getDirectorySize
protected long getDirectorySize(FilePath directory) throws IOException, InterruptedException
Gets the total size of given directory recursively.- Parameters:
directory
- the directory- Returns:
- the directory size
- Throws:
IOException
- signals that an I/O exception has occurredInterruptedException
- the interrupted exception
-
randomId
public static String randomId()
Generates a random alphanumeric id to be used for linking reports.- Returns:
- the random id string
-
getRequiredMonitorService
public BuildStepMonitor getRequiredMonitorService()
- Specified by:
getRequiredMonitorService
in interfaceBuildStep
-
getDescriptor
public AbstractReportDescriptor getDescriptor()
- Specified by:
getDescriptor
in interfaceDescribable<Publisher>
- Overrides:
getDescriptor
in classRecorder
-
-