Skip to content

Commit

Permalink
🛠refactor(artifact-uploader) add more error information
Browse files Browse the repository at this point in the history
  • Loading branch information
GoCD Automation committed Mar 24, 2024
1 parent 8e52431 commit 85aba7e
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions agent/src/util/artifact-uploader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,11 @@ const uploadBinary = async (path: string, logger: Awaited<ReturnType<typeof getS

let headers = formData.getHeaders();

const result = await api.post(`/api/artifact/` + path.split('/').pop(), formData, { headers })
const result = await api.post(
`/api/artifact/` + path.split('/').pop(),
formData,
{ headers }
)
.catch(err => err);

if (result.stack)
Expand All @@ -100,7 +104,10 @@ const uploadBinary = async (path: string, logger: Awaited<ReturnType<typeof getS
catch(err) {
logger.warn({
msg: "Failed to upload artifact",
path
path,
name: err.name,
message: err.message,
stack: err.stack
})
return -1;
}
Expand Down Expand Up @@ -128,11 +135,20 @@ export const UploadArtifacts = async (
artifact
})
const result = await compressArtifact(dir, dest, logger);
logger.info({
msg: "Sealed artifact " + artifact.label,
artifact,
result
})
if (result.exitCode == 0) {
logger.info({
msg: "Sealed artifact " + artifact.label,
artifact,
result
})
}
else {
logger.warn({
msg: "Failed to seal artifact " + artifact.label,
artifact,
result
})
}

// If it was successful in saving to disk, upload it
if (result['path']) {
Expand Down

0 comments on commit 85aba7e

Please sign in to comment.