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());
}
}
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());
}
}
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);
}
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);
}
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);
}
Aggregations