From 8218b2f6b7c621b6ac79ccfa73703db194d773bd Mon Sep 17 00:00:00 2001 From: Lars Grefer Date: Sat, 9 Jul 2022 03:16:52 +0200 Subject: [PATCH] Dont fail on missing permissions --- .../plugins/github/dependencies/UploadSnapshotTask.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/github-plugin/src/main/java/io/freefair/gradle/plugins/github/dependencies/UploadSnapshotTask.java b/github-plugin/src/main/java/io/freefair/gradle/plugins/github/dependencies/UploadSnapshotTask.java index adb71108..bbd10561 100644 --- a/github-plugin/src/main/java/io/freefair/gradle/plugins/github/dependencies/UploadSnapshotTask.java +++ b/github-plugin/src/main/java/io/freefair/gradle/plugins/github/dependencies/UploadSnapshotTask.java @@ -12,7 +12,6 @@ import org.gradle.api.tasks.Input; import org.gradle.api.tasks.InputFile; import org.gradle.api.tasks.TaskAction; -import org.gradle.api.tasks.TaskExecutionException; import retrofit2.Call; import retrofit2.Response; @@ -43,7 +42,8 @@ public void upload() { GithubService githubService = githubClient.getGithubService(); try (FileReader fileReader = new FileReader(getSnapshotFile().getAsFile().get())) { - Snapshot snapshot = new Gson().fromJson(fileReader, Snapshot.class); + Gson gson = new Gson(); + Snapshot snapshot = gson.fromJson(fileReader, Snapshot.class); getLogger().lifecycle("Job: {}", snapshot.getJob()); getLogger().lifecycle("Ref: {}, Sha: {}", snapshot.getRef(), snapshot.getSha()); getLogger().info("Detector: {}", snapshot.getDetector()); @@ -54,6 +54,10 @@ public void upload() { if (execute.isSuccessful()) { getLogger().lifecycle(execute.body().getMessage()); } + else if (execute.code() == 403) { + getLogger().warn("Upload Failed due to missing permissions"); + getLogger().info(execute.errorBody().string()); + } else { getLogger().error("{} {}", execute.code(), execute.message()); getLogger().error(execute.errorBody().string());