From 27c8a2e50a34799d3cb1a704d9f3625ac662f9c9 Mon Sep 17 00:00:00 2001 From: Alexander Brandes Date: Tue, 24 May 2022 09:54:19 +0200 Subject: [PATCH] Enable CD (#21) --- .github/release-drafter.yml | 1 + .github/workflows/cd.yaml | 57 +++++++++++++++++++ .mvn/extensions.xml | 7 +++ .mvn/maven.config | 3 + pom.xml | 29 ++++------ .../GlobalBuildStatsPlugin.java | 7 +-- .../business/GlobalBuildStatsPluginSaver.java | 1 - .../global_build_stats/model/BuildResult.java | 2 + .../model/BuildSearchCriteria.java | 2 + .../model/BuildStatConfiguration.java | 9 ++- .../global_build_stats/model/DateRange.java | 2 + .../model/JobBuildResult.java | 7 ++- .../model/JobBuildResultSharder.java | 6 +- .../model/JobBuildSearchResult.java | 2 + .../model/ModelIdGenerator.java | 3 + .../DiscardResultsOlderThanDays.java | 2 +- .../RetentionStrategy.java | 2 + .../GlobalBuildStatsDataMigrator.java | 2 - .../GlobalBuildStatsXStreamReader.java | 1 - .../xstream/migration/v5/V4ToV5Migrator.java | 2 +- .../global_build_stats/VersioningTest.java | 4 +- 21 files changed, 117 insertions(+), 34 deletions(-) create mode 100644 .github/release-drafter.yml create mode 100644 .github/workflows/cd.yaml create mode 100644 .mvn/extensions.xml create mode 100644 .mvn/maven.config diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 0000000..0d0b1c9 --- /dev/null +++ b/.github/release-drafter.yml @@ -0,0 +1 @@ +_extends: .github diff --git a/.github/workflows/cd.yaml b/.github/workflows/cd.yaml new file mode 100644 index 0000000..07710b6 --- /dev/null +++ b/.github/workflows/cd.yaml @@ -0,0 +1,57 @@ +name: cd +on: + workflow_dispatch: + check_run: + types: + - completed + +jobs: + validate: + runs-on: ubuntu-latest + outputs: + should_release: ${{ steps.verify-ci-status.outputs.result == 'success' && steps.interesting-categories.outputs.interesting == 'true' }} + steps: + - name: Verify CI status + uses: jenkins-infra/verify-ci-status-action@v1.2.0 + id: verify-ci-status + with: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + output_result: true + + - name: Release Drafter + uses: release-drafter/release-drafter@v5 + if: steps.verify-ci-status.outputs.result == 'success' + with: + name: next + tag: next + version: next + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Check interesting categories + uses: jenkins-infra/interesting-category-action@v1.1.0 + id: interesting-categories + if: steps.verify-ci-status.outputs.result == 'success' + with: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + release: + runs-on: ubuntu-latest + needs: [validate] + if: needs.validate.outputs.should_release == 'true' + steps: + - name: Check out + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Set up JDK 8 + uses: actions/setup-java@v3 + with: + distribution: temurin + java-version: 8 + - name: Release + uses: jenkins-infra/jenkins-maven-cd-action@v1.3.0 + with: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }} + MAVEN_TOKEN: ${{ secrets.MAVEN_TOKEN }} diff --git a/.mvn/extensions.xml b/.mvn/extensions.xml new file mode 100644 index 0000000..0ab095f --- /dev/null +++ b/.mvn/extensions.xml @@ -0,0 +1,7 @@ + + + io.jenkins.tools.incrementals + git-changelist-maven-extension + 1.3 + + diff --git a/.mvn/maven.config b/.mvn/maven.config new file mode 100644 index 0000000..f7daf60 --- /dev/null +++ b/.mvn/maven.config @@ -0,0 +1,3 @@ +-Pconsume-incrementals +-Pmight-produce-incrementals +-Dchangelist.format=%d.v%s diff --git a/pom.xml b/pom.xml index 9981c8a..b71700f 100644 --- a/pom.xml +++ b/pom.xml @@ -3,27 +3,15 @@ org.jenkins-ci.plugins plugin - 1.609.1 + 4.40 + global-build-stats - 1.6-SNAPSHOT + ${changelist} Jenkins global-build-stats plugin hpi https://plugins.jenkins.io/global-build-stats/ - Global build stats plugin will allow to gather and display global build result statistics. It is a useful tool allowing to display global Jenkins build trend over time. - - - - - org.apache.maven.plugins - maven-javadoc-plugin - - -Xdoclint:none - - - - @@ -59,10 +47,15 @@ + + 999999-SNAPSHOT + 2.332.3 + + - scm:git:git://github.com/jenkinsci/global-build-stats-plugin.git + scm:git:https://github.com/jenkinsci/global-build-stats-plugin.git scm:git:git@github.com:jenkinsci/global-build-stats-plugin.git https://github.com/jenkinsci/global-build-stats-plugin - HEAD - + ${scmTag} + diff --git a/src/main/java/hudson/plugins/global_build_stats/GlobalBuildStatsPlugin.java b/src/main/java/hudson/plugins/global_build_stats/GlobalBuildStatsPlugin.java index 24c1cf2..7d6044b 100644 --- a/src/main/java/hudson/plugins/global_build_stats/GlobalBuildStatsPlugin.java +++ b/src/main/java/hudson/plugins/global_build_stats/GlobalBuildStatsPlugin.java @@ -40,7 +40,6 @@ * Entry point of the global build stats plugin * * @author fcamblor - * @plugin */ @ExportedBean public class GlobalBuildStatsPlugin extends Plugin { @@ -413,7 +412,7 @@ protected static void respondAjaxOk(StaplerResponse res) throws IOException { /** * Method must stay here since, for an unknown reason, in buildHistory.jelly, - * call to doesn't work (and work fine !) + * call to <j:invokeStatic> doesn't work (and <j:invoke> work fine !) * @param value Parameter which should be escaped * @return value where "\" are escaped */ @@ -422,7 +421,7 @@ public static String escapeAntiSlashes(String value){ } /** - * For some unknown reasons, doesn't work due to a classloader problem (FieldFilterFactory doesn't seem + * For some unknown reasons, <j:getStatic> doesn't work due to a classloader problem (FieldFilterFactory doesn't seem * to be accessible in a static way from jelly script) * @return FieldFilterFactory.ALL_VALUES_FILTER_LABEL */ @@ -431,7 +430,7 @@ public static String getFieldFilterALL(){ } /** - * For some unknown reasons, doesn't work due to a classloader problem (FieldFilterFactory doesn't seem + * For some unknown reasons, <:getStatic> doesn't work due to a classloader problem (FieldFilterFactory doesn't seem * to be accessible in a static way from jelly script) * @return FieldFilterFactory.REGEX_FIELD_FILTER_LABEL */ diff --git a/src/main/java/hudson/plugins/global_build_stats/business/GlobalBuildStatsPluginSaver.java b/src/main/java/hudson/plugins/global_build_stats/business/GlobalBuildStatsPluginSaver.java index 6102027..e5f68e1 100644 --- a/src/main/java/hudson/plugins/global_build_stats/business/GlobalBuildStatsPluginSaver.java +++ b/src/main/java/hudson/plugins/global_build_stats/business/GlobalBuildStatsPluginSaver.java @@ -115,7 +115,6 @@ public void reloadPlugin() { * non-trivial, up to the order of minutes or more. So to prevent this from blocking executor threads * that execute this callback, we use {@linkplain #writer a separate thread} to asynchronously persist * them to the disk. - * @param callback */ public void updatePlugin(BeforeSavePluginCallback callback){ final List configsBeforeStateChange = new ArrayList(plugin.getBuildStatConfigs()); diff --git a/src/main/java/hudson/plugins/global_build_stats/model/BuildResult.java b/src/main/java/hudson/plugins/global_build_stats/model/BuildResult.java index 80064f9..9875f17 100644 --- a/src/main/java/hudson/plugins/global_build_stats/model/BuildResult.java +++ b/src/main/java/hudson/plugins/global_build_stats/model/BuildResult.java @@ -1,5 +1,6 @@ package hudson.plugins.global_build_stats.model; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import hudson.plugins.global_build_stats.Messages; public enum BuildResult { @@ -35,6 +36,7 @@ public String getLabel() { } }; + @SuppressFBWarnings("ME_MUTABLE_ENUM_FIELD") public transient short code; private BuildResult(short _code){ diff --git a/src/main/java/hudson/plugins/global_build_stats/model/BuildSearchCriteria.java b/src/main/java/hudson/plugins/global_build_stats/model/BuildSearchCriteria.java index fb01bd8..e969780 100644 --- a/src/main/java/hudson/plugins/global_build_stats/model/BuildSearchCriteria.java +++ b/src/main/java/hudson/plugins/global_build_stats/model/BuildSearchCriteria.java @@ -1,5 +1,6 @@ package hudson.plugins.global_build_stats.model; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import hudson.plugins.global_build_stats.FieldFilter; import hudson.plugins.global_build_stats.FieldFilterFactory; @@ -139,6 +140,7 @@ public void setShownBuildResults(short shownBuildResults) { } @Override + @SuppressFBWarnings({"BC_EQUALS_METHOD_SHOULD_WORK_FOR_ALL_OBJECTS", "HE_EQUALS_USE_HASHCODE"}) public boolean equals(Object o) { if (o == null) return false; if (o == this) return true; diff --git a/src/main/java/hudson/plugins/global_build_stats/model/BuildStatConfiguration.java b/src/main/java/hudson/plugins/global_build_stats/model/BuildStatConfiguration.java index f98b187..569b890 100644 --- a/src/main/java/hudson/plugins/global_build_stats/model/BuildStatConfiguration.java +++ b/src/main/java/hudson/plugins/global_build_stats/model/BuildStatConfiguration.java @@ -1,5 +1,6 @@ package hudson.plugins.global_build_stats.model; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import hudson.plugins.global_build_stats.FieldFilter; import hudson.plugins.global_build_stats.FieldFilterFactory; @@ -20,6 +21,7 @@ * @author fcamblor */ @ExportedBean +@SuppressFBWarnings({"SE_BAD_FIELD", "SE_TRANSIENT_FIELD_NOT_RESTORED"}) public class BuildStatConfiguration implements Serializable { private static final long serialVersionUID = -2962124739645932894L; @@ -143,11 +145,13 @@ public void setyAxisChartType(YAxisChartType yAxisChartType) { } @Exported + @SuppressFBWarnings("EI_EXPOSE_REP") public YAxisChartDimension[] getDimensionsShown() { return dimensionsShown; - } + } - public void setDimensionsShown(YAxisChartDimension[] dimensionsShown) { + @SuppressFBWarnings("EI_EXPOSE_REP2") + public void setDimensionsShown(YAxisChartDimension[] dimensionsShown) { this.dimensionsShown = dimensionsShown; } @@ -258,6 +262,7 @@ public void setShownBuildResults(short shownBuildResults) { } @Override + @SuppressFBWarnings("EC_BAD_ARRAY_COMPARE") public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; diff --git a/src/main/java/hudson/plugins/global_build_stats/model/DateRange.java b/src/main/java/hudson/plugins/global_build_stats/model/DateRange.java index 5df11ef..e084661 100644 --- a/src/main/java/hudson/plugins/global_build_stats/model/DateRange.java +++ b/src/main/java/hudson/plugins/global_build_stats/model/DateRange.java @@ -3,6 +3,7 @@ import java.text.DateFormat; import java.util.Calendar; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import org.kohsuke.stapler.export.Exported; import org.kohsuke.stapler.export.ExportedBean; @@ -18,6 +19,7 @@ public DateRange(Calendar _start, Calendar _end, DateFormat _dateFormatter){ this.dateFormatter = _dateFormatter; } + @SuppressFBWarnings("EQ_COMPARETO_USE_OBJECT_EQUALS") public int compareTo(DateRange o) { return this.start.compareTo(o.start); } diff --git a/src/main/java/hudson/plugins/global_build_stats/model/JobBuildResult.java b/src/main/java/hudson/plugins/global_build_stats/model/JobBuildResult.java index 2a3e6a4..e5ee989 100644 --- a/src/main/java/hudson/plugins/global_build_stats/model/JobBuildResult.java +++ b/src/main/java/hudson/plugins/global_build_stats/model/JobBuildResult.java @@ -1,5 +1,7 @@ package hudson.plugins.global_build_stats.model; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; + import java.io.Serializable; import java.util.Calendar; import java.util.Comparator; @@ -86,6 +88,7 @@ public boolean isNodeNameEmpty(){ } @Override + @SuppressFBWarnings("HE_EQUALS_USE_HASHCODE") public boolean equals(Object obj) { if(obj instanceof JobBuildResult){ JobBuildResult r = (JobBuildResult)obj; @@ -119,11 +122,13 @@ public String getUserName() { return userName; } + @SuppressFBWarnings("SE_COMPARATOR_SHOULD_BE_SERIALIZABLE") public void setUserName(String userName) { this.userName = userName; } - public static class ChronologicalComparator implements Comparator{ + @SuppressFBWarnings("SE_COMPARATOR_SHOULD_BE_SERIALIZABLE") + public static class ChronologicalComparator implements Comparator{ public int compare(JobBuildResult jbr1, JobBuildResult jbr2) { return jbr1.buildDate.compareTo(jbr2.buildDate); } diff --git a/src/main/java/hudson/plugins/global_build_stats/model/JobBuildResultSharder.java b/src/main/java/hudson/plugins/global_build_stats/model/JobBuildResultSharder.java index 92dec4c..00823c8 100644 --- a/src/main/java/hudson/plugins/global_build_stats/model/JobBuildResultSharder.java +++ b/src/main/java/hudson/plugins/global_build_stats/model/JobBuildResultSharder.java @@ -1,5 +1,6 @@ package hudson.plugins.global_build_stats.model; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import hudson.model.Hudson; import hudson.plugins.global_build_stats.util.CollectionsUtil; import org.apache.commons.io.FileUtils; @@ -14,7 +15,7 @@ * @author fcamblor * POJO which responsibility is to : * - Shard JobBuildResult into several monthly files when saving / loading JobBuildResults - * - Allow to queue add & remove of job build results before a save + * - Allow to queue add and remove of job build results before a save */ public class JobBuildResultSharder { @@ -76,6 +77,7 @@ public void queueResultsToRemove(List results){ queuedResultsToRemove.addAll(results); } + @SuppressFBWarnings("DM_DEFAULT_ENCODING") public void applyQueuedResultsInFiles(){ LOGGER.log(Level.FINER, "Processing job results update queue ..."); // atomically move all the queued stuff into a local list @@ -129,6 +131,7 @@ public void applyQueuedResultsInFiles(){ LOGGER.log(Level.FINER, "Queued changes applied on job results !"); } + @SuppressFBWarnings({"NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE", "DM_DEFAULT_ENCODING"}) public static List load(){ List jobBuildResults = new ArrayList(); File jobResultsRoot = getJobResultFolder(); @@ -175,6 +178,7 @@ public boolean pendingChanges(){ /** * Transforming given JobBuildResult list into a map of type [filename of monthly job result file => list of job results] */ + @SuppressFBWarnings("STCAL_INVOKE_ON_STATIC_DATE_FORMAT_INSTANCE") private static Map> toJobResultFilenameMap(List results){ // Sharding job build results depending on their year+month Map> byMonthJobResults = new HashMap>(); diff --git a/src/main/java/hudson/plugins/global_build_stats/model/JobBuildSearchResult.java b/src/main/java/hudson/plugins/global_build_stats/model/JobBuildSearchResult.java index 4ed39be..f901745 100644 --- a/src/main/java/hudson/plugins/global_build_stats/model/JobBuildSearchResult.java +++ b/src/main/java/hudson/plugins/global_build_stats/model/JobBuildSearchResult.java @@ -1,11 +1,13 @@ package hudson.plugins.global_build_stats.model; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import hudson.Util; /** * Implementation used in search result view * @author fcamblor */ +@SuppressFBWarnings("EQ_DOESNT_OVERRIDE_EQUALS") public class JobBuildSearchResult extends JobBuildResult { // Will be true if targetted job hasn't be deleted/renamed diff --git a/src/main/java/hudson/plugins/global_build_stats/model/ModelIdGenerator.java b/src/main/java/hudson/plugins/global_build_stats/model/ModelIdGenerator.java index a52f5e1..dab76d4 100644 --- a/src/main/java/hudson/plugins/global_build_stats/model/ModelIdGenerator.java +++ b/src/main/java/hudson/plugins/global_build_stats/model/ModelIdGenerator.java @@ -1,5 +1,7 @@ package hudson.plugins.global_build_stats.model; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; + import java.security.SecureRandom; import java.util.Collections; import java.util.HashMap; @@ -41,6 +43,7 @@ public void unregisterIdForClass(Class clazz, String id){ } } + @SuppressFBWarnings("DMI_RANDOM_USED_ONLY_ONCE") public String generateIdForClass(Class clazz){ String id = null; do{ diff --git a/src/main/java/hudson/plugins/global_build_stats/rententionstrategies/DiscardResultsOlderThanDays.java b/src/main/java/hudson/plugins/global_build_stats/rententionstrategies/DiscardResultsOlderThanDays.java index 2e772b7..d705164 100644 --- a/src/main/java/hudson/plugins/global_build_stats/rententionstrategies/DiscardResultsOlderThanDays.java +++ b/src/main/java/hudson/plugins/global_build_stats/rententionstrategies/DiscardResultsOlderThanDays.java @@ -35,7 +35,7 @@ public long getDays() { } public void updateStrategyParameters(Map parameters) { - this.days = Long.valueOf(parameters.get("discardResultsOlderThanDays")[0]); + this.days = Long.parseLong(parameters.get("discardResultsOlderThanDays")[0]); } public void updateStrategyParameters(DiscardResultsOlderThanDays otherStrategyToCopy) { diff --git a/src/main/java/hudson/plugins/global_build_stats/rententionstrategies/RetentionStrategy.java b/src/main/java/hudson/plugins/global_build_stats/rententionstrategies/RetentionStrategy.java index 3527455..ed72a2a 100644 --- a/src/main/java/hudson/plugins/global_build_stats/rententionstrategies/RetentionStrategy.java +++ b/src/main/java/hudson/plugins/global_build_stats/rententionstrategies/RetentionStrategy.java @@ -1,5 +1,6 @@ package hudson.plugins.global_build_stats.rententionstrategies; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import hudson.model.AbstractBuild; import hudson.plugins.global_build_stats.business.GlobalBuildStatsPluginSaver; import hudson.plugins.global_build_stats.rententionstrategies.strategybehaviours.BuildCompletedListener; @@ -15,6 +16,7 @@ */ public abstract class RetentionStrategy { + @SuppressFBWarnings("MS_MUTABLE_COLLECTION_PKGPROTECT") protected static final List RETENTION_STRATEGIES_IMPLEMENTATIONS = new ArrayList(){{ add(new DiscardResultsOlderThanDays()); add(new DoNotKeepBuildResultWhenDiscarded()); diff --git a/src/main/java/hudson/plugins/global_build_stats/xstream/migration/GlobalBuildStatsDataMigrator.java b/src/main/java/hudson/plugins/global_build_stats/xstream/migration/GlobalBuildStatsDataMigrator.java index 10728e5..c9638c0 100644 --- a/src/main/java/hudson/plugins/global_build_stats/xstream/migration/GlobalBuildStatsDataMigrator.java +++ b/src/main/java/hudson/plugins/global_build_stats/xstream/migration/GlobalBuildStatsDataMigrator.java @@ -6,8 +6,6 @@ /** * Migrator from old GlobalBuildStats POJO to later GlobalBuildStats POJO * @author fcamblor - * @param - * @param */ public interface GlobalBuildStatsDataMigrator { public TTO migrate(TFROM pojo); diff --git a/src/main/java/hudson/plugins/global_build_stats/xstream/migration/GlobalBuildStatsXStreamReader.java b/src/main/java/hudson/plugins/global_build_stats/xstream/migration/GlobalBuildStatsXStreamReader.java index d34af2c..52a7499 100644 --- a/src/main/java/hudson/plugins/global_build_stats/xstream/migration/GlobalBuildStatsXStreamReader.java +++ b/src/main/java/hudson/plugins/global_build_stats/xstream/migration/GlobalBuildStatsXStreamReader.java @@ -6,7 +6,6 @@ /** * Behavior for GlobalBuildStats readers * @author fcamblor - * @param */ public interface GlobalBuildStatsXStreamReader { T readGlobalBuildStatsPOJO(HierarchicalStreamReader reader, UnmarshallingContext context); diff --git a/src/main/java/hudson/plugins/global_build_stats/xstream/migration/v5/V4ToV5Migrator.java b/src/main/java/hudson/plugins/global_build_stats/xstream/migration/v5/V4ToV5Migrator.java index 736d2aa..2258f97 100644 --- a/src/main/java/hudson/plugins/global_build_stats/xstream/migration/v5/V4ToV5Migrator.java +++ b/src/main/java/hudson/plugins/global_build_stats/xstream/migration/v5/V4ToV5Migrator.java @@ -11,7 +11,7 @@ /** * V5 Evolutions : * - BuildStatConfiguration.nodeFilter attribute added - * - BuildStatConfiguration.jobFilter values refactored ("jobNameRegex" => "fieldRegex") + * - BuildStatConfiguration.jobFilter values refactored ("jobNameRegex" to "fieldRegex") * @author fcamblor */ public class V4ToV5Migrator extends PreV8AbstractMigrator { diff --git a/src/test/java/hudson/plugins/global_build_stats/VersioningTest.java b/src/test/java/hudson/plugins/global_build_stats/VersioningTest.java index d0a7fff..5aec1fa 100644 --- a/src/test/java/hudson/plugins/global_build_stats/VersioningTest.java +++ b/src/test/java/hudson/plugins/global_build_stats/VersioningTest.java @@ -1,6 +1,6 @@ package hudson.plugins.global_build_stats; -import org.codehaus.plexus.util.FileUtils; +import org.apache.commons.io.FileUtils; import org.jvnet.hudson.test.HudsonTestCase; import org.jvnet.hudson.test.recipes.Recipe; import org.springframework.core.io.ClassPathResource; @@ -33,7 +33,7 @@ public void decorateHome(HudsonTestCase testCase, File home) throws Exception { if(!testDirectoryRoot.exists()){ throw new IllegalStateException("Directory versioning/"+versionUnderTest+" not found in classpath !"); } - FileUtils.copyDirectoryStructure(testDirectoryRoot.getFile(), home); + FileUtils.copyDirectory(testDirectoryRoot.getFile(), home); } } });