Search in sources :

Example 1 with IssuesCollectionConfig

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);
}
Also used : Issue(org.jfrog.build.extractor.ci.Issue) IssuesCollectionConfig(org.jfrog.build.extractor.ci.IssuesCollectionConfig)

Example 2 with IssuesCollectionConfig

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;
}
Also used : JsonFactory(com.fasterxml.jackson.core.JsonFactory) IssuesCollectionConfig(org.jfrog.build.extractor.ci.IssuesCollectionConfig) IOException(java.io.IOException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) IOException(java.io.IOException)

Example 3 with IssuesCollectionConfig

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());
        }
    }
}
Also used : IssuesCollectionConfig(org.jfrog.build.extractor.ci.IssuesCollectionConfig) IOException(java.io.IOException) Test(org.testng.annotations.Test)

Aggregations

IssuesCollectionConfig (org.jfrog.build.extractor.ci.IssuesCollectionConfig)3 IOException (java.io.IOException)2 JsonFactory (com.fasterxml.jackson.core.JsonFactory)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Issue (org.jfrog.build.extractor.ci.Issue)1 Test (org.testng.annotations.Test)1