From 70b512f8ba92b3ecd8a1952cda8e905bdb7f1688 Mon Sep 17 00:00:00 2001 From: Hugh Nowlan Date: Wed, 26 Sep 2018 12:18:43 +0100 Subject: [PATCH] Change scope of variables --- .../ghprb/extensions/comments/GhprbCommentFile.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/jenkinsci/plugins/ghprb/extensions/comments/GhprbCommentFile.java b/src/main/java/org/jenkinsci/plugins/ghprb/extensions/comments/GhprbCommentFile.java index 85d804fa6..ce00ae074 100644 --- a/src/main/java/org/jenkinsci/plugins/ghprb/extensions/comments/GhprbCommentFile.java +++ b/src/main/java/org/jenkinsci/plugins/ghprb/extensions/comments/GhprbCommentFile.java @@ -51,9 +51,6 @@ public String postBuildComment(Run build, TaskListener listener) { try { String content = null; - FilePath workspace; - FilePath path; - // On custom pipelines, build will be an instance of WorkflowRun if (build instanceof WorkflowRun) { FlowExecution exec = ((WorkflowRun) build).getExecution(); @@ -76,7 +73,7 @@ public String postBuildComment(Run build, TaskListener listener) { continue; } - path = action.getWorkspace().child(scriptFilePathResolved); + FilePath path = action.getWorkspace().child(scriptFilePathResolved); if (path.exists()) { content = path.readToString(); @@ -93,8 +90,8 @@ public String postBuildComment(Run build, TaskListener listener) { } } else if (build instanceof Build) { // When using workers on hosts other than master, we simply get the workspace here. - workspace = ((Build) build).getWorkspace(); - path = workspace.child(scriptFilePathResolved); + FilePath workspace = ((Build) build).getWorkspace(); + FilePath path = workspace.child(scriptFilePathResolved); if (path.exists()) { content = path.readToString();