use of org.jfrog.build.extractor.ci.Artifact in project build-info by JFrogDev.
the class PropertiesTest method propsTest.
@Test
public void propsTest() throws Exception {
mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
propsTestPath = new File(this.getClass().getResource(PROPS_TEST_PATH).toURI()).getCanonicalFile();
downloadSpec = readSpec(new File(propsTestPath, DOWNLOAD_SPEC), tempWorkspace.getPath());
// Upload artifacts.
String uploadSpec = readSpec(new File(propsTestPath, UPLOAD_SPEC), tempWorkspace.getPath());
File uploadFromPath = new File(this.getClass().getResource("/workspace").toURI()).getCanonicalFile();
List<Artifact> uploaded = specsHelper.uploadArtifactsBySpec(uploadSpec, uploadFromPath, new HashMap<>(), artifactoryManagerBuilder);
Reporter.log("Uploaded " + uploaded.size() + " artifacts", true);
// Edit properties on the uploaded artifacts and verify.
editPropsAndVerify("setProps.json", EditPropertiesHelper.EditPropertiesActionType.SET, "p=v+1+d!", "setExpected.json");
editPropsAndVerify("deleteProps.json", EditPropertiesHelper.EditPropertiesActionType.DELETE, "p", "deleteExpected.json");
}
use of org.jfrog.build.extractor.ci.Artifact in project build-info by JFrogDev.
the class SpecsHelperIntegrationTest method integrationTests.
@Test(dataProvider = "testCases")
public void integrationTests(SingleSpecTest specTest) throws Exception {
Reporter.log("Running test: " + specTest.testPath, false);
// Upload artifacts.
File uploadFromPath = new File(this.getClass().getResource("/workspace").toURI()).getCanonicalFile();
List<Artifact> uploaded = specsHelper.uploadArtifactsBySpec(specTest.uploadSpec, uploadFromPath, new HashMap<>(), artifactoryManagerBuilder);
Reporter.log("Uploaded " + uploaded.size() + " artifacts", false);
// Download artifacts to compare against the expected result.
List<Dependency> downloaded = specsHelper.downloadArtifactsBySpec(specTest.downloadSpec, artifactoryManager, tempWorkspace.getPath());
Reporter.log("Downloaded " + downloaded.size() + " artifacts", false);
// Verify expected results
verifyExpected(specTest.expected, tempWorkspace);
}
use of org.jfrog.build.extractor.ci.Artifact in project build-info by JFrogDev.
the class SpecsHelper method convertDeployDetailsToArtifacts.
private List<Artifact> convertDeployDetailsToArtifacts(Set<DeployDetails> details) {
List<Artifact> result = new ArrayList<>();
for (DeployDetails detail : details) {
String ext = FilenameUtils.getExtension(detail.getFile().getName());
ArtifactBuilder artifactBuilder = new ArtifactBuilder(detail.getFile().getName());
artifactBuilder.md5(detail.getMd5()).sha1(detail.getSha1()).sha256(detail.getSha256()).type(ext).localPath(detail.getFile().getAbsolutePath()).remotePath(detail.getArtifactPath()).build();
result.add(artifactBuilder.build());
}
return result;
}
use of org.jfrog.build.extractor.ci.Artifact in project build-info by JFrogDev.
the class Utils method checkWebserviceArtifact.
/**
* Check webservice-1.0-SNAPSHOT.jar artifact under webservice module.
*
* @param webservice - The webservice module
*/
private static void checkWebserviceArtifact(Module webservice) {
Artifact webServiceJar = webservice.getArtifacts().stream().filter(artifact -> StringUtils.equals(artifact.getName(), "webservice-1.0-SNAPSHOT.jar")).findAny().orElse(null);
assertNotNull(webServiceJar);
assertEquals(webServiceJar.getType(), "jar");
assertEquals(webServiceJar.getRemotePath(), "org/jfrog/test/gradle/publish/webservice/1.0-SNAPSHOT/webservice-1.0-SNAPSHOT.jar");
assertTrue(StringUtils.isNotBlank(webServiceJar.getMd5()));
assertTrue(StringUtils.isNotBlank(webServiceJar.getSha1()));
assertTrue(StringUtils.isNotBlank(webServiceJar.getSha256()));
}
use of org.jfrog.build.extractor.ci.Artifact in project build-info by JFrogDev.
the class GradleBuildInfoExtractor method extract.
@Override
public BuildInfo extract(Project rootProject) {
String buildName = clientConf.info.getBuildName();
BuildInfoBuilder bib = new BuildInfoBuilder(buildName);
String buildNumber = clientConf.info.getBuildNumber();
bib.number(buildNumber);
String buildStartedIso = clientConf.info.getBuildStarted();
Date buildStartDate = null;
try {
buildStartDate = new SimpleDateFormat(BuildInfo.STARTED_FORMAT).parse(buildStartedIso);
} catch (ParseException e) {
log.error("Build start date format error: " + buildStartedIso, e);
}
bib.started(buildStartedIso);
BuildAgent buildAgent = new BuildAgent(clientConf.info.getBuildAgentName(), clientConf.info.getBuildAgentVersion());
bib.buildAgent(buildAgent);
// CI agent
String agentName = clientConf.info.getAgentName();
String agentVersion = clientConf.info.getAgentVersion();
if (StringUtils.isNotBlank(agentName) && StringUtils.isNotBlank(agentVersion)) {
bib.agent(new Agent(agentName, agentVersion));
} else {
// Fallback for standalone builds
bib.agent(new Agent(buildAgent.getName(), buildAgent.getVersion()));
}
long durationMillis = buildStartDate != null ? System.currentTimeMillis() - buildStartDate.getTime() : 0;
bib.durationMillis(durationMillis);
Set<File> moduleFilesWithModules = moduleInfoFileProducers.stream().filter(ModuleInfoFileProducer::hasModules).flatMap(moduleInfoFileProducer -> moduleInfoFileProducer.getModuleInfoFiles().getFiles().stream()).collect(Collectors.toSet());
moduleFilesWithModules.forEach(moduleFile -> {
try {
Module module = ModuleExtractorUtils.readModuleFromFile(moduleFile);
List<Artifact> artifacts = module.getArtifacts();
List<Dependency> dependencies = module.getDependencies();
if ((artifacts != null && !artifacts.isEmpty()) || (dependencies != null && !dependencies.isEmpty())) {
bib.addModule(module);
}
} catch (IOException e) {
throw new RuntimeException("Cannot load module info from file: " + moduleFile.getAbsolutePath(), e);
}
});
String parentName = clientConf.info.getParentBuildName();
String parentNumber = clientConf.info.getParentBuildNumber();
if (parentName != null && parentNumber != null) {
bib.parentName(parentName);
bib.parentNumber(parentNumber);
}
String principal = clientConf.info.getPrincipal();
if (StringUtils.isBlank(principal)) {
principal = System.getProperty("user.name");
}
bib.principal(principal);
String artifactoryPrincipal = clientConf.publisher.getUsername();
if (StringUtils.isBlank(artifactoryPrincipal)) {
artifactoryPrincipal = System.getProperty("user.name");
}
bib.artifactoryPrincipal(artifactoryPrincipal);
String artifactoryPluginVersion = clientConf.info.getArtifactoryPluginVersion();
if (StringUtils.isBlank(artifactoryPluginVersion)) {
artifactoryPluginVersion = "Unknown";
}
bib.artifactoryPluginVersion(artifactoryPluginVersion);
String buildUrl = clientConf.info.getBuildUrl();
if (StringUtils.isNotBlank(buildUrl)) {
bib.url(buildUrl);
}
String vcsRevision = clientConf.info.getVcsRevision();
if (StringUtils.isNotBlank(vcsRevision)) {
bib.vcsRevision(vcsRevision);
}
String vcsUrl = clientConf.info.getVcsUrl();
if (StringUtils.isNotBlank(vcsUrl)) {
bib.vcsUrl(vcsUrl);
}
Vcs vcs = new Vcs(vcsUrl, vcsRevision, clientConf.info.getVcsBranch(), clientConf.info.getVcsMessage());
if (!vcs.isEmpty()) {
bib.vcs(Arrays.asList(vcs));
}
if (clientConf.info.isReleaseEnabled()) {
String stagingRepository = clientConf.publisher.getRepoKey();
String comment = clientConf.info.getReleaseComment();
if (comment == null) {
comment = "";
}
bib.addStatus(new PromotionStatusBuilder(Promotion.STAGED).timestampDate(buildStartDate).comment(comment).repository(stagingRepository).ciUser(principal).user(artifactoryPrincipal).build());
}
String issueTrackerName = clientConf.info.issues.getIssueTrackerName();
if (StringUtils.isNotBlank(issueTrackerName)) {
Issues issues = new Issues();
issues.setAggregateBuildIssues(clientConf.info.issues.getAggregateBuildIssues());
issues.setAggregationBuildStatus(clientConf.info.issues.getAggregationBuildStatus());
issues.setTracker(new IssueTracker(issueTrackerName, clientConf.info.issues.getIssueTrackerVersion()));
Set<Issue> affectedIssuesSet = clientConf.info.issues.getAffectedIssuesSet();
if (!affectedIssuesSet.isEmpty()) {
issues.setAffectedIssues(affectedIssuesSet);
}
bib.issues(issues);
}
for (Map.Entry<String, String> runParam : clientConf.info.getRunParameters().entrySet()) {
MatrixParameter matrixParameter = new MatrixParameter(runParam.getKey(), runParam.getValue());
bib.addRunParameters(matrixParameter);
}
log.debug("buildInfoBuilder = " + bib);
// for backward compatibility for Artifactory 2.2.3
BuildInfo buildInfo = bib.build();
if (parentName != null && parentNumber != null) {
buildInfo.setParentBuildId(parentName);
}
PackageManagerUtils.collectEnvIfNeeded(clientConf, buildInfo);
return buildInfo;
}
Aggregations