Search in sources :

Example 1 with SystemParams

use of com.epam.pipeline.manager.execution.SystemParams in project cloud-pipeline by epam.

the class DtsRunner method runEntry.

private PipelineRun runEntry(DtsRunConfigurationEntry entry, Long configurationId, List<Long> entitiesIds, PipelineConfiguration configuration) {
    Pipeline pipeline = entry.getPipelineId() == null ? null : pipelineManager.load(entry.getPipelineId());
    PipelineRun run = pipelineRunManager.createPipelineRun(entry.getPipelineVersion(), configuration, pipeline, null, entitiesIds, configurationId);
    run.setConfigName(entry.getConfigName());
    run.setDockerImage(toolManager.getExternalToolName(run.getDockerImage()));
    run.setExecutionPreferences(DtsExecutionPreferences.builder().dtsId(entry.getDtsId()).coresNumber(entry.getCoresNumber()).build());
    Map<SystemParams, String> systemParams = pipelineLauncher.matchCommonParams(run, preferenceManager.getPreference(SystemPreferences.BASE_API_HOST_EXTERNAL), configuration.getGitCredentials());
    systemParams.put(SystemParams.DISTRIBUTION_URL, preferenceManager.getPreference(SystemPreferences.DTS_DISTRIBUTION_URL));
    GitCredentials gitCredentials = configuration.getGitCredentials();
    String gitCloneUrl = gitCredentials == null ? run.getRepository() : gitCredentials.getUrl();
    String pipelineCommand = commandBuilder.build(configuration, systemParams);
    run.setActualCmd(pipelineCommand);
    String launchCmd = preferenceManager.getPreference(SystemPreferences.DTS_LAUNCH_CMD_TEMPLATE);
    String launchScriptUrl = preferenceManager.getPreference(SystemPreferences.DTS_LAUNCH_URL);
    String fullCmd = String.format(launchCmd, launchScriptUrl, launchScriptUrl, gitCloneUrl, run.getRevisionName(), pipelineCommand);
    pipelineRunManager.save(run);
    DtsSubmission submission = buildSubmission(run, configuration, entry.getCoresNumber(), systemParams, fullCmd);
    log.debug("Creating DTS submission");
    try {
        DtsSubmission scheduled = submissionManager.createSubmission(entry.getDtsId(), submission);
        if (scheduled.getState().getStatus() != TaskStatus.RUNNING) {
            return failRun(run, String.format("Submission failed to start: %s", scheduled.getState().getReason()));
        }
        log.debug("Successfully scheduled submission on DTS");
        return run;
    } catch (DtsRequestException e) {
        return failRun(run, e.getMessage());
    }
}
Also used : PipelineRun(com.epam.pipeline.entity.pipeline.PipelineRun) GitCredentials(com.epam.pipeline.entity.git.GitCredentials) SystemParams(com.epam.pipeline.manager.execution.SystemParams) DtsRequestException(com.epam.pipeline.exception.DtsRequestException) DtsSubmission(com.epam.pipeline.entity.dts.DtsSubmission) Pipeline(com.epam.pipeline.entity.pipeline.Pipeline)

Example 2 with SystemParams

use of com.epam.pipeline.manager.execution.SystemParams in project cloud-pipeline by epam.

the class PipelineRunDaoTest method createTestPipelineRun.

private PipelineRun createTestPipelineRun(Long pipelineId) {
    PipelineRun run = new PipelineRun();
    run.setPipelineId(pipelineId);
    run.setVersion("abcdefg");
    run.setStartDate(new Date());
    run.setEndDate(run.getStartDate());
    run.setStatus(TaskStatus.RUNNING);
    run.setCommitStatus(CommitStatus.NOT_COMMITTED);
    run.setLastChangeCommitTime(new Date());
    run.setPodId(TEST_POD_ID);
    run.setParams(TEST_PARAMS);
    run.setOwner(USER);
    run.setServiceUrl(TEST_SERVICE_URL);
    Map<SystemParams, String> systemParams = EnvVarsBuilderTest.matchSystemParams();
    PipelineConfiguration configuration = EnvVarsBuilderTest.matchPipeConfig();
    EnvVarsBuilder.buildEnvVars(run, configuration, systemParams, null);
    run.setEnvVars(run.getEnvVars());
    pipelineRunDao.createPipelineRun(run);
    return run;
}
Also used : PipelineRun(com.epam.pipeline.entity.pipeline.PipelineRun) SystemParams(com.epam.pipeline.manager.execution.SystemParams) PipelineConfiguration(com.epam.pipeline.entity.configuration.PipelineConfiguration) Date(java.util.Date) LocalDate(java.time.LocalDate)

Aggregations

PipelineRun (com.epam.pipeline.entity.pipeline.PipelineRun)2 SystemParams (com.epam.pipeline.manager.execution.SystemParams)2 PipelineConfiguration (com.epam.pipeline.entity.configuration.PipelineConfiguration)1 DtsSubmission (com.epam.pipeline.entity.dts.DtsSubmission)1 GitCredentials (com.epam.pipeline.entity.git.GitCredentials)1 Pipeline (com.epam.pipeline.entity.pipeline.Pipeline)1 DtsRequestException (com.epam.pipeline.exception.DtsRequestException)1 LocalDate (java.time.LocalDate)1 Date (java.util.Date)1