From a3ada505b25e75f4b510ff73ed06d92373aa8422 Mon Sep 17 00:00:00 2001 From: Konrad Pabjan Date: Fri, 15 May 2020 23:54:56 +0200 Subject: [PATCH] setFailed if certain items don't upload --- dist/index.js | 9 +++++++-- src/upload-artifact.ts | 12 ++++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/dist/index.js b/dist/index.js index ad3d7b0..e234ece 100644 --- a/dist/index.js +++ b/dist/index.js @@ -4005,8 +4005,13 @@ function run() { const options = { continueOnError: false }; - yield artifactClient.uploadArtifact(name || constants_1.getDefaultArtifactName(), searchResult.filesToUpload, searchResult.rootDirectory, options); - core.info('Artifact upload has finished successfully!'); + const uploadResponse = yield artifactClient.uploadArtifact(name || constants_1.getDefaultArtifactName(), searchResult.filesToUpload, searchResult.rootDirectory, options); + if (uploadResponse.failedItems.length > 0) { + core.setFailed(`An error was encountered when uploading ${uploadResponse.artifactName}. There were ${uploadResponse.failedItems.length} items that failed to upload.`); + } + else { + core.info(`Artifact ${uploadResponse.artifactName} has been successfully uploaded!`); + } } } catch (err) { diff --git a/src/upload-artifact.ts b/src/upload-artifact.ts index 4ae76aa..af42a9f 100644 --- a/src/upload-artifact.ts +++ b/src/upload-artifact.ts @@ -23,14 +23,22 @@ async function run(): Promise { const options: UploadOptions = { continueOnError: false } - await artifactClient.uploadArtifact( + const uploadResponse = await artifactClient.uploadArtifact( name || getDefaultArtifactName(), searchResult.filesToUpload, searchResult.rootDirectory, options ) - core.info('Artifact upload has finished successfully!') + if (uploadResponse.failedItems.length > 0) { + core.setFailed( + `An error was encountered when uploading ${uploadResponse.artifactName}. There were ${uploadResponse.failedItems.length} items that failed to upload.` + ) + } else { + core.info( + `Artifact ${uploadResponse.artifactName} has been successfully uploaded!` + ) + } } } catch (err) { core.setFailed(err.message)