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.
  • Constructor Details

    • AbstractReportPublisher

      public AbstractReportPublisher()
      Instantiates a new AbstractReportPublisher.
    • AbstractReportPublisher

      public AbstractReportPublisher(boolean allowMissing, boolean runOnFailed, boolean archiving, boolean keepAll)
      Instantiates a new AbstractReportPublisher.
      Parameters:
      allowMissing - specifies whether missing reports are allowed
      runOnFailed - specifies whether this publisher even runs on a failed build
      archiving - specifies whether archiving artifacts is enabled
      keepAll - specifies whether artifacts are archived for all successful builds, otherwise only the most recent
  • Method Details

    • 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 occurred
      InterruptedException - 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 run
      clazz - 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 with boolean return type.
      Returns:
      true if archiving artifacts is enabled, false otherwise
      See Also:
    • 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 with boolean return type.
      Returns:
      true if artifacts should be archived for all successful builds, false otherwise
      See Also:
    • setKeepAll

      @DataBoundSetter public void setKeepAll(boolean keepAll)
    • isDownstream

      public boolean isDownstream()
      Returns whether this publisher is part of DownStreamPublisher 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 a DownStreamPublisher.
      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 interface SimpleBuildStep
      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 run
      workspace - the workspace
      launcher - the launcher
      listener - the listener
      Throws:
      InterruptedException - the interrupted exception
      IOException - signals that an I/O exception has occurred
      ETPluginException - 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 OS
      run - the run
      launcher - 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. Returns true if the property runOnFailed 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 launcher
      listener - the listener
      Returns:
      true if ecu.test is running, false otherwise
      Throws:
      IOException - signals that an I/O exception has occurred
      InterruptedException - 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 name
      run - the run
      workspace - the workspace
      launcher - the launcher
      listener - the listener
      Returns:
      the ecu.test client
      Throws:
      IOException - signals that an I/O exception has occurred
      InterruptedException - the interrupted exception
      ETPluginException - 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 tool
      computer - the computer
      listener - the listener
      envVars - the environment variables
      Returns:
      the tool installation
      Throws:
      IOException - signals that an I/O exception has occurred
      InterruptedException - if the build gets interrupted
      ETPluginException - 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 tool
      envVars - 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 run
      workspace - 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 run
      workspace - 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 run
      workspace - the workspace
      launcher - 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 run
      workspace - the workspace
      launcher - the launcher
      Returns:
      the list of report files
      Throws:
      IOException - signals that an I/O exception has occurred
      InterruptedException - 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 includes
      excludes - the excludes
      run - the run
      workspace - the workspace
      launcher - the launcher
      Returns:
      the list of report files
      Throws:
      IOException - signals that an I/O exception has occurred
      InterruptedException - 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 run
      workspace - the workspace
      launcher - the launcher
      Returns:
      the list of project report files
      Throws:
      IOException - signals that an I/O exception has occurred
      InterruptedException - 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 occurred
      InterruptedException - 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 occurred
      InterruptedException - 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 interface BuildStep
    • getDescriptor

      public AbstractReportDescriptor getDescriptor()
      Specified by:
      getDescriptor in interface Describable<Publisher>
      Overrides:
      getDescriptor in class Recorder