Search in sources :

Example 21 with BuildInfo

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

the class DockerExtractorTest method buildDockerCreateKanikoTest.

@Test
public void buildDockerCreateKanikoTest() throws IOException, InterruptedException {
    Path workingDirectory = Files.createTempDirectory("build-docker-create-kaniko-test", PosixFilePermissions.asFileAttribute(Sets.newHashSet(PosixFilePermission.OWNER_READ, PosixFilePermission.OWNER_WRITE, PosixFilePermission.OWNER_EXECUTE)));
    try {
        FileUtils.copyDirectory(new File(PROJECT_PATH), workingDirectory.toFile());
        Path kanikoConfig = createKanikoConfig(workingDirectory, virtualDomainName);
        String kanikoFile = execKaniko(workingDirectory, virtualDomainName, kanikoConfig);
        BuildDockerCreator buildDockerCreator = new BuildDockerCreator(artifactoryManagerBuilder, kanikoFile, BuildDockerCreator.ImageFileType.KANIKO, artifactProperties, dockerVirtualRepo, getLog());
        BuildInfo buildInfo = buildDockerCreator.execute();
        assertEquals(buildInfo.getModules().size(), 1);
        Module module = getAndValidateModule(buildInfo, "hello-world:latest", dockerVirtualRepo);
        module.getArtifacts().stream().map(BaseBuildFileBean::getRemotePath).forEach(remotePath -> assertEquals(remotePath, EXPECTED_REMOTE_PATH_KANIKO));
    } finally {
        FileUtils.deleteDirectory(workingDirectory.toFile());
    }
}
Also used : Path(java.nio.file.Path) BuildInfo(org.jfrog.build.extractor.ci.BuildInfo) Module(org.jfrog.build.extractor.ci.Module) File(java.io.File) Test(org.testng.annotations.Test)

Example 22 with BuildInfo

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

the class DockerExtractorTest method buildDockerCreateJibTest.

@Test
public void buildDockerCreateJibTest() throws IOException, InterruptedException {
    Path wd = Files.createTempDirectory("build-docker-create-jib-test", PosixFilePermissions.asFileAttribute(Sets.newHashSet(PosixFilePermission.OWNER_READ, PosixFilePermission.OWNER_WRITE, PosixFilePermission.OWNER_EXECUTE)));
    try {
        FileUtils.copyDirectory(PROJECTS_ROOT.resolve("maven-jib-example").toFile(), wd.toFile());
        execJib(wd);
        // Run build-docker-create
        BuildDockerCreator.ImageFileType imageFileType = BuildDockerCreator.ImageFileType.JIB;
        BuildInfo buildInfo = new BuildDockerCreator(artifactoryManagerBuilder, getJibImageJsonPath(wd), imageFileType, artifactProperties, dockerVirtualRepo, getLog()).execute();
        // Check modules
        assertEquals(buildInfo.getModules().size(), 3);
        Module module = getAndValidateModule(buildInfo, "multi1", dockerVirtualRepo);
        assertFalse(module.getArtifacts().isEmpty());
        module = getAndValidateModule(buildInfo, "multi2", dockerVirtualRepo);
        assertFalse(module.getArtifacts().isEmpty());
        module = getAndValidateModule(buildInfo, "multi3", dockerVirtualRepo);
        assertFalse(module.getArtifacts().isEmpty());
    } finally {
        FileUtils.deleteDirectory(wd.toFile());
    }
}
Also used : Path(java.nio.file.Path) BuildInfo(org.jfrog.build.extractor.ci.BuildInfo) Module(org.jfrog.build.extractor.ci.Module) Test(org.testng.annotations.Test)

Example 23 with BuildInfo

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

the class Utils method checkBuildResults.

/**
 * 1. Check the build status of all tasks.
 * 2. Make sure all artifacts deployed.
 *
 * @param artifactoryManager    - ArtifactoryManager client
 * @param buildResult           - The build results
 * @param expectModuleArtifacts - Should we expect *.module files
 * @param localRepo             - Artifactory local localRepo
 * @throws IOException - In case of any IO error
 */
static void checkBuildResults(ArtifactoryManager artifactoryManager, BuildResult buildResult, boolean expectModuleArtifacts, String localRepo) throws IOException {
    // Assert all tasks ended with success outcome
    assertProjectsSuccess(buildResult);
    // Check that all expected artifacts uploaded to Artifactory
    String[] expectedArtifacts = expectModuleArtifacts ? EXPECTED_MODULE_ARTIFACTS : EXPECTED_ARTIFACTS;
    for (String expectedArtifact : expectedArtifacts) {
        artifactoryManager.downloadHeaders(localRepo + ARTIFACTS_GROUP_ID + expectedArtifact);
    }
    // Check buildInfo info
    BuildInfo buildInfo = getBuildInfo(artifactoryManager, buildResult);
    assertNotNull(buildInfo);
    checkBuildInfoModules(buildInfo, 3, expectModuleArtifacts ? 5 : 4);
}
Also used : BuildInfoExtractorUtils.jsonStringToBuildInfo(org.jfrog.build.extractor.BuildInfoExtractorUtils.jsonStringToBuildInfo) BuildInfo(org.jfrog.build.extractor.ci.BuildInfo)

Example 24 with BuildInfo

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

the class Utils method checkLocalBuild.

static void checkLocalBuild(BuildResult buildResult, File buildInfoJson, int expectedModules, int expectedArtifactsPerModule) throws IOException {
    assertProjectsSuccess(buildResult);
    // Assert build info contains requestedBy information.
    assertTrue(buildInfoJson.exists());
    BuildInfo buildInfo = jsonStringToBuildInfo(CommonUtils.readByCharset(buildInfoJson, StandardCharsets.UTF_8));
    checkBuildInfoModules(buildInfo, expectedModules, expectedArtifactsPerModule);
    assertRequestedBy(buildInfo);
}
Also used : BuildInfoExtractorUtils.jsonStringToBuildInfo(org.jfrog.build.extractor.BuildInfoExtractorUtils.jsonStringToBuildInfo) BuildInfo(org.jfrog.build.extractor.ci.BuildInfo)

Example 25 with BuildInfo

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

the class IssuesCollectorTest method publishBuildInfoWithVcs.

private void publishBuildInfoWithVcs(List<Vcs> vcsList) throws IOException {
    BuildInfoBuilder buildInfoBuilder = new BuildInfoBuilder(BUILD_NAME).number(BUILD_NUMBER).startedDate(new Date()).url(getArtifactoryUrl()).vcs(vcsList);
    BuildInfo buildInfoToSend = buildInfoBuilder.build();
    // Publish build info
    artifactoryManager.publishBuildInfo(buildInfoToSend, null);
}
Also used : BuildInfoBuilder(org.jfrog.build.extractor.builder.BuildInfoBuilder) BuildInfo(org.jfrog.build.extractor.ci.BuildInfo) Date(java.util.Date)

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