diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..391fbe5 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,14 @@ +version: 2 +updates: +# Maintain dependencies for your plugin +- package-ecosystem: maven + directory: / + schedule: + interval: monthly + open-pull-requests-limit: 10 + target-branch: master +# Maintain dependencies for GitHub Actions +- package-ecosystem: github-actions + directory: / + schedule: + interval: monthly diff --git a/.mvn/extensions.xml b/.mvn/extensions.xml new file mode 100644 index 0000000..1f36364 --- /dev/null +++ b/.mvn/extensions.xml @@ -0,0 +1,7 @@ + + + io.jenkins.tools.incrementals + git-changelist-maven-extension + 1.7 + + diff --git a/.mvn/maven.config b/.mvn/maven.config new file mode 100644 index 0000000..2a0299c --- /dev/null +++ b/.mvn/maven.config @@ -0,0 +1,2 @@ +-Pconsume-incrementals +-Pmight-produce-incrementals diff --git a/Jenkinsfile b/Jenkinsfile index 77c9ed7..e78e812 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,4 +1,9 @@ -#!/usr/bin/env groovy - -/* `buildPlugin` step provided by: https://github.com/jenkins-infra/pipeline-library */ -buildPlugin() +/* + 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/modifications.patch b/modifications.patch new file mode 100644 index 0000000..7424ac0 --- /dev/null +++ b/modifications.patch @@ -0,0 +1,26 @@ +diff --git a/pom.xml b/pom.xml +index 08b78fc..5911846 100644 +--- a/pom.xml ++++ b/pom.xml +@@ -1,9 +1,10 @@ + + 4.0.0 +- ++ + org.jenkins-ci.plugins + plugin +- 2.23 ++ 4.51 ++ + + + sectioned-view +@@ -48,7 +49,7 @@ + + + +- 1.580.3 ++ 2.346.3 + 6 + false + diff --git a/pom.xml b/pom.xml index 762b7af..9408f88 100644 --- a/pom.xml +++ b/pom.xml @@ -1,15 +1,16 @@ 4.0.0 - + org.jenkins-ci.plugins plugin - 2.23 + 4.76 + sectioned-view hpi Sectioned View Plugin - 1.28-SNAPSHOT + ${revision}${changelist} http://wiki.jenkins-ci.org/display/JENKINS/Sectioned+View+Plugin @@ -28,11 +29,22 @@ - scm:git:git://github.com/jenkinsci/${project.artifactId}-plugin.git - scm:git:git@github.com:jenkinsci/${project.artifactId}-plugin.git - https://github.com/jenkinsci/${project.artifactId}-plugin - HEAD + scm:git:https://github.com/${gitHubRepo}.git + scm:git:git@github.com:${gitHubRepo}.git + https://github.com/${gitHubRepo} + ${scmTag} + + + + io.jenkins.tools.bom + bom-2.401.x + 2582.v830625dd636c + pom + import + + + @@ -48,41 +60,51 @@ - 1.580.3 - 6 + 1.26 + -SNAPSHOT + jenkinsci/sectioned-view-plugin + 2.401.3 false + Max + Low + + io.jenkins.plugins + commons-lang3-api + org.mockito mockito-core - 1.10.19 test org.hamcrest hamcrest-core - 1.2.1 test org.jenkins-ci.plugins junit - 1.19 test + + + + org.apache.commons + commons-lang3 + + org.jenkins-ci.plugins antisamy-markup-formatter - 1.2 test true org.jenkins-ci.plugins cloudbees-folder - 5.18 diff --git a/src/main/java/hudson/plugins/sectioned_view/FolderViewSection.java b/src/main/java/hudson/plugins/sectioned_view/FolderViewSection.java index d19508d..5f95446 100644 --- a/src/main/java/hudson/plugins/sectioned_view/FolderViewSection.java +++ b/src/main/java/hudson/plugins/sectioned_view/FolderViewSection.java @@ -103,8 +103,7 @@ public void addChildren(TopLevelItem item, Node node, int baseFolderLevel) { } private boolean filter(TopLevelItem item, int baseFolderLevel) { - boolean allow = true; - if (!(item instanceof Folder) & hideJobs) allow = false; + boolean allow = !(!(item instanceof Folder) & hideJobs); if (regexFilter != null && !regexFilter.isEmpty() && !regexFilterPattern.matcher(item.getName()).matches()) allow = false; if (folderLevels != null && item.getFullName().length() - item.getFullName().replace("/", "").length() > (folderLevels + baseFolderLevel)) allow = false; diff --git a/src/main/java/hudson/plugins/sectioned_view/ListViewSection.java b/src/main/java/hudson/plugins/sectioned_view/ListViewSection.java index a6fd9d4..b03c75c 100644 --- a/src/main/java/hudson/plugins/sectioned_view/ListViewSection.java +++ b/src/main/java/hudson/plugins/sectioned_view/ListViewSection.java @@ -73,7 +73,8 @@ public static List getDefaultColumns() { Descriptor des = all.find(d); if (des != null) { try { - r.add(des.newInstance(null, null)); + JSONObject json = new JSONObject(); + r.add(des.newInstance(null, json)); } catch (FormException e) { LOGGER.log(Level.WARNING, "Failed to instantiate "+des.clazz,e); } diff --git a/src/main/java/hudson/plugins/sectioned_view/SectionedViewSection.java b/src/main/java/hudson/plugins/sectioned_view/SectionedViewSection.java index 0cd7de4..44f6d42 100644 --- a/src/main/java/hudson/plugins/sectioned_view/SectionedViewSection.java +++ b/src/main/java/hudson/plugins/sectioned_view/SectionedViewSection.java @@ -23,6 +23,7 @@ */ package hudson.plugins.sectioned_view; +import edu.umd.cs.findbugs.annotations.NonNull; import hudson.DescriptorExtensionList; import hudson.ExtensionPoint; import hudson.model.Describable; @@ -47,8 +48,6 @@ import jenkins.model.Jenkins; import org.kohsuke.stapler.Stapler; -import javax.annotation.Nonnull; - public abstract class SectionedViewSection implements ExtensionPoint, Describable { public SectionedViewSection(String name, Width width, Positioning alignment) { @@ -56,7 +55,7 @@ public SectionedViewSection(String name, Width width, Positioning alignment) { this.width = width; this.alignment = alignment; determineCss(); - initJobFilters(); + this.jobFilters = new DescribableList>(Saveable.NOOP, new ArrayList()); } /** @@ -96,7 +95,7 @@ public static DescriptorExtensionListgetDescriptorList(SectionedViewSection.class); } - public @Nonnull String getName() { + public @NonNull String getName() { return name == null ? "" : name; } diff --git a/src/main/java/hudson/plugins/sectioned_view/SectionedViewSectionDescriptor.java b/src/main/java/hudson/plugins/sectioned_view/SectionedViewSectionDescriptor.java index 7ede8cf..8fc8b1d 100644 --- a/src/main/java/hudson/plugins/sectioned_view/SectionedViewSectionDescriptor.java +++ b/src/main/java/hudson/plugins/sectioned_view/SectionedViewSectionDescriptor.java @@ -61,12 +61,17 @@ public boolean hasJobFilterExtensions() { @Override public SectionedViewSection newInstance(StaplerRequest req, JSONObject formData) throws FormException { + assert req != null; SectionedViewSection section = (SectionedViewSection)req.bindJSON(getClass().getDeclaringClass(), formData); - + assert section != null; if (formData.get("useincluderegex") != null) { JSONObject merp = formData.getJSONObject("useincluderegex"); try { - section.setIncludeRegex(Util.nullify(merp.getString("includeRegex"))); + String merpString = merp.getString("includeRegex"); + assert merpString != null; + merpString = Util.nullify(merpString); + assert merpString != null; + section.setIncludeRegex(merpString); } catch (PatternSyntaxException e) { throw new FormException("Regular expression is invalid: " + e.getMessage(), e, "includeRegex"); } diff --git a/src/main/java/hudson/plugins/sectioned_view/TextSection.java b/src/main/java/hudson/plugins/sectioned_view/TextSection.java index 327ee27..4c2d812 100644 --- a/src/main/java/hudson/plugins/sectioned_view/TextSection.java +++ b/src/main/java/hudson/plugins/sectioned_view/TextSection.java @@ -73,6 +73,7 @@ public static final class DescriptorImpl extends SectionedViewSectionDescriptor @Override public SectionedViewSection newInstance(StaplerRequest req, JSONObject formData) throws FormException { + assert req != null; return (SectionedViewSection)req.bindJSON(getClass().getDeclaringClass(), formData); } diff --git a/src/test/java/hudson/plugins/sectioned_view/SectionedViewTest.java b/src/test/java/hudson/plugins/sectioned_view/SectionedViewTest.java index 6de6cd3..c2edcab 100644 --- a/src/test/java/hudson/plugins/sectioned_view/SectionedViewTest.java +++ b/src/test/java/hudson/plugins/sectioned_view/SectionedViewTest.java @@ -4,16 +4,16 @@ import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.not; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; -import com.gargoylesoftware.htmlunit.html.HtmlButton; -import com.gargoylesoftware.htmlunit.html.HtmlElement; -import com.gargoylesoftware.htmlunit.html.HtmlForm; -import com.gargoylesoftware.htmlunit.html.HtmlInput; -import com.gargoylesoftware.htmlunit.html.HtmlPage; +import org.htmlunit.html.HtmlButton; +import org.htmlunit.html.HtmlElement; +import org.htmlunit.html.HtmlForm; +import org.htmlunit.html.HtmlInput; +import org.htmlunit.html.HtmlPage; import hudson.markup.RawHtmlMarkupFormatter; import hudson.model.Descriptor; import hudson.model.ItemGroup; @@ -69,8 +69,7 @@ public void doNotEnumerateItemsRepeatedly() throws Exception { @Test @Issue("JENKINS-44987") public void htmlUI() throws Exception { - String MARKUP = ""; - + String MARKUP = ""; j.jenkins.setMarkupFormatter(new RawHtmlMarkupFormatter(false)); SectionedView sw = new SectionedView("SW"); diff --git a/src/test/java/hudson/plugins/sectioned_view/TestResultViewSectionTest.java b/src/test/java/hudson/plugins/sectioned_view/TestResultViewSectionTest.java index 2e6eae1..752206b 100644 --- a/src/test/java/hudson/plugins/sectioned_view/TestResultViewSectionTest.java +++ b/src/test/java/hudson/plugins/sectioned_view/TestResultViewSectionTest.java @@ -1,7 +1,5 @@ package hudson.plugins.sectioned_view; -import static org.junit.Assert.*; - import hudson.Launcher; import hudson.model.AbstractBuild; import hudson.model.BuildListener; @@ -15,23 +13,28 @@ import java.io.IOException; import java.util.Collections; +import java.util.Objects; import java.util.regex.Pattern; +import static org.junit.Assert.assertTrue; + /** * @author ogondza. */ public class TestResultViewSectionTest { public @Rule JenkinsRule j = new JenkinsRule(); - + @Test public void showIt() throws Exception { FreeStyleProject p = j.createFreeStyleProject("test_project"); - p.getPublishersList().add(new JUnitResultArchiver("*.xml", false, null, 1)); + p.getPublishersList().add(new JUnitResultArchiver("*.xml")); p.getBuildersList().add(new TestBuilder() { @Override public boolean perform(AbstractBuild build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException { - build.getWorkspace().child("result.xml").copyFrom(TestResultViewSectionTest.class.getResourceAsStream("junit-report-1472.xml")); + Objects.requireNonNull(build.getWorkspace()).child("result.xml"). + copyFrom(Objects.requireNonNull(TestResultViewSectionTest.class. + getResourceAsStream("junit-report-1472.xml"))); return true; } });