Search in sources :

Example 6 with BuildDetailsImpl

use of org.jenkins.plugins.audit2db.internal.model.BuildDetailsImpl in project selenium_java by sergueik.

the class BuildDetailsResolver method resolveBuildDetails.

/**
 * This method creates a BuildDetails object with infomation from the
 * jobs run context.
 *
 * <b>Note:</b> The <code>endDate</code>, <code>duration</code>, and <code>result</code>
 * properties are <b>not</b> set, since that information is not accessiable from a pipeline
 * job without a {@link CpsFlowExecution}, which we may not have at call time.
 *
 * @param run This pipeline's run context
 * @param computer The node this job is currently running on. Since this is a pipeline job, it may be inconsistent.
 * @return The populated BuildDetails.
 */
public static BuildDetails resolveBuildDetails(Run<?, ?> run, Computer computer) {
    LOGGER.fine("resolving BuildDetails");
    BuildDetailsImpl details = new BuildDetailsImpl();
    LOGGER.fine("computer: " + computer);
    LOGGER.fine("run: " + run);
    LOGGER.fine("start time: " + run.getStartTimeInMillis());
    details.setFullName(run.getFullDisplayName());
    details.setId(run.getId());
    details.setName(run.getDisplayName());
    details.setStartDate(new Date(run.getStartTimeInMillis()));
    LOGGER.finer("base BuildDetails: " + details);
    try {
        addParametersFromContext(details, run);
        addUserInfoFromContext(details, run);
        addBuildNodeFromContext(details, run, computer);
    } catch (Exception e) {
        // IOException, InterruptedException
        throw new Audit2DbPipelineStepException(e);
    }
    return details;
}
Also used : BuildDetailsImpl(org.jenkins.plugins.audit2db.internal.model.BuildDetailsImpl) Date(java.util.Date) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException)

Aggregations

BuildDetailsImpl (org.jenkins.plugins.audit2db.internal.model.BuildDetailsImpl)6 BuildDetails (org.jenkins.plugins.audit2db.model.BuildDetails)5 Date (java.util.Date)3 FreeStyleBuild (hudson.model.FreeStyleBuild)2 FreeStyleProject (hudson.model.FreeStyleProject)2 ArrayList (java.util.ArrayList)2 DbAuditPublisher (org.jenkins.plugins.audit2db.DbAuditPublisher)2 BuildDetailsRepository (org.jenkins.plugins.audit2db.data.BuildDetailsRepository)2 BuildParameterImpl (org.jenkins.plugins.audit2db.internal.model.BuildParameterImpl)2 BuildParameter (org.jenkins.plugins.audit2db.model.BuildParameter)2 Test (org.junit.Test)2 BooleanParameterDefinition (hudson.model.BooleanParameterDefinition)1 ParameterDefinition (hudson.model.ParameterDefinition)1 ParametersDefinitionProperty (hudson.model.ParametersDefinitionProperty)1 StringParameterDefinition (hudson.model.StringParameterDefinition)1 IOException (java.io.IOException)1 UnknownHostException (java.net.UnknownHostException)1 BuildNodeImpl (org.jenkins.plugins.audit2db.internal.model.BuildNodeImpl)1 BuildNode (org.jenkins.plugins.audit2db.model.BuildNode)1