From cc6c900c6b9d5040078e9c1ceb0688987bf951cd Mon Sep 17 00:00:00 2001 From: Bruno Verachten Date: Mon, 2 Oct 2023 21:28:03 +0200 Subject: [PATCH 01/11] Add a JDK21 Jenkinsfile for ci.jenkins.io --- Jenkinsfile | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..64fce02 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,12 @@ +/* + See the documentation for more options: + +https://github.com/jenkins-infra/pipeline-library/ + +*/ +buildPlugin( + useContainerAgent: true, // Set to `false` if you need to use Docker for containerized tests + configurations: [ + [platform: 'linux', jdk: 21], + [platform: 'windows', jdk: 17], +]) From bd1da12ab4c1420dca5ef7ca729553162559834d Mon Sep 17 00:00:00 2001 From: Bruno Verachten Date: Wed, 4 Oct 2023 17:11:08 +0200 Subject: [PATCH 02/11] Use most recent parent pom --- pom.xml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 3729bc2..db8a1f8 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.jenkins-ci.plugins plugin - 3.43 + 4.74 io.jenkins.plugins @@ -12,8 +12,7 @@ 0.13-SNAPSHOT hpi - 2.164.1 - 8 + 2.361.4 Pipeline restFul API Plugin From a8a5a96193bc167d264205334195e8838b423062 Mon Sep 17 00:00:00 2001 From: gounthar Date: Wed, 4 Oct 2023 17:16:50 +0200 Subject: [PATCH 03/11] fix(spotbug): Encoding problem. [ERROR] High: Found reliance on default encoding in io.jenkins.plugins.pipeline.restful.api.HttpFlowDefinition.create(FlowExecutionOwner, TaskListener, List): java.io.ByteArrayOutputStream.toString() [io.jenkins.plugins.pipeline.restful.api.HttpFlowDefinition] At HttpFlowDefinition.java:[line 35] DM_DEFAULT_ENCODING --- .../plugins/pipeline/restful/api/HttpFlowDefinition.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/jenkins/plugins/pipeline/restful/api/HttpFlowDefinition.java b/src/main/java/io/jenkins/plugins/pipeline/restful/api/HttpFlowDefinition.java index 07d3505..8c3c0b6 100644 --- a/src/main/java/io/jenkins/plugins/pipeline/restful/api/HttpFlowDefinition.java +++ b/src/main/java/io/jenkins/plugins/pipeline/restful/api/HttpFlowDefinition.java @@ -12,6 +12,7 @@ import java.io.ByteArrayOutputStream; import java.io.InputStream; +import java.nio.charset.StandardCharsets; import java.net.URL; import java.util.List; @@ -32,7 +33,7 @@ public CpsFlowExecution create(FlowExecutionOwner owner, TaskListener listener, try(InputStream input = new URL(url).openStream()) { ByteArrayOutputStream data = new ByteArrayOutputStream(); IOUtils.copy(input, data); - script = data.toString(); + script = data.toString(StandardCharsets.UTF_8); } return new CpsFlowExecution(this.script, this.sandbox, owner); } From 77a34fdfadb6bcd590e05b55179e2389960e6668 Mon Sep 17 00:00:00 2001 From: gounthar Date: Wed, 4 Oct 2023 17:18:58 +0200 Subject: [PATCH 04/11] fix(spotbug): Encoding problem. [ERROR] High: Found reliance on default encoding in io.jenkins.plugins.pipeline.restful.api.InstanceAPI.doGenerateToken(StaplerResponse, String): java.io.ByteArrayOutputStream.toString() [io.jenkins.plugins.pipeline.restful.api.InstanceAPI] At InstanceAPI.java:[line 161] DM_DEFAULT_ENCODING --- .../io/jenkins/plugins/pipeline/restful/api/InstanceAPI.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/jenkins/plugins/pipeline/restful/api/InstanceAPI.java b/src/main/java/io/jenkins/plugins/pipeline/restful/api/InstanceAPI.java index c9080bc..3278239 100644 --- a/src/main/java/io/jenkins/plugins/pipeline/restful/api/InstanceAPI.java +++ b/src/main/java/io/jenkins/plugins/pipeline/restful/api/InstanceAPI.java @@ -25,6 +25,7 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStream; +import java.nio.charset.StandardCharsets; import java.net.HttpURLConnection; import java.net.URL; import java.util.HashMap; @@ -158,7 +159,7 @@ public void setWriteListener(WriteListener writeListener) { urlCon.setDoOutput(true); urlCon.setRequestProperty("Content-Type", "application/json; charset=UTF-8"); - JSONObject jsonObj = JSONObject.fromObject(output.toString()); + JSONObject jsonObj = JSONObject.fromObject(output.toString(StandardCharsets.UTF_8)); jsonObj.getJSONObject("data").put("userName", user.getFullName()); urlCon.setFixedLengthStreamingMode(jsonObj.toString().length()); From 00f7e44b9f769b86a0dcf30f517bcdac594ac7f1 Mon Sep 17 00:00:00 2001 From: gounthar Date: Wed, 4 Oct 2023 17:20:36 +0200 Subject: [PATCH 05/11] fix(spotbug): Encoding problem. [ERROR] High: Found reliance on default encoding in io.jenkins.plugins.pipeline.restful.api.InstanceAPI.doGenerateToken(StaplerResponse, String): String.getBytes() [io.jenkins.plugins.pipeline.restful.api.InstanceAPI] At InstanceAPI.java:[line 167] DM_DEFAULT_ENCODING --- .../io/jenkins/plugins/pipeline/restful/api/InstanceAPI.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/jenkins/plugins/pipeline/restful/api/InstanceAPI.java b/src/main/java/io/jenkins/plugins/pipeline/restful/api/InstanceAPI.java index 3278239..91f067f 100644 --- a/src/main/java/io/jenkins/plugins/pipeline/restful/api/InstanceAPI.java +++ b/src/main/java/io/jenkins/plugins/pipeline/restful/api/InstanceAPI.java @@ -164,7 +164,7 @@ public void setWriteListener(WriteListener writeListener) { urlCon.setFixedLengthStreamingMode(jsonObj.toString().length()); try(OutputStream os = urlCon.getOutputStream()) { - os.write(jsonObj.toString().getBytes()); + os.write(jsonObj.toString().getBytes(StandardCharsets.UTF_8)); } String result = "All set, jcli is ready! For example: 'jcli plugin list'. You can close this page now."; From 1a20c56a88ea06085f12b059823b60e4954718c9 Mon Sep 17 00:00:00 2001 From: gounthar Date: Wed, 4 Oct 2023 17:23:17 +0200 Subject: [PATCH 06/11] fix(spotbug): Encoding problem. [ERROR] Medium: Redundant nullcheck of config, which is known to be non-null in io.jenkins.plugins.pipeline.restful.api.InstanceAPI.doSetLocation(String, String) [io.jenkins.plugins.pipeline.restful.api.InstanceAPI] Redundant null check at InstanceAPI.java:[line 182] RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE --- .../io/jenkins/plugins/pipeline/restful/api/InstanceAPI.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/main/java/io/jenkins/plugins/pipeline/restful/api/InstanceAPI.java b/src/main/java/io/jenkins/plugins/pipeline/restful/api/InstanceAPI.java index 91f067f..8b92240 100644 --- a/src/main/java/io/jenkins/plugins/pipeline/restful/api/InstanceAPI.java +++ b/src/main/java/io/jenkins/plugins/pipeline/restful/api/InstanceAPI.java @@ -179,9 +179,6 @@ public HttpResponse doSetLocation(@QueryParameter String rootURL, @QueryParamete } JenkinsLocationConfiguration config = JenkinsLocationConfiguration.get(); - if (config == null) { - return HttpResponses.errorJSON("cannot set Jenkins location due to it is undefined"); - } if (StringUtils.isNotBlank(rootURL)) { config.setUrl(rootURL); From 2c7b11643582d281b3d7a2e6484d37274fceeac9 Mon Sep 17 00:00:00 2001 From: gounthar Date: Wed, 4 Oct 2023 17:25:08 +0200 Subject: [PATCH 07/11] fix(spotbug): Visibility problem. [ERROR] Medium: Should io.jenkins.plugins.pipeline.restful.api.PipelineRestfulAPI$IdentifyCause be a _static_ inner class? [io.jenkins.plugins.pipeline.restful.api.PipelineRestfulAPI$IdentifyCause] At PipelineRestfulAPI.java:[lines 305-328] SIC_INNER_SHOULD_BE_STATIC --- .../plugins/pipeline/restful/api/PipelineRestfulAPI.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/jenkins/plugins/pipeline/restful/api/PipelineRestfulAPI.java b/src/main/java/io/jenkins/plugins/pipeline/restful/api/PipelineRestfulAPI.java index acc5a10..a77dba1 100644 --- a/src/main/java/io/jenkins/plugins/pipeline/restful/api/PipelineRestfulAPI.java +++ b/src/main/java/io/jenkins/plugins/pipeline/restful/api/PipelineRestfulAPI.java @@ -298,7 +298,7 @@ public static CauseAction getBuildCause(ParameterizedJobMixIn.ParameterizedJob j } @ExportedBean - class IdentifyCause extends Cause { + public static class IdentifyCause extends Cause { private String uuid; private String message; From 9e48f770637fb3fccfa55e19773fcbaaafc392e6 Mon Sep 17 00:00:00 2001 From: gounthar Date: Wed, 4 Oct 2023 17:26:45 +0200 Subject: [PATCH 08/11] fix(spotbug): Visibility problem. [ERROR] Medium: Should io.jenkins.plugins.pipeline.restful.api.PipelineRestfulAPI$IdentityBuild be a _static_ inner class? [io.jenkins.plugins.pipeline.restful.api.PipelineRestfulAPI$IdentityBuild] At PipelineRestfulAPI.java:[lines 200-220] SIC_INNER_SHOULD_BE_STATIC --- .../plugins/pipeline/restful/api/PipelineRestfulAPI.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/jenkins/plugins/pipeline/restful/api/PipelineRestfulAPI.java b/src/main/java/io/jenkins/plugins/pipeline/restful/api/PipelineRestfulAPI.java index a77dba1..4273757 100644 --- a/src/main/java/io/jenkins/plugins/pipeline/restful/api/PipelineRestfulAPI.java +++ b/src/main/java/io/jenkins/plugins/pipeline/restful/api/PipelineRestfulAPI.java @@ -197,7 +197,7 @@ public void doBuild(StaplerRequest req, StaplerResponse rsp, @QueryParameter Tim } @ExportedBean - class IdentityBuild { + public static class IdentityBuild { private WorkflowRun build; private IdentifyCause cause; From 6f8598b834c2fe512772eb54c28589b2e50dabab Mon Sep 17 00:00:00 2001 From: Bruno Verachten Date: Wed, 4 Oct 2023 17:29:42 +0200 Subject: [PATCH 09/11] Use https: for scm URL, not git: --- pom.xml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index db8a1f8..6f54b23 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ 0.13-SNAPSHOT hpi - 2.361.4 + 2.387.3 Pipeline restFul API Plugin @@ -23,6 +23,13 @@ + + io.jenkins.tools.bom + bom-2.387.x + 2179.v0884e842b_859 + pom + import + org.jenkins-ci.plugins structs @@ -90,7 +97,7 @@ https://github.com/jenkinsci/pipeline-restful-api-plugin - scm:git:git://github.com/jenkinsci/${project.artifactId}-plugin.git + scm:git:https://github.com/jenkinsci/${project.artifactId}-plugin.git scm:git:git@github.com:jenkinsci/${project.artifactId}-plugin.git https://github.com/jenkinsci/${project.artifactId}-plugin pipeline-restful-api-0.4 From d0b01d20dfa9b15c61ca3c99535f53b3df76312e Mon Sep 17 00:00:00 2001 From: Bruno Verachten Date: Wed, 4 Oct 2023 17:30:01 +0200 Subject: [PATCH 10/11] Automate dependency updates --- .github/dependabot.yml | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..7321407 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,8 @@ +version: 2 +updates: +- package-ecosystem: maven + directory: "/" + schedule: + interval: monthly + open-pull-requests-limit: 10 + target-branch: master From 08117d7bb5539f16c700900aa0734b982ddae369 Mon Sep 17 00:00:00 2001 From: Bruno Verachten Date: Wed, 4 Oct 2023 17:38:43 +0200 Subject: [PATCH 11/11] Use plugin bill of materials for easier dependency management --- pom.xml | 35 ----------------------------------- 1 file changed, 35 deletions(-) diff --git a/pom.xml b/pom.xml index 6f54b23..90a3743 100644 --- a/pom.xml +++ b/pom.xml @@ -30,46 +30,11 @@ pom import - - org.jenkins-ci.plugins - structs - 1.19 - - - org.jenkins-ci.plugins.workflow - workflow-step-api - 2.19 - - - org.jenkins-ci.plugins.workflow - workflow-cps - 2.39 - - - org.jenkins-ci.plugins.workflow - workflow-job - 2.11.2 - - - org.jenkins-ci.plugins.workflow - workflow-basic-steps - 2.6 - - - org.jenkins-ci.plugins.workflow - workflow-durable-task-step - 2.13 - org.jenkins-ci.plugins.workflow workflow-api 2.30 - - org.jenkins-ci.plugins.workflow - workflow-support - 3.3 - org.jenkins-ci.plugins.pipeline-stage-view pipeline-rest-api