Skip to content
146 changes: 79 additions & 67 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,79 +1,91 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>4.52</version>
<relativePath />
</parent>
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>4.88</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>
<!-- 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..
~ stapler-plugin.version: The Stapler Maven plugin version required by the plugin.
-->
</properties>
<groupId>me.leejay.jenkins</groupId>
<artifactId>date-parameter</artifactId>
<version>${changelist}</version>
<packaging>hpi</packaging>
<name>Date Parameter Plugin</name>
<description>Java style LocalDate code as parameter in Parametrized builds</description>
<url>https://wiki.jenkins-ci.org/display/JENKINS/Date+Parameter+Plugin</url>
<!-- The default licence for Jenkins OSS Plugins is MIT. Substitute for the applicable one if needed. -->

<groupId>me.leejay.jenkins</groupId>
<artifactId>date-parameter</artifactId>
<version>${changelist}</version>
<packaging>hpi</packaging>
<name>Date Parameter Plugin</name>
<url>https://wiki.jenkins-ci.org/display/JENKINS/Date+Parameter+Plugin</url>
<description>Java style LocalDate code as parameter in Parametrized builds</description>
<!-- The default licence for Jenkins OSS Plugins is MIT. Substitute for the applicable one if needed. -->
<licenses>
<license>
<name>MIT License</name>
<url>http://opensource.org/licenses/MIT</url>
</license>
</licenses>

<licenses>
<license>
<name>MIT License</name>
<url>http://opensource.org/licenses/MIT</url>
</license>
</licenses>
<developers>
<developer>
<id>leejaycoke</id>
<name>JuHyun Lee</name>
<email>leejaycoke@gmail.com</email>
<timezone>+9</timezone>
</developer>
</developers>

<scm>
<connection>scm:git:git://github.com/${gitHubRepo}.git</connection>
<developerConnection>scm:git:git@github.com:${gitHubRepo}.git</developerConnection>
<url>https://github.com/${gitHubRepo}</url>
<tag>${scmTag}</tag>
<scm>
<connection>scm:git:https://github.com/${gitHubRepo}.git</connection>
<developerConnection>scm:git:git@github.com:${gitHubRepo}.git</developerConnection>
<tag>${scmTag}</tag>
<url>https://github.com/${gitHubRepo}</url>
</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>
<url>https://repo.jenkins-ci.org/public/</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>repo.jenkins-ci.org</id>
<url>https://repo.jenkins-ci.org/public/</url>
</pluginRepository>
</pluginRepositories>
<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.462.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..
~ stapler-plugin.version: The Stapler Maven plugin version required by the plugin.
-->
</properties>
<!-- https://mvnrepository.com/artifact/joda-time/joda-time -->
<dependencies>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.9.9</version>
<scope>compile</scope>
</dependency>
</dependencies>

<!-- https://mvnrepository.com/artifact/joda-time/joda-time -->
<dependencies>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.9.9</version>
<scope>compile</scope>
</dependency>
</dependencies>
<repositories>
<repository>
<id>repo.jenkins-ci.org</id>
<url>https://repo.jenkins-ci.org/public/</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>repo.jenkins-ci.org</id>
<url>https://repo.jenkins-ci.org/public/</url>
</pluginRepository>
</pluginRepositories>
<build>
<plugins>
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<configuration>
<excludeFilterFile>src/main/resources/spotbugs-exclude.xml</excludeFilterFile>
<xmlOutput>true</xmlOutput>
<outputDirectory>target</outputDirectory>
</configuration>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package me.leejay.jenkins.dateparameter;

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

import hudson.Extension;
import hudson.model.ParameterDefinition;
import hudson.model.ParameterValue;
Expand All @@ -11,16 +13,14 @@
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 @@ -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,10 +1,9 @@
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..
Expand All @@ -13,7 +12,7 @@

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

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

Check warning on line 15 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 15 is not covered by tests

public String name;

Expand Down Expand Up @@ -42,5 +41,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 "";
}

}
9 changes: 9 additions & 0 deletions src/main/resources/spotbugs-exclude.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<FindBugsFilter>
<Match>
<Bug pattern="PA_PUBLIC_PRIMITIVE_ATTRIBUTE"/>
</Match>
<Match>
<Bug pattern="PA_PUBLIC_PRIMITIVE_ATTRIBUTE"/>
</Match>
</FindBugsFilter>