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 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], +]) diff --git a/pom.xml b/pom.xml index 3729bc2..90a3743 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.387.3 Pipeline restFul API Plugin @@ -25,45 +24,17 @@ - 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 + io.jenkins.tools.bom + bom-2.387.x + 2179.v0884e842b_859 + pom + import 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 @@ -91,7 +62,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 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); } 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..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 @@ -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,12 +159,12 @@ 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()); 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."; @@ -178,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); 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..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; @@ -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;