Search in sources :

Example 6 with JunitSubmitterRequest

use of com.qasymphony.ci.plugin.submitter.JunitSubmitterRequest in project jenkin-qtest-plugin by QASymphony.

the class PushingResultAction method perform.

@SuppressWarnings("rawtypes")
@Override
public boolean perform(AbstractBuild build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
    PrintStream logger = listener.getLogger();
    JunitSubmitterRequest submitterRequest = configuration.createJunitSubmitRequest();
    if (null == submitterRequest) {
        LoggerUtils.formatError(logger, "Could not create JUnitSumitterRequest");
        return true;
    }
    submitterRequest.setBuildNumber(build.getNumber() + "").setBuildPath(build.getUrl()).setListener(listener);
    JunitSubmitter junitSubmitter = new JunitQtestSubmitterImpl();
    String buildResult = build.getResult() + "";
    if (Result.ABORTED.equals(build.getResult())) {
        LoggerUtils.formatWarn(logger, "Abort build action.");
        storeWhenNotSuccess(submitterRequest, junitSubmitter, build, buildResult, logger, JunitSubmitterResult.STATUS_CANCELED);
        return true;
    }
    showInfo(logger);
    if (!validateConfig(configuration)) {
        LoggerUtils.formatWarn(logger, "Invalid configuration to qTest, reject submit test results.");
        storeWhenNotSuccess(submitterRequest, junitSubmitter, build, buildResult, logger, JunitSubmitterResult.STATUS_FAILED);
        return true;
    }
    if (null == checkProjectNameChanged(build, listener)) {
        storeWhenNotSuccess(submitterRequest, junitSubmitter, build, buildResult, logger, JunitSubmitterResult.STATUS_CANCELED);
        return true;
    }
    List<AutomationTestResult> automationTestResults = readTestResults(build, launcher, listener, logger);
    if (automationTestResults.isEmpty()) {
        LoggerUtils.formatWarn(logger, "No JUnit test result found.");
        storeWhenNotSuccess(submitterRequest, junitSubmitter, build, buildResult, logger, JunitSubmitterResult.STATUS_SKIPPED);
        LoggerUtils.formatHR(logger);
        return true;
    }
    submitterRequest.setTestResults(automationTestResults);
    JunitSubmitterResult result = submitTestResult(submitterRequest, build, listener, junitSubmitter, automationTestResults);
    if (null == result) {
        // if have no test result, we do not break build flow
        return true;
    }
    saveConfiguration(build, result, logger);
    storeResult(submitterRequest, build, buildResult, junitSubmitter, result, logger);
    LoggerUtils.formatHR(logger);
    return true;
}
Also used : PrintStream(java.io.PrintStream) AutomationTestResult(com.qasymphony.ci.plugin.model.AutomationTestResult) JunitSubmitterResult(com.qasymphony.ci.plugin.submitter.JunitSubmitterResult) JunitSubmitter(com.qasymphony.ci.plugin.submitter.JunitSubmitter) JunitQtestSubmitterImpl(com.qasymphony.ci.plugin.submitter.JunitQtestSubmitterImpl) JunitSubmitterRequest(com.qasymphony.ci.plugin.submitter.JunitSubmitterRequest)

Example 7 with JunitSubmitterRequest

use of com.qasymphony.ci.plugin.submitter.JunitSubmitterRequest in project jenkin-qtest-plugin by QASymphony.

the class Configuration method createJunitSubmitRequest.

public JunitSubmitterRequest createJunitSubmitRequest() {
    Long containerID = this.releaseId;
    String containerType = "release";
    Container container = null;
    if (submitToContainer) {
        container = this.getContainerInfo();
        if (null == container) {
            return null;
        }
        containerID = container.getId();
        containerType = container.getType();
    }
    JunitSubmitterRequest request = new JunitSubmitterRequest();
    request.setqTestURL(this.url).setApiKey(this.appSecretKey).setConfigurationID(this.id).setSubmitToExistingContainer(this.submitToContainer).setContainerID(containerID).setContainerType(containerType).setCreateNewTestRunsEveryBuildDate(null != container ? container.getCreateNewTestSuiteEveryBuild() : null).setEnvironmentID(this.environmentId).setEnvironmentParentID(this.environmentParentId).setJenkinsProjectName(this.jenkinsProjectName).setModuleID(this.moduleId).setJenkinsServerURL(this.jenkinsServerUrl).setProjectID(this.projectId);
    return request;
}
Also used : Container(com.qasymphony.ci.plugin.model.qtest.Container) JunitSubmitterRequest(com.qasymphony.ci.plugin.submitter.JunitSubmitterRequest)

Aggregations

JunitSubmitterRequest (com.qasymphony.ci.plugin.submitter.JunitSubmitterRequest)7 Test (org.junit.Test)4 FreeStyleBuild (hudson.model.FreeStyleBuild)2 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 LocalData (org.jvnet.hudson.test.recipes.LocalData)2 SubmittedException (com.qasymphony.ci.plugin.exception.SubmittedException)1 AutomationTestResult (com.qasymphony.ci.plugin.model.AutomationTestResult)1 Configuration (com.qasymphony.ci.plugin.model.Configuration)1 Container (com.qasymphony.ci.plugin.model.qtest.Container)1 JunitQtestSubmitterImpl (com.qasymphony.ci.plugin.submitter.JunitQtestSubmitterImpl)1 JunitSubmitter (com.qasymphony.ci.plugin.submitter.JunitSubmitter)1 JunitSubmitterResult (com.qasymphony.ci.plugin.submitter.JunitSubmitterResult)1 PrintStream (java.io.PrintStream)1