use of org.jfrog.build.extractor.ci.IssuesCollectionConfig in project build-info by JFrogDev.
the class IssuesCollector method collectIssues.
/**
* Main function that manages the issue collection process.
*/
public Issues collectIssues(File execDir, Log logger, String config, ArtifactoryManagerBuilder artifactoryManagerBuilder, String buildName, Vcs vcs, String project) throws InterruptedException, IOException {
IssuesCollectionConfig parsedConfig = parseConfig(config);
String previousVcsRevision = getPreviousVcsRevision(artifactoryManagerBuilder, buildName, vcs, project);
Set<Issue> affectedIssues = doCollect(execDir, logger, parsedConfig, previousVcsRevision);
return buildIssuesObject(parsedConfig, affectedIssues);
}
use of org.jfrog.build.extractor.ci.IssuesCollectionConfig in project build-info by JFrogDev.
the class IssuesCollector method parseConfig.
IssuesCollectionConfig parseConfig(String config) throws IOException {
// When mapping the config from String to IssuesCollectionConfig one backslash is being removed, multiplying the backslashes solves this.
config = config.replace("\\", "\\\\");
ObjectMapper mapper = new ObjectMapper(new JsonFactory());
IssuesCollectionConfig parsedConfig;
try {
parsedConfig = mapper.readValue(config, IssuesCollectionConfig.class);
} catch (Exception e) {
throw new IOException(ISSUES_COLLECTION_ERROR_PREFIX + "Failed parsing config: " + e.getMessage());
}
parsedConfig.validateConfig();
return parsedConfig;
}
use of org.jfrog.build.extractor.ci.IssuesCollectionConfig in project build-info by JFrogDev.
the class IssuesCollectorTest method testIssuesParseConfig.
@Test
public void testIssuesParseConfig() throws IOException {
// Test success scenario
IssuesCollectionConfig parsedConfig = parseConfigFromPath(collector, "issues_config_success.json");
verifySuccessfulConfig(parsedConfig);
// Test fail scenarios
String[] failConfigPaths = new String[] { "issues_config_fail_no_issues.json", "issues_config_fail_invalid_group_index.json", "issues_config_fail_invalid_aggregate.json" };
for (String path : failConfigPaths) {
try {
IssuesCollectionConfig failConfig = parseConfigFromPath(collector, path);
// If didn't fail:
Assert.fail("Parsing config should have failed for path: " + path);
} catch (IOException e) {
// Expected IOException
getLog().info("-----\n Got an expected IOException from path: " + path);
getLog().info("Exception message:");
getLog().info(e.getMessage());
}
}
}
Aggregations