use of org.eclipse.jkube.kit.config.service.JKubeServiceException in project jkube by eclipse.
the class KubernetesBuildTask method run.
@Override
public void run() {
if (kubernetesExtension.getRuntimeMode() == RuntimeMode.OPENSHIFT) {
kitLogger.info("Using [[B]]OpenShift[[B]] build with strategy [[B]]%s[[B]]", kubernetesExtension.getBuildStrategyOrDefault().getLabel());
} else {
kitLogger.info("Building container image in [[B]]Kubernetes[[B]] mode");
}
try {
storeTimestamp(getBuildTimestampFile(kubernetesExtension.javaProject.getBuildDirectory().getAbsolutePath(), DOCKER_BUILD_TIMESTAMP), getBuildTimestamp(null, null, kubernetesExtension.javaProject.getBuildDirectory().getAbsolutePath(), DOCKER_BUILD_TIMESTAMP));
jKubeServiceHub.getBuildService().build(resolvedImages.toArray(new ImageConfiguration[0]));
} catch (JKubeServiceException | IOException e) {
kitLogger.error(e.getMessage());
throw new GradleException(e.getMessage(), e);
}
}
use of org.eclipse.jkube.kit.config.service.JKubeServiceException in project jkube by eclipse.
the class JibBuildServiceBuildIntegrationTest method build_dockerFileMode_shouldThrowException.
@Test
public void build_dockerFileMode_shouldThrowException() {
// Given
final ImageConfiguration ic = imageConfiguration.toBuilder().build(imageConfiguration.getBuild().toBuilder().dockerFile("Dockerfile").build()).build();
// When
final JKubeServiceException result = assertThrows(JKubeServiceException.class, () -> jibBuildService.build(ic));
// Then
assertThat(result).hasMessage("Error when building JIB image").getCause().hasMessage("Dockerfile mode is not supported with JIB build strategy");
}
use of org.eclipse.jkube.kit.config.service.JKubeServiceException in project jkube by eclipse.
the class JibBuildService method pushSingleImage.
@Override
protected void pushSingleImage(ImageConfiguration imageConfiguration, int retries, RegistryConfig registryConfig, boolean skipTag) throws JKubeServiceException {
try {
prependRegistry(imageConfiguration, registryConfig.getRegistry());
log.info("This push refers to: %s", imageConfiguration.getName());
JibServiceUtil.jibPush(imageConfiguration, getRegistryCredentials(registryConfig, true, imageConfiguration, log), getBuildTarArchive(imageConfiguration, configuration), log);
} catch (Exception ex) {
throw new JKubeServiceException("Error when push JIB image", ex);
}
}
use of org.eclipse.jkube.kit.config.service.JKubeServiceException in project jkube by eclipse.
the class OpenShiftBuildServiceUtils method createS2IArchiveCustomizer.
private static ArchiverCustomizer createS2IArchiveCustomizer(BuildServiceConfig buildServiceConfig, ImageConfiguration imageConfiguration) throws JKubeServiceException {
try {
if (imageConfiguration.getBuildConfiguration() != null && imageConfiguration.getBuildConfiguration().getEnv() != null) {
String fileName = IoUtil.sanitizeFileName("s2i-env-" + imageConfiguration.getName());
final File environmentFile = new File(buildServiceConfig.getBuildDirectory(), fileName);
try (PrintWriter out = new PrintWriter(new FileWriter(environmentFile))) {
for (Map.Entry<String, String> e : imageConfiguration.getBuildConfiguration().getEnv().entrySet()) {
out.println(e.getKey() + "=" + e.getValue());
}
}
return tarArchiver -> {
tarArchiver.includeFile(environmentFile, ".s2i/environment");
return tarArchiver;
};
} else {
return null;
}
} catch (IOException e) {
throw new JKubeServiceException("Unable to add environment variables to the S2I build archive", e);
}
}
use of org.eclipse.jkube.kit.config.service.JKubeServiceException in project jkube by eclipse.
the class OpenshiftBuildService method logBuildFailure.
private void logBuildFailure(OpenShiftClient client, String buildName) throws JKubeServiceException {
try {
List<Build> builds = client.builds().inNamespace(applicableOpenShiftNamespace).list().getItems();
for (Build build : builds) {
if (build.getMetadata().getName().contains(buildName)) {
log.error(build.getMetadata().getName() + "\t" + "\t" + build.getStatus().getReason() + "\t" + build.getStatus().getMessage());
throw new JKubeServiceException("Unable to build the image using the OpenShift build service", new KubernetesClientException(build.getStatus().getReason() + " " + build.getStatus().getMessage()));
}
}
log.error("Also, check cluster events via `oc get events` to see what could have possibly gone wrong");
} catch (KubernetesClientException clientException) {
Status status = clientException.getStatus();
if (status != null)
log.error("OpenShift Error: [%d] %s", status.getCode(), status.getMessage());
}
}
Aggregations