use of com.thoughtworks.go.config.ArtifactStores in project gocd by gocd.
the class BuildWorkEnvironmentVariablesTest method createAssignment.
private BuildAssignment createAssignment(EnvironmentVariableContext environmentVariableContext) throws IOException {
JobPlan plan = new DefaultJobPlan(new Resources(), new ArrayList<>(), -1, new JobIdentifier(PIPELINE_NAME, 1, "1", STAGE_NAME, "1", JOB_NAME, 123L), null, new EnvironmentVariables(), new EnvironmentVariables(), null, null);
MaterialRevisions materialRevisions = materialRevisions();
BuildCause buildCause = BuildCause.createWithModifications(materialRevisions, TRIGGERED_BY_USER);
List<Builder> builders = new ArrayList<>();
builders.add(new CommandBuilder("ant", "", dir, new RunIfConfigs(), new NullBuilder(), ""));
return BuildAssignment.create(plan, buildCause, builders, dir, environmentVariableContext, new ArtifactStores());
}
use of com.thoughtworks.go.config.ArtifactStores in project gocd by gocd.
the class ArtifactsPublisherTest method shouldRegisterAndDeRegisterArtifactRequestProcessBeforeAndAfterPublishingPluggableArtifact.
@Test
public void shouldRegisterAndDeRegisterArtifactRequestProcessBeforeAndAfterPublishingPluggableArtifact() {
final ArtifactStore s3ArtifactStore = new ArtifactStore("s3", "cd.go.s3", create("access_key", false, "some-key"));
final ArtifactStores artifactStores = new ArtifactStores(s3ArtifactStore);
final ArtifactPlan s3ArtifactPlan = new ArtifactPlan(new PluggableArtifactConfig("installers", "s3", create("Baz", true, "Car")));
when(artifactExtension.publishArtifact(eq("cd.go.s3"), eq(s3ArtifactPlan), eq(s3ArtifactStore), anyString(), eq(env))).thenReturn(new PublishArtifactResponse(Collections.singletonMap("src", "s3://dist")));
new ArtifactsPublisher(publisher, artifactExtension, artifactStores, registry, workingFolder).publishArtifacts(Arrays.asList(s3ArtifactPlan), env);
InOrder inOrder = inOrder(registry, artifactExtension);
inOrder.verify(registry, times(1)).registerProcessorFor(eq(CONSOLE_LOG.requestName()), any(ArtifactRequestProcessor.class));
inOrder.verify(artifactExtension, times(1)).publishArtifact("cd.go.s3", s3ArtifactPlan, s3ArtifactStore, workingFolder.getAbsolutePath(), env);
inOrder.verify(registry, times(1)).removeProcessorFor(CONSOLE_LOG.requestName());
}
use of com.thoughtworks.go.config.ArtifactStores in project gocd by gocd.
the class ArtifactsPublisherTest method shouldNotUploadMetadataFileWhenPublishPluggableArtifactIsUnsuccessful.
@Test
public void shouldNotUploadMetadataFileWhenPublishPluggableArtifactIsUnsuccessful() {
final ArtifactStore artifactStore = new ArtifactStore("s3", "cd.go.s3", create("Foo", false, "Bar"));
final ArtifactStores artifactStores = new ArtifactStores(artifactStore);
final ArtifactPlan artifactPlan = new ArtifactPlan(new PluggableArtifactConfig("installers", "s3", create("Baz", true, "Car")));
when(artifactExtension.publishArtifact(eq("cd.go.s3"), eq(artifactPlan), eq(artifactStore), anyString(), eq(env))).thenThrow(new RuntimeException("something"));
try {
new ArtifactsPublisher(publisher, artifactExtension, artifactStores, registry, workingFolder).publishArtifacts(Arrays.asList(artifactPlan), env);
fail("Should throw error for pluggable artifact [installers].");
} catch (Exception e) {
assertThat(publisher.publishedFiles().size(), is(0));
assertThat(e.getMessage(), containsString("[go] Uploading finished. Failed to upload [installers]."));
}
}
use of com.thoughtworks.go.config.ArtifactStores in project gocd by gocd.
the class ArtifactsPublisherTest method setUp.
@BeforeEach
public void setUp() throws IOException {
artifactExtension = mock(ArtifactExtension.class);
registry = mock(PluginRequestProcessorRegistry.class);
publisher = new StubGoPublisher();
artifactsPublisher = new ArtifactsPublisher(publisher, artifactExtension, new ArtifactStores(), registry, workingFolder);
File file = new File(workingFolder, "cruise-output/log.xml");
file.getParentFile().mkdirs();
file.createNewFile();
}
use of com.thoughtworks.go.config.ArtifactStores in project gocd by gocd.
the class ArtifactsPublisherTest method shouldErrorOutWhenFailedToCreateFolderToWritePluggableArtifactMetadata.
@Test
public void shouldErrorOutWhenFailedToCreateFolderToWritePluggableArtifactMetadata() {
Assumptions.assumeFalse(IS_WINDOWS, "Do not run on windows.");
final ArtifactStore artifactStore = new ArtifactStore("s3", "cd.go.s3", create("Foo", false, "Bar"));
final ArtifactStores artifactStores = new ArtifactStores(artifactStore);
final ArtifactPlan artifactPlan = new ArtifactPlan(new PluggableArtifactConfig("installers", "s3", create("Baz", true, "Car")));
when(artifactExtension.publishArtifact(eq("cd.go.s3"), eq(artifactPlan), eq(artifactStore), anyString(), eq(env))).thenReturn(new PublishArtifactResponse(Collections.singletonMap("Foo", "Bar")));
workingFolder.setWritable(false);
assertThatThrownBy(() -> new ArtifactsPublisher(publisher, artifactExtension, artifactStores, registry, workingFolder).publishArtifacts(Arrays.asList(artifactPlan), env)).isInstanceOf(RuntimeException.class).hasMessageContaining("[go] Could not create pluggable artifact metadata folder");
}
Aggregations