我正尝试通过Jenkins从我的Kubernetes Pod将文件上传到AWS S3 Bucket,并获得public Path writeToFile() {
final Path tempFilePath;
try {
tempFilePath = Files.createTempFile(Paths.get(""), "sorting_test_", ".txt");
} catch (IOException e ) {
throw new MyRuntimeException(
"Cannot create sorting_test temp file",
e
);
}
try (final FileWriter fw = new FileWriter(tempFilePath.toFile())) {
try(final BufferedWriter bw = new BufferedWriter(fw)) {
for (List<Integer> arr : arrays) {
// Convert array ints to strings, join it to single string and write
bw.write(arr.stream()
.map(String::valueOf)
.collect(Collectors.joining(" ")));
bw.newLine();
}
}
return tempFilePath;
} catch (IOException e) {
throw new MyRuntimeException(
"Cannot write to " + tempFilePath,
e
);
}
}
。成功的命令将终止。
我尝试在Pod上手动运行命令,它的工作原理非常好。
这是我在jenkins声明式管道上的代码:
command terminated with exit code 1
这是日志:
sh (script: "kubectl exec -i ${MONGODB_POD_NAME} -n ${ENVIRONMENT} -- bash -c 'aws s3 sync /dump/${AUTOMATION_DUMP_DIRECTORY} s3://${S3_BUCKET}/${ENVIRONMENT}/${AUTOMATION_DUMP_DIRECTORY} --debug'")