From cc7b20e8aed4ae934aa89d574ea665c86705467c Mon Sep 17 00:00:00 2001 From: memir Date: Wed, 2 Mar 2022 13:40:59 +0300 Subject: [PATCH 01/21] delete component function added --- .../EnvDashboardView.java | 40 ++++++++++++++++++- .../EnvDashboardView/configure-entries.jelly | 4 ++ .../EnvDashboardView/index.jelly | 10 +++++ 3 files changed, 53 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/jenkinsci/plugins/environmentdashboard/EnvDashboardView.java b/src/main/java/org/jenkinsci/plugins/environmentdashboard/EnvDashboardView.java index 6a7978bc..233f5cf9 100644 --- a/src/main/java/org/jenkinsci/plugins/environmentdashboard/EnvDashboardView.java +++ b/src/main/java/org/jenkinsci/plugins/environmentdashboard/EnvDashboardView.java @@ -47,14 +47,17 @@ public class EnvDashboardView extends View { private String compOrder = null; private String deployHistory = null; + + private String componentNameWillBeDeleted = null; @DataBoundConstructor public EnvDashboardView(final String name, final String envOrder, final String compOrder, - final String deployHistory) { + final String deployHistory, final String componentNameWillBeDeleted) { super(name, Hudson.getInstance()); this.envOrder = envOrder; this.compOrder = compOrder; this.deployHistory = deployHistory; + this.componentNameWillBeDeleted = componentNameWillBeDeleted; } static { @@ -108,6 +111,31 @@ public void doPurgeSubmit(final StaplerRequest req, StaplerResponse res) res.forwardToPreviousPage(req); } + @RequirePOST + public void doDeleteComponent(final StaplerRequest req, StaplerResponse res) + throws IOException, ServletException, FormException { + checkPermission(Jenkins.ADMINISTER); + //System.out.println("[OKSY_log value of componentNameWillBeDeleted in doDeleteComponent method: ]" + componentNameWillBeDeleted); + Connection conn = null; + Statement stat = null; + conn = DBConnection.getConnection(); + String runQuery = null; + + try { + assert conn != null; + stat = conn.createStatement(); + runQuery = "DELETE FROM env_dashboard where compName = '" + componentNameWillBeDeleted + "';"; + stat.execute(runQuery); + System.out.println("[Delete query in doDeleteComponent method: ]" + runQuery); + System.out.println("Selected component has been removed successfully!.. " + componentNameWillBeDeleted); + } catch (SQLException e) { + System.out.println("E15: Could not delete component lines.\n" + e.getMessage()); + } finally { + DBConnection.closeConnection(); + } + res.forwardToPreviousPage(req); + } + @Override public Item doCreateItem(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException { return Hudson.getInstance().doCreateItem(req, rsp); @@ -119,6 +147,7 @@ public static final class DescriptorImpl extends ViewDescriptor { private String envOrder; private String compOrder; private String deployHistory; + private String componentNameWillBeDeleted; /** * descriptor impl constructor This empty constructor is required for @@ -233,6 +262,7 @@ public boolean configure(StaplerRequest req, JSONObject formData) throws FormExc envOrder = formData.getString("envOrder"); compOrder = formData.getString("compOrder"); deployHistory = formData.getString("deployHistory"); + componentNameWillBeDeleted = formData.getString("componentNameWillBeDeleted"); save(); return super.configure(req, formData); } @@ -519,6 +549,14 @@ public void setDeployHistory(final String deployHistory) { this.deployHistory = deployHistory; } + public String getcomponentNameWillBeDeleted() { + return componentNameWillBeDeleted; + } + + public void setcomponentNameWillBeDeleted(final String componentNameWillBeDeleted) { + this.componentNameWillBeDeleted = componentNameWillBeDeleted; + } + @Override public boolean contains(TopLevelItem topLevelItem) { return false; diff --git a/src/main/resources/org/jenkinsci/plugins/environmentdashboard/EnvDashboardView/configure-entries.jelly b/src/main/resources/org/jenkinsci/plugins/environmentdashboard/EnvDashboardView/configure-entries.jelly index d5afc556..c1040cc8 100644 --- a/src/main/resources/org/jenkinsci/plugins/environmentdashboard/EnvDashboardView/configure-entries.jelly +++ b/src/main/resources/org/jenkinsci/plugins/environmentdashboard/EnvDashboardView/configure-entries.jelly @@ -13,6 +13,10 @@ + + + + diff --git a/src/main/resources/org/jenkinsci/plugins/environmentdashboard/EnvDashboardView/index.jelly b/src/main/resources/org/jenkinsci/plugins/environmentdashboard/EnvDashboardView/index.jelly index ec0eb0b0..a3ad0672 100644 --- a/src/main/resources/org/jenkinsci/plugins/environmentdashboard/EnvDashboardView/index.jelly +++ b/src/main/resources/org/jenkinsci/plugins/environmentdashboard/EnvDashboardView/index.jelly @@ -17,6 +17,16 @@ + + + + + + + + + + From 40ee5ec4647cf4b4190297ee952b4d52763a05f6 Mon Sep 17 00:00:00 2001 From: memir Date: Fri, 4 Mar 2022 14:39:52 +0300 Subject: [PATCH 02/21] pom.xml modified --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 02c0cdde..ed2233e0 100644 --- a/pom.xml +++ b/pom.xml @@ -74,4 +74,4 @@ 1.12.4-1 - + \ No newline at end of file From 0f0d594faf0290674b81f1ddddc9255e16f06396 Mon Sep 17 00:00:00 2001 From: memir Date: Fri, 4 Mar 2022 14:48:28 +0300 Subject: [PATCH 03/21] added jenkinsci-releases repository to pom.xml --- pom.xml | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/pom.xml b/pom.xml index ed2233e0..a9e45f6c 100644 --- a/pom.xml +++ b/pom.xml @@ -22,26 +22,19 @@ - - - vipinsthename - Vipin - vipinsthename@gmail.com - - - willwh - William Hetherington - will@willwh.com - - - scm:git:git@github.com:${gitHubRepo}.git scm:git:git@github.com:${gitHubRepo}.git https://github.com/${gitHubRepo} ${scmTag} - + + + maven.jenkins-ci.org + jenkinsci-releases + https://repo.jenkins-ci.org/org/releases + + 1.1.11 -SNAPSHOT From 92bd3c3adc14badc4aacb9c2f9c0bf1c276090ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mustafa=20Ya=C5=9Far=20Emir?= Date: Fri, 4 Mar 2022 14:55:03 +0300 Subject: [PATCH 04/21] Update pom.xml --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index a9e45f6c..da794979 100644 --- a/pom.xml +++ b/pom.xml @@ -32,7 +32,7 @@ maven.jenkins-ci.org jenkinsci-releases - https://repo.jenkins-ci.org/org/releases + https://repo.jenkins-ci.org/releases @@ -67,4 +67,4 @@ 1.12.4-1 - \ No newline at end of file + From 217edf18e370e3f0754251adb64e681539d6d36a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mustafa=20Ya=C5=9Far=20Emir?= Date: Fri, 4 Mar 2022 15:07:48 +0300 Subject: [PATCH 05/21] added maven-hpi-plugin dependency --- pom.xml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pom.xml b/pom.xml index da794979..27545ad8 100644 --- a/pom.xml +++ b/pom.xml @@ -66,5 +66,12 @@ jquery 1.12.4-1 + + + org.jenkins-ci.tools + maven-hpi-plugin + 3.17 + + From eedae909ea887b48a58e693c223e99d27fefc60e Mon Sep 17 00:00:00 2001 From: memir Date: Fri, 4 Mar 2022 15:32:46 +0300 Subject: [PATCH 06/21] jenkins.version and maven-hpi-plugin.version updated --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 27545ad8..1c115b04 100644 --- a/pom.xml +++ b/pom.xml @@ -39,7 +39,7 @@ 1.1.11 -SNAPSHOT jenkinsci/environment-dashboard-plugin - 2.223 + 2.330 8 false @@ -70,7 +70,7 @@ org.jenkins-ci.tools maven-hpi-plugin - 3.17 + 3.23 From 6444dd45a0dd13c2b044eca44d39e9f23df1b05e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mustafa=20Ya=C5=9Far=20Emir?= Date: Sun, 6 Mar 2022 22:11:39 +0300 Subject: [PATCH 07/21] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5511f807..03ccf5e1 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ Jenkins Environment Dashboard Plugin ========================= + This Jenkins plugin creates a custom view which can be used as a dashboard to display what code release versions have been deployed to what test and production environments (or devices). ![JobConfig](https://github.com/vipinsthename/environment-dashboard/raw/master/img/config.png) @@ -105,4 +106,4 @@ environmentDashboard(addColumns: true, buildJob: '', buildNumber: 'Version-1', c // some block } -``` \ No newline at end of file +``` From 0fe098c0f5330c9f5bb3d97aa6917971ee168e72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mustafa=20Ya=C5=9Far=20Emir?= Date: Sun, 6 Mar 2022 22:33:27 +0300 Subject: [PATCH 08/21] Update pom.xml added symbol-annotation dependency --- pom.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pom.xml b/pom.xml index 1c115b04..2f73b66f 100644 --- a/pom.xml +++ b/pom.xml @@ -72,6 +72,12 @@ maven-hpi-plugin 3.23 + + + org.jenkins-ci + symbol-annotation + 1.19 + From 4dd667c5b8909b62780de4febcf7f93ca1017fc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mustafa=20Ya=C5=9Far=20Emir?= Date: Sun, 6 Mar 2022 22:59:50 +0300 Subject: [PATCH 09/21] added stapler-groovy --- pom.xml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 2f73b66f..c0aa16e4 100644 --- a/pom.xml +++ b/pom.xml @@ -78,6 +78,10 @@ symbol-annotation 1.19 - + + org.kohsuke.stapler + stapler-groovy + ${stapler.version} + From d8a51657ba7c99059e94f4ecab93e1d6837a8ef6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mustafa=20Ya=C5=9Far=20Emir?= Date: Sun, 6 Mar 2022 23:15:46 +0300 Subject: [PATCH 10/21] stapler-groovy versiyon updated --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c0aa16e4..9dda4691 100644 --- a/pom.xml +++ b/pom.xml @@ -81,7 +81,7 @@ org.kohsuke.stapler stapler-groovy - ${stapler.version} + 1642.ve454c4518974 From 134842e192ce2dbc03d8bc43429791971c7f115b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mustafa=20Ya=C5=9Far=20Emir?= Date: Sun, 6 Mar 2022 23:27:45 +0300 Subject: [PATCH 11/21] stapler 1.140 added --- pom.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pom.xml b/pom.xml index 9dda4691..94086a22 100644 --- a/pom.xml +++ b/pom.xml @@ -83,5 +83,10 @@ stapler-groovy 1642.ve454c4518974 + + org.kohsuke.stapler + stapler + 1.140 + From 08d39971f7f4951c5df5e7e64c89e7be43dd0f3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mustafa=20Ya=C5=9Far=20Emir?= Date: Sun, 6 Mar 2022 23:47:25 +0300 Subject: [PATCH 12/21] Update pom.xml --- pom.xml | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 94086a22..408b6946 100644 --- a/pom.xml +++ b/pom.xml @@ -88,5 +88,29 @@ stapler 1.140 - + + + org.apache.maven.plugins + maven-enforcer-plugin + 3.0.0-M2 + + + enforce-dependency-convergence + + enforce + + + + + + org.kohsuke.stapler:stapler + + + + + + + + + From a7bfc885382e406071b8def13b0b0578eae2be1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mustafa=20Ya=C5=9Far=20Emir?= Date: Sun, 6 Mar 2022 23:56:32 +0300 Subject: [PATCH 13/21] Update pom.xml --- pom.xml | 230 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 115 insertions(+), 115 deletions(-) diff --git a/pom.xml b/pom.xml index 408b6946..14799b76 100644 --- a/pom.xml +++ b/pom.xml @@ -1,116 +1,116 @@ - - 4.0.0 - - - org.jenkins-ci.plugins - plugin - 4.15 - - - - io.jenkins.plugins - environment-dashboard - ${revision}${changelist} - hpi - Environment Dashboard Plugin - https://github.com/jenkinsci/environment-dashboard-plugin - - - - MIT License - https://opensource.org/licenses/MIT - - - - - scm:git:git@github.com:${gitHubRepo}.git - scm:git:git@github.com:${gitHubRepo}.git - https://github.com/${gitHubRepo} - ${scmTag} - - - - maven.jenkins-ci.org - jenkinsci-releases - https://repo.jenkins-ci.org/releases - - - - 1.1.11 - -SNAPSHOT - jenkinsci/environment-dashboard-plugin - 2.330 - 8 - false - - - - - org.jenkins-ci.plugins - job-dsl - 1.76 - - - org.codehaus.groovy - groovy-all - - 2.4.12 - - - com.h2database - h2 - 1.4.196 - - - org.jenkins-ci.plugins - jquery - 1.12.4-1 - - - - org.jenkins-ci.tools - maven-hpi-plugin - 3.23 - - - - org.jenkins-ci - symbol-annotation - 1.19 - - - org.kohsuke.stapler - stapler-groovy - 1642.ve454c4518974 - - - org.kohsuke.stapler - stapler - 1.140 - - - - org.apache.maven.plugins - maven-enforcer-plugin - 3.0.0-M2 - - - enforce-dependency-convergence - - enforce - - - - - - org.kohsuke.stapler:stapler - - - - - - - - - + + 4.0.0 + + org.jenkins-ci.plugins + plugin + 4.15 + + + io.jenkins.plugins + environment-dashboard + ${revision}${changelist} + hpi + Environment Dashboard Plugin + https://github.com/jenkinsci/environment-dashboard-plugin + + + MIT License + https://opensource.org/licenses/MIT + + + + scm:git:git@github.com:${gitHubRepo}.git + scm:git:git@github.com:${gitHubRepo}.git + https://github.com/${gitHubRepo} + ${scmTag} + + + + maven.jenkins-ci.org + jenkinsci-releases + https://repo.jenkins-ci.org/releases + + + + 1.1.11 + -SNAPSHOT + jenkinsci/environment-dashboard-plugin + 2.330 + 8 + false + + + + + org.apache.maven.plugins + maven-enforcer-plugin + 3.0.0-M2 + + + enforce-dependency-convergence + + enforce + + + + + + org.kohsuke.stapler:stapler + + + + + + + + + + + + + org.jenkins-ci.plugins + job-dsl + 1.76 + + + org.codehaus.groovy + groovy-all + + 2.4.12 + + + com.h2database + h2 + 1.4.196 + + + org.jenkins-ci.plugins + jquery + 1.12.4-1 + + + + org.jenkins-ci.tools + maven-hpi-plugin + 3.23 + + + + org.jenkins-ci + symbol-annotation + 1.19 + + + org.kohsuke.stapler + stapler-groovy + 1642.ve454c4518974 + + + org.kohsuke.stapler + stapler + 1.140 + + From 4edfe152d6257ffc0fb908e7c6b8d4f0c365ff5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mustafa=20Ya=C5=9Far=20Emir?= Date: Mon, 7 Mar 2022 11:11:09 +0300 Subject: [PATCH 14/21] jenkins vesiyon updated to 2.223 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 14799b76..a61f4951 100644 --- a/pom.xml +++ b/pom.xml @@ -37,7 +37,7 @@ 1.1.11 -SNAPSHOT jenkinsci/environment-dashboard-plugin - 2.330 + 2.223 8 false From 952fb6f10cae88a6f8e3b6a276a602c9a94d508f Mon Sep 17 00:00:00 2001 From: memir Date: Mon, 7 Mar 2022 15:11:17 +0300 Subject: [PATCH 15/21] RB to base pom.xml --- pom.xml | 55 ++----------------------------------------------------- 1 file changed, 2 insertions(+), 53 deletions(-) diff --git a/pom.xml b/pom.xml index a61f4951..06299514 100644 --- a/pom.xml +++ b/pom.xml @@ -1,6 +1,4 @@ - + 4.0.0 org.jenkins-ci.plugins @@ -40,34 +38,7 @@ 2.223 8 false - - - - - org.apache.maven.plugins - maven-enforcer-plugin - 3.0.0-M2 - - - enforce-dependency-convergence - - enforce - - - - - - org.kohsuke.stapler:stapler - - - - - - - - - - + org.jenkins-ci.plugins @@ -90,27 +61,5 @@ jquery 1.12.4-1 - - - org.jenkins-ci.tools - maven-hpi-plugin - 3.23 - - - - org.jenkins-ci - symbol-annotation - 1.19 - - - org.kohsuke.stapler - stapler-groovy - 1642.ve454c4518974 - - - org.kohsuke.stapler - stapler - 1.140 - From c4ac2613603e4b6c57f93163fad1d9adc4e5b857 Mon Sep 17 00:00:00 2001 From: memir Date: Mon, 7 Mar 2022 17:34:49 +0300 Subject: [PATCH 16/21] sql conn changed with preparedStatement --- .../environmentdashboard/EnvDashboardView.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/jenkinsci/plugins/environmentdashboard/EnvDashboardView.java b/src/main/java/org/jenkinsci/plugins/environmentdashboard/EnvDashboardView.java index 233f5cf9..e8ca65c9 100644 --- a/src/main/java/org/jenkinsci/plugins/environmentdashboard/EnvDashboardView.java +++ b/src/main/java/org/jenkinsci/plugins/environmentdashboard/EnvDashboardView.java @@ -12,6 +12,7 @@ import java.io.IOException; import java.sql.Connection; +import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; @@ -117,17 +118,21 @@ public void doDeleteComponent(final StaplerRequest req, StaplerResponse res) checkPermission(Jenkins.ADMINISTER); //System.out.println("[OKSY_log value of componentNameWillBeDeleted in doDeleteComponent method: ]" + componentNameWillBeDeleted); Connection conn = null; - Statement stat = null; + //Statement stat = null; + PreparedStatement preStat = null; conn = DBConnection.getConnection(); String runQuery = null; try { assert conn != null; - stat = conn.createStatement(); - runQuery = "DELETE FROM env_dashboard where compName = '" + componentNameWillBeDeleted + "';"; - stat.execute(runQuery); - System.out.println("[Delete query in doDeleteComponent method: ]" + runQuery); + runQuery = "DELETE FROM env_dashboard where compName = ?;"; + preStat = conn.prepareStatement(runQuery); + preStat.setString(1, componentNameWillBeDeleted); + int query = preStat.executeUpdate(); + System.out.println("Selected component has been removed successfully!.. " + componentNameWillBeDeleted); + + } catch (SQLException e) { System.out.println("E15: Could not delete component lines.\n" + e.getMessage()); } finally { From b7d76c5fb449b4db705441dc7108673ab617ccc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mustafa=20Ya=C5=9Far=20Emir?= Date: Mon, 7 Mar 2022 23:32:12 +0300 Subject: [PATCH 17/21] update EnvDashboardView.java --- .../plugins/environmentdashboard/EnvDashboardView.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/jenkinsci/plugins/environmentdashboard/EnvDashboardView.java b/src/main/java/org/jenkinsci/plugins/environmentdashboard/EnvDashboardView.java index e8ca65c9..e6c28893 100644 --- a/src/main/java/org/jenkinsci/plugins/environmentdashboard/EnvDashboardView.java +++ b/src/main/java/org/jenkinsci/plugins/environmentdashboard/EnvDashboardView.java @@ -128,7 +128,7 @@ public void doDeleteComponent(final StaplerRequest req, StaplerResponse res) runQuery = "DELETE FROM env_dashboard where compName = ?;"; preStat = conn.prepareStatement(runQuery); preStat.setString(1, componentNameWillBeDeleted); - int query = preStat.executeUpdate(); + preStat.executeUpdate(); System.out.println("Selected component has been removed successfully!.. " + componentNameWillBeDeleted); From f4368f1e29d0d047aa232c3ceefb2f4a920711c3 Mon Sep 17 00:00:00 2001 From: memir Date: Tue, 8 Mar 2022 00:15:51 +0300 Subject: [PATCH 18/21] fix db connection settings --- .../environmentdashboard/EnvDashboardView.java | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/jenkinsci/plugins/environmentdashboard/EnvDashboardView.java b/src/main/java/org/jenkinsci/plugins/environmentdashboard/EnvDashboardView.java index e6c28893..1d646b11 100644 --- a/src/main/java/org/jenkinsci/plugins/environmentdashboard/EnvDashboardView.java +++ b/src/main/java/org/jenkinsci/plugins/environmentdashboard/EnvDashboardView.java @@ -117,16 +117,12 @@ public void doDeleteComponent(final StaplerRequest req, StaplerResponse res) throws IOException, ServletException, FormException { checkPermission(Jenkins.ADMINISTER); //System.out.println("[OKSY_log value of componentNameWillBeDeleted in doDeleteComponent method: ]" + componentNameWillBeDeleted); - Connection conn = null; - //Statement stat = null; - PreparedStatement preStat = null; - conn = DBConnection.getConnection(); String runQuery = null; + runQuery = "DELETE FROM env_dashboard where compName = ?;"; - try { + try (Connection conn = DBConnection.getConnection(); + PreparedStatement preStat = conn.prepareStatement(runQuery);) { assert conn != null; - runQuery = "DELETE FROM env_dashboard where compName = ?;"; - preStat = conn.prepareStatement(runQuery); preStat.setString(1, componentNameWillBeDeleted); preStat.executeUpdate(); @@ -135,8 +131,6 @@ public void doDeleteComponent(final StaplerRequest req, StaplerResponse res) } catch (SQLException e) { System.out.println("E15: Could not delete component lines.\n" + e.getMessage()); - } finally { - DBConnection.closeConnection(); } res.forwardToPreviousPage(req); } From 6cc0e894b84d6d4a2fcce9d40b6999ca87cdc8e9 Mon Sep 17 00:00:00 2001 From: memir Date: Tue, 8 Mar 2022 00:50:48 +0300 Subject: [PATCH 19/21] null check added for db connection --- .../environmentdashboard/EnvDashboardView.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/jenkinsci/plugins/environmentdashboard/EnvDashboardView.java b/src/main/java/org/jenkinsci/plugins/environmentdashboard/EnvDashboardView.java index 1d646b11..dd678988 100644 --- a/src/main/java/org/jenkinsci/plugins/environmentdashboard/EnvDashboardView.java +++ b/src/main/java/org/jenkinsci/plugins/environmentdashboard/EnvDashboardView.java @@ -21,6 +21,7 @@ import java.util.Collection; import java.util.Collections; import java.util.HashMap; +import java.util.Objects; import javax.servlet.ServletException; @@ -121,12 +122,18 @@ public void doDeleteComponent(final StaplerRequest req, StaplerResponse res) runQuery = "DELETE FROM env_dashboard where compName = ?;"; try (Connection conn = DBConnection.getConnection(); - PreparedStatement preStat = conn.prepareStatement(runQuery);) { - assert conn != null; - preStat.setString(1, componentNameWillBeDeleted); - preStat.executeUpdate(); + PreparedStatement preStat = Objects.nonNull(conn) ? conn.prepareStatement(runQuery) : null;) { + + if (Objects.nonNull(preStat)) { + preStat.setString(1, componentNameWillBeDeleted); + preStat.executeUpdate(); - System.out.println("Selected component has been removed successfully!.. " + componentNameWillBeDeleted); + System.out.println("Selected component has been removed successfully!.. " + componentNameWillBeDeleted); + }else{ + System.err.println("Empty connection"); + } + + } catch (SQLException e) { From 15929508f80c97af105c98e5fa64502fceac89fa Mon Sep 17 00:00:00 2001 From: memir Date: Tue, 8 Mar 2022 09:55:50 +0300 Subject: [PATCH 20/21] fix --- .../plugins/environmentdashboard/EnvDashboardView.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/jenkinsci/plugins/environmentdashboard/EnvDashboardView.java b/src/main/java/org/jenkinsci/plugins/environmentdashboard/EnvDashboardView.java index dd678988..b78471d6 100644 --- a/src/main/java/org/jenkinsci/plugins/environmentdashboard/EnvDashboardView.java +++ b/src/main/java/org/jenkinsci/plugins/environmentdashboard/EnvDashboardView.java @@ -268,7 +268,7 @@ public boolean configure(StaplerRequest req, JSONObject formData) throws FormExc envOrder = formData.getString("envOrder"); compOrder = formData.getString("compOrder"); deployHistory = formData.getString("deployHistory"); - componentNameWillBeDeleted = formData.getString("componentNameWillBeDeleted"); + //componentNameWillBeDeleted = formData.getString("componentNameWillBeDeleted"); save(); return super.configure(req, formData); } From 96745af66e348f38773cf22d33154f68b1cc9a50 Mon Sep 17 00:00:00 2001 From: memir Date: Tue, 8 Mar 2022 10:25:25 +0300 Subject: [PATCH 21/21] removed unused variable --- .../plugins/environmentdashboard/EnvDashboardView.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/jenkinsci/plugins/environmentdashboard/EnvDashboardView.java b/src/main/java/org/jenkinsci/plugins/environmentdashboard/EnvDashboardView.java index b78471d6..339f416c 100644 --- a/src/main/java/org/jenkinsci/plugins/environmentdashboard/EnvDashboardView.java +++ b/src/main/java/org/jenkinsci/plugins/environmentdashboard/EnvDashboardView.java @@ -153,7 +153,7 @@ public static final class DescriptorImpl extends ViewDescriptor { private String envOrder; private String compOrder; private String deployHistory; - private String componentNameWillBeDeleted; + //private String componentNameWillBeDeleted; /** * descriptor impl constructor This empty constructor is required for