Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ buildPlugin(
forkCount: '1C', // Run a JVM per core in tests
useContainerAgent: true, // Set to `false` if you need to use Docker for containerized tests
configurations: [
[platform: 'linux', jdk: 11],
[platform: 'windows', jdk: 11],
[platform: 'linux', jdk: 21],
[platform: 'windows', jdk: 17],
])
15 changes: 3 additions & 12 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>4.52</version>
<version>5.7</version>
<relativePath />
</parent>

<properties>
<changelist>999999-SNAPSHOT</changelist>
<gitHubRepo>jenkinsci/date-parameter-plugin</gitHubRepo>
<!-- Baseline Jenkins version you use to build the plugin. Users must have this version or newer to run. -->
<jenkins.version>2.361.4</jenkins.version>
<jenkins.version>2.479.3</jenkins.version>
<!-- Other properties you may want to use:
~ java.level: set to 6 if your jenkins.version <= 1.611 ~ jenkins-test-harness.version: Jenkins Test Harness version you use to test the plugin. For Jenkins version >= 1.580.1 use JTH 2.0 or higher.
~ hpi-plugin.version: The HPI Maven Plugin version used by the plugin..
Expand All @@ -38,21 +38,12 @@
</licenses>

<scm>
<connection>scm:git:git://github.com/${gitHubRepo}.git</connection>
<connection>scm:git:https://github.com/${gitHubRepo}.git</connection>
<developerConnection>scm:git:git@github.com:${gitHubRepo}.git</developerConnection>
<url>https://github.com/${gitHubRepo}</url>
<tag>${scmTag}</tag>
</scm>

<developers>
<developer>
<id>leejaycoke</id>
<name>JuHyun Lee</name>
<email>leejaycoke@gmail.com</email>
<timezone>+9</timezone>
</developer>
</developers>

<repositories>
<repository>
<id>repo.jenkins-ci.org</id>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
package me.leejay.jenkins.dateparameter;

import static org.apache.commons.lang.StringUtils.isEmpty;

import hudson.Extension;
import hudson.model.ParameterDefinition;
import hudson.model.ParameterValue;
import hudson.util.FormValidation;
import net.sf.json.JSONObject;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.QueryParameter;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerRequest2;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import static org.apache.commons.lang.StringUtils.isEmpty;

/**
* Created by JuHyunLee on 2017. 5. 23..
*/
public class DateParameterDefinition extends ParameterDefinition {

private final static Logger log = LoggerFactory.getLogger(DateParameterDefinition.class);
private static final Logger log = LoggerFactory.getLogger(DateParameterDefinition.class);

Check warning on line 21 in src/main/java/me/leejay/jenkins/dateparameter/DateParameterDefinition.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered line

Line 21 is not covered by tests

private final static long serialVersionUID = 776445397055325795L;
private static final long serialVersionUID = 776445397055325795L;

private final StringLocalDateValue stringLocalDateValue;

Expand Down Expand Up @@ -69,14 +69,14 @@
}

@Override
public ParameterValue createValue(StaplerRequest req, JSONObject jo) {
public ParameterValue createValue(StaplerRequest2 req, JSONObject jo) {
DateParameterValue value = req.bindJSON(DateParameterValue.class, jo);
value.createValueFromJenkins(getDateFormat());
return value;
}

@Override
public ParameterValue createValue(StaplerRequest staplerRequest) {
public ParameterValue createValue(StaplerRequest2 staplerRequest) {
String requestedValue = staplerRequest.getParameter(getName());
if (isEmpty(requestedValue)) {
return getDefaultParameterValue();
Expand All @@ -90,7 +90,7 @@
@Extension
public static final class DescriptorImpl extends ParameterDescriptor {

private final static String DISPLAY_NAME = "Date Parameter";
private static final String DISPLAY_NAME = "Date Parameter";

@Override
public String getDisplayName() {
Expand All @@ -111,7 +111,8 @@
return FormValidation.ok();
}

public FormValidation doCheckDefaultValue(@QueryParameter String dateFormat, @QueryParameter String defaultValue) {
public FormValidation doCheckDefaultValue(

Check warning

Code scanning / Jenkins Security Scan

Stapler: Missing permission check Warning

Potential missing permission check in DescriptorImpl#doCheckDefaultValue

Check warning

Code scanning / Jenkins Security Scan

Stapler: Missing POST/RequirePOST annotation Warning

Potential CSRF vulnerability: If DescriptorImpl#doCheckDefaultValue connects to user-specified URLs, modifies state, or is expensive to run, it should be annotated with @POST or @RequirePOST
@QueryParameter String dateFormat, @QueryParameter String defaultValue) {
StringLocalDateValue value = new StringLocalDateValue(defaultValue, dateFormat);
if (value.isCompletionFormat()) {
return FormValidation.ok();
Expand All @@ -124,5 +125,4 @@
return FormValidation.error("Invalid default value");
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,17 @@
import hudson.model.StringParameterValue;
import hudson.tasks.BuildWrapper;
import hudson.util.VariableResolver;
import org.apache.commons.lang.StringUtils;
import org.kohsuke.stapler.DataBoundConstructor;

import java.io.IOException;
import java.util.Objects;
import org.apache.commons.lang.StringUtils;
import org.kohsuke.stapler.DataBoundConstructor;

/**
* Created by JuHyunLee on 2017. 5. 23..
*/
public class DateParameterValue extends StringParameterValue {

private final static long serialVersionUID = -3270996447541190520L;
private static final long serialVersionUID = -3270996447541190520L;

private String dateFormat;

Expand Down Expand Up @@ -80,8 +79,10 @@
if (!value.isCompletionFormat()) {
return new BuildWrapper() {
@Override
public Environment setUp(AbstractBuild build, Launcher launcher, BuildListener listener) throws IOException, InterruptedException {
throw new AbortException("Can't parse date format '" + getValue() + "' with '" + getDateFormat() + "'");
public Environment setUp(AbstractBuild build, Launcher launcher, BuildListener listener)
throws IOException, InterruptedException {
throw new AbortException(
"Can't parse date format '" + getValue() + "' with '" + getDateFormat() + "'");

Check warning on line 85 in src/main/java/me/leejay/jenkins/dateparameter/DateParameterValue.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 84-85 are not covered by tests
}
};
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
package me.leejay.jenkins.dateparameter;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Created by JuHyunLee on 2017. 6. 2..
*/
public class IntegerParamMethod {

private final Logger log = LoggerFactory.getLogger(this.getClass());

private final static Pattern PATTERN = Pattern.compile("^(?<name>.+)\\((?<parameter>[0-9]+)\\);?$");

public String name;

public Integer parameter;
private static final Pattern PATTERN = Pattern.compile("^(?<name>.+)\\((?<parameter>[0-9]+)\\);?$");

Check warning on line 12 in src/main/java/me/leejay/jenkins/dateparameter/IntegerParamMethod.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered line

Line 12 is not covered by tests

private String name;
private Integer parameter;
private String code;

public IntegerParamMethod(String code) {
Expand All @@ -42,5 +36,4 @@
public Integer getParameter() {
return parameter;
}

}
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
package me.leejay.jenkins.dateparameter;

import org.joda.time.LocalDateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.Serializable;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.List;
import org.joda.time.LocalDateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Created by JuHyunLee on 2017. 6. 2..
Expand All @@ -21,7 +20,8 @@ public class StringLocalDateValue implements Serializable {

private static final long serialVersionUID = 8295455815421939737L;

private static final String JAVA_PATTERN = "^LocalDate(Time)?\\.now\\(\\)(\\.(plus|minus)(Seconds|Minutes|Hours|Days|Months|Years)\\([0-9]+\\))*;?$";
private static final String JAVA_PATTERN =
"^LocalDate(Time)?\\.now\\(\\)(\\.(plus|minus)(Seconds|Minutes|Hours|Days|Months|Years)\\([0-9]+\\))*;?$";

private final String stringLocalDate;

Expand Down Expand Up @@ -96,5 +96,4 @@ String getValue() {

return "";
}

}