Search in sources :

Example 11 with StageConfig

use of com.thoughtworks.go.config.StageConfig in project gocd by gocd.

the class StageMother method failingStage.

public static Stage failingStage(String stageName) {
    StageConfig stageConfig = StageConfigMother.twoBuildPlansWithResourcesAndMaterials(stageName);
    Stage stage = scheduleInstance(stageConfig);
    stage.setId(fakeId());
    stage.getJobInstances().get(0).fail();
    stage.getJobInstances().get(1).completing(JobResult.Passed);
    return stage;
}
Also used : StageConfig(com.thoughtworks.go.config.StageConfig)

Example 12 with StageConfig

use of com.thoughtworks.go.config.StageConfig in project gocd by gocd.

the class PipelineMother method withTwoStagesOneBuildEach.

public static PipelineConfig withTwoStagesOneBuildEach(String pipelineName, String stageName, String stageName2) {
    StageConfig stageConfig1 = com.thoughtworks.go.helper.StageConfigMother.oneBuildPlanWithResourcesAndMaterials(stageName);
    StageConfig stageConfig2 = com.thoughtworks.go.helper.StageConfigMother.oneBuildPlanWithResourcesAndMaterials(stageName2);
    MaterialConfigs materialConfigs = MaterialConfigsMother.defaultMaterialConfigs();
    return new PipelineConfig(new CaseInsensitiveString(pipelineName), materialConfigs, stageConfig1, stageConfig2);
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) PipelineConfig(com.thoughtworks.go.config.PipelineConfig) StageConfig(com.thoughtworks.go.config.StageConfig) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString)

Example 13 with StageConfig

use of com.thoughtworks.go.config.StageConfig in project gocd by gocd.

the class StageMother method scheduledStage.

public static Stage scheduledStage(String pipelineName, int pipelineCounter, String stageName, int stageCounter, String buildName) {
    StageConfig stageConfig = StageConfigMother.oneBuildPlanWithResourcesAndMaterials(stageName, buildName);
    Stage stage = scheduleInstance(stageConfig);
    stage.setCounter(stageCounter);
    stage.setIdentifier(new StageIdentifier(pipelineName, pipelineCounter, "LABEL-" + pipelineCounter, stageName, "" + stageCounter));
    stage.setId(fakeId());
    for (JobInstance jobInstance : stage.getJobInstances()) {
        jobInstance.setIdentifier(new JobIdentifier(pipelineName, pipelineCounter, "LABEL-" + pipelineCounter, stageName, "" + stageCounter, buildName, fakeId()));
    }
    return stage;
}
Also used : StageConfig(com.thoughtworks.go.config.StageConfig)

Example 14 with StageConfig

use of com.thoughtworks.go.config.StageConfig in project gocd by gocd.

the class StageMother method completedStageInstanceWithTwoPlans.

public static Stage completedStageInstanceWithTwoPlans(String stageName) {
    StageConfig scheduledStageConfig = StageConfigMother.twoBuildPlansWithResourcesAndMaterials(stageName);
    Stage completed = scheduleInstance(scheduledStageConfig);
    passBuildInstancesOfStage(completed, new Date());
    return completed;
}
Also used : StageConfig(com.thoughtworks.go.config.StageConfig) Date(java.util.Date)

Example 15 with StageConfig

use of com.thoughtworks.go.config.StageConfig in project gocd by gocd.

the class ConfigDbStateRepository method flushArtifactCleanupProhibitions.

private Object flushArtifactCleanupProhibitions() {
    List<StageArtifactCleanupProhibited> existingEntries = getHibernateTemplate().find("from StageArtifactCleanupProhibited");
    HashMap<Map.Entry<String, String>, StageArtifactCleanupProhibited> persistentStateMap = new HashMap<>();
    for (StageArtifactCleanupProhibited persistentState : existingEntries) {
        persistentState.setProhibited(false);
        persistentStateMap.put(new AbstractMap.SimpleEntry<>(persistentState.getPipelineName(), persistentState.getStageName()), persistentState);
    }
    List<PipelineConfig> pipelineConfigs = goConfigService.currentCruiseConfig().allPipelines();
    for (PipelineConfig pipelineConfig : pipelineConfigs) {
        for (StageConfig stageConfig : pipelineConfig) {
            StageArtifactCleanupProhibited stageArtifactCleanupProhibited = persistentStateMap.get(new AbstractMap.SimpleEntry<>(CaseInsensitiveString.str(pipelineConfig.name()), CaseInsensitiveString.str(stageConfig.name())));
            if (stageArtifactCleanupProhibited == null) {
                stageArtifactCleanupProhibited = new StageArtifactCleanupProhibited(CaseInsensitiveString.str(pipelineConfig.name()), CaseInsensitiveString.str(stageConfig.name()));
            }
            stageArtifactCleanupProhibited.setProhibited(stageConfig.isArtifactCleanupProhibited());
            getHibernateTemplate().saveOrUpdate(stageArtifactCleanupProhibited);
        }
    }
    return null;
}
Also used : AbstractMap(java.util.AbstractMap) PipelineConfig(com.thoughtworks.go.config.PipelineConfig) HashMap(java.util.HashMap) StageArtifactCleanupProhibited(com.thoughtworks.go.domain.StageArtifactCleanupProhibited) StageConfig(com.thoughtworks.go.config.StageConfig)

Aggregations

StageConfig (com.thoughtworks.go.config.StageConfig)30 Test (org.junit.Test)12 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)11 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)8 TimeProvider (com.thoughtworks.go.util.TimeProvider)4 Agents (com.thoughtworks.go.config.Agents)3 EnvironmentVariableConfig (com.thoughtworks.go.config.EnvironmentVariableConfig)3 EnvironmentVariablesConfig (com.thoughtworks.go.config.EnvironmentVariablesConfig)3 AgentConfig (com.thoughtworks.go.config.AgentConfig)2 JobConfigs (com.thoughtworks.go.config.JobConfigs)2 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)2 DefaultSchedulingContext (com.thoughtworks.go.domain.DefaultSchedulingContext)2 NullStage (com.thoughtworks.go.domain.NullStage)2 Stage (com.thoughtworks.go.domain.Stage)2 InstanceFactory (com.thoughtworks.go.server.service.InstanceFactory)2 Map (java.util.Map)2 AdminUser (com.thoughtworks.go.config.AdminUser)1 Approval (com.thoughtworks.go.config.Approval)1 AuthConfig (com.thoughtworks.go.config.AuthConfig)1 EnvironmentConfig (com.thoughtworks.go.config.EnvironmentConfig)1