Search in sources :

Example 26 with BuildInfo

use of org.jfrog.build.extractor.ci.BuildInfo in project build-info by JFrogDev.

the class BuildInfoRecorder method extract.

@Override
public BuildInfo extract(ExecutionEvent event) {
    MavenSession session = event.getSession();
    if (!session.getResult().hasExceptions()) {
        Date finish = new Date();
        long time = finish.getTime() - session.getRequest().getStartTime().getTime();
        BuildInfo buildInfo = buildInfoBuilder.durationMillis(time).build();
        PackageManagerUtils.collectEnvIfNeeded(conf, buildInfo);
        return buildInfo;
    }
    return null;
}
Also used : MavenSession(org.apache.maven.execution.MavenSession) BuildInfo(org.jfrog.build.extractor.ci.BuildInfo)

Example 27 with BuildInfo

use of org.jfrog.build.extractor.ci.BuildInfo in project build-info by JFrogDev.

the class BuildInfoRecorder method sessionEnded.

@Override
public void sessionEnded(ExecutionEvent event) {
    try {
        BuildInfo buildInfo = extract(event);
        if (buildInfo != null) {
            File basedir = event.getSession().getTopLevelProject().getBasedir();
            buildDeploymentHelper.deploy(buildInfo, conf, deployableArtifactBuilderMap, projectHasTestFailures, basedir);
        }
        deployableArtifactBuilderMap.clear();
        if (wrappedListener != null) {
            wrappedListener.sessionEnded(event);
        }
    } catch (Throwable t) {
        String message = getClass().getName() + ".sessionEnded() listener has failed: ";
        logger.error(message, t);
        throw new RuntimeException(message, t);
    } finally {
        // This is used in Jenkins jobs
        String propertyFilePath = System.getenv(BuildInfoConfigProperties.PROP_PROPS_FILE);
        if (StringUtils.isBlank(propertyFilePath)) {
            // This is used in the Artifactory maven plugin and Bamboo
            propertyFilePath = conf.getPropertiesFile();
        }
        if (StringUtils.isNotBlank(propertyFilePath)) {
            File file = new File(propertyFilePath);
            if (file.exists()) {
                boolean deleteFailed = !file.delete();
                if (deleteFailed) {
                    logger.warn("Failed to delete properties file with sensitive data: " + propertyFilePath);
                }
            }
        }
    }
}
Also used : BuildInfo(org.jfrog.build.extractor.ci.BuildInfo) BuildInfoExtractorUtils.getModuleIdString(org.jfrog.build.extractor.BuildInfoExtractorUtils.getModuleIdString) BuildInfoExtractorUtils.getTypeString(org.jfrog.build.extractor.BuildInfoExtractorUtils.getTypeString) File(java.io.File)

Example 28 with BuildInfo

use of org.jfrog.build.extractor.ci.BuildInfo in project build-info by JFrogDev.

the class NpmBuildInfoExtractor method createBuild.

private BuildInfo createBuild(List<Dependency> dependencies, String moduleId) {
    Module module = new ModuleBuilder().type(ModuleType.NPM).id(moduleId).dependencies(dependencies).build();
    List<Module> modules = new ArrayList<>();
    modules.add(module);
    BuildInfo buildInfo = new BuildInfo();
    buildInfo.setModules(modules);
    return buildInfo;
}
Also used : ModuleBuilder(org.jfrog.build.extractor.builder.ModuleBuilder) BuildInfo(org.jfrog.build.extractor.ci.BuildInfo) ArrayList(java.util.ArrayList) Module(org.jfrog.build.extractor.ci.Module)

Aggregations

BuildInfo (org.jfrog.build.extractor.ci.BuildInfo)28 Module (org.jfrog.build.extractor.ci.Module)18 IOException (java.io.IOException)11 Path (java.nio.file.Path)6 ModuleBuilder (org.jfrog.build.extractor.builder.ModuleBuilder)6 Test (org.testng.annotations.Test)6 File (java.io.File)3 ArrayList (java.util.ArrayList)3 Date (java.util.Date)3 BuildInfoBuilder (org.jfrog.build.extractor.builder.BuildInfoBuilder)3 Artifact (org.jfrog.build.extractor.ci.Artifact)3 Vcs (org.jfrog.build.extractor.ci.Vcs)3 ArtifactoryClientConfiguration (org.jfrog.build.extractor.clientConfiguration.ArtifactoryClientConfiguration)3 DockerImage (org.jfrog.build.extractor.docker.types.DockerImage)3 Map (java.util.Map)2 BuildInfoExtractorUtils.jsonStringToBuildInfo (org.jfrog.build.extractor.BuildInfoExtractorUtils.jsonStringToBuildInfo)2 Agent (org.jfrog.build.extractor.ci.Agent)2 BuildAgent (org.jfrog.build.extractor.ci.BuildAgent)2 Dependency (org.jfrog.build.extractor.ci.Dependency)2 Issue (org.jfrog.build.extractor.ci.Issue)2