Skip to content

Commit

Permalink
Enable CD (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
NotMyFault committed May 24, 2022
1 parent 6f315cc commit 27c8a2e
Show file tree
Hide file tree
Showing 21 changed files with 117 additions and 34 deletions.
1 change: 1 addition & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_extends: .github
57 changes: 57 additions & 0 deletions .github/workflows/cd.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
7 changes: 7 additions & 0 deletions .mvn/extensions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<extensions xmlns="http://maven.apache.org/EXTENSIONS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/EXTENSIONS/1.0.0 http://maven.apache.org/xsd/core-extensions-1.0.0.xsd">
<extension>
<groupId>io.jenkins.tools.incrementals</groupId>
<artifactId>git-changelist-maven-extension</artifactId>
<version>1.3</version>
</extension>
</extensions>
3 changes: 3 additions & 0 deletions .mvn/maven.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-Pconsume-incrementals
-Pmight-produce-incrementals
-Dchangelist.format=%d.v%s
29 changes: 11 additions & 18 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,15 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>1.609.1</version>
<version>4.40</version>
<relativePath />
</parent>

<artifactId>global-build-stats</artifactId>
<version>1.6-SNAPSHOT</version>
<version>${changelist}</version>
<name>Jenkins global-build-stats plugin</name>
<packaging>hpi</packaging>
<url>https://plugins.jenkins.io/global-build-stats/</url>
<description>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.</description>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<additionalparam>-Xdoclint:none</additionalparam>
</configuration>
</plugin>
</plugins>
</build>

<developers>
<developer>
Expand Down Expand Up @@ -59,10 +47,15 @@
</pluginRepository>
</pluginRepositories>

<properties>
<changelist>999999-SNAPSHOT</changelist>
<jenkins.version>2.332.3</jenkins.version>
</properties>

<scm>
<connection>scm:git:git://github.com/jenkinsci/global-build-stats-plugin.git</connection>
<connection>scm:git:https://github.com/jenkinsci/global-build-stats-plugin.git</connection>
<developerConnection>scm:git:git@github.com:jenkinsci/global-build-stats-plugin.git</developerConnection>
<url>https://github.com/jenkinsci/global-build-stats-plugin</url>
<tag>HEAD</tag>
</scm>
<tag>${scmTag}</tag>
</scm>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
* Entry point of the global build stats plugin
*
* @author fcamblor
* @plugin
*/
@ExportedBean
public class GlobalBuildStatsPlugin extends Plugin {
Expand Down Expand Up @@ -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 <j:invokeStatic> doesn't work (and <j:invoke> work fine !)
* call to &lt;j:invokeStatic&gt; doesn't work (and &lt;j:invoke&gt; work fine !)
* @param value Parameter which should be escaped
* @return value where "\" are escaped
*/
Expand All @@ -422,7 +421,7 @@ public static String escapeAntiSlashes(String value){
}

/**
* For some unknown reasons, <j:getStatic> doesn't work due to a classloader problem (FieldFilterFactory doesn't seem
* For some unknown reasons, &lt;j:getStatic&gt; 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
*/
Expand All @@ -431,7 +430,7 @@ public static String getFieldFilterALL(){
}

/**
* For some unknown reasons, <j:getStatic> doesn't work due to a classloader problem (FieldFilterFactory doesn't seem
* For some unknown reasons, &lt;:getStatic&gt; 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
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<BuildStatConfiguration> configsBeforeStateChange = new ArrayList<BuildStatConfiguration>(plugin.getBuildStatConfigs());
Expand Down
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -35,6 +36,7 @@ public String getLabel() {
}
};

@SuppressFBWarnings("ME_MUTABLE_ENUM_FIELD")
public transient short code;

private BuildResult(short _code){
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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<JobBuildResult>{
@SuppressFBWarnings("SE_COMPARATOR_SHOULD_BE_SERIALIZABLE")
public static class ChronologicalComparator implements Comparator<JobBuildResult>{
public int compare(JobBuildResult jbr1, JobBuildResult jbr2) {
return jbr1.buildDate.compareTo(jbr2.buildDate);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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 {

Expand Down Expand Up @@ -76,6 +77,7 @@ public void queueResultsToRemove(List<JobBuildResult> 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
Expand Down Expand Up @@ -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<JobBuildResult> load(){
List<JobBuildResult> jobBuildResults = new ArrayList<JobBuildResult>();
File jobResultsRoot = getJobResultFolder();
Expand Down Expand Up @@ -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<String, List<JobBuildResult>> toJobResultFilenameMap(List<JobBuildResult> results){
// Sharding job build results depending on their year+month
Map<String, List<JobBuildResult>> byMonthJobResults = new HashMap<String, List<JobBuildResult>>();
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public long getDays() {
}

public void updateStrategyParameters(Map<String, String[]> parameters) {
this.days = Long.valueOf(parameters.get("discardResultsOlderThanDays")[0]);
this.days = Long.parseLong(parameters.get("discardResultsOlderThanDays")[0]);
}

public void updateStrategyParameters(DiscardResultsOlderThanDays otherStrategyToCopy) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -15,6 +16,7 @@
*/
public abstract class RetentionStrategy<T extends RetentionStrategy> {

@SuppressFBWarnings("MS_MUTABLE_COLLECTION_PKGPROTECT")
protected static final List<RetentionStrategy> RETENTION_STRATEGIES_IMPLEMENTATIONS = new ArrayList<RetentionStrategy>(){{
add(new DiscardResultsOlderThanDays());
add(new DoNotKeepBuildResultWhenDiscarded());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
/**
* Migrator from old GlobalBuildStats POJO to later GlobalBuildStats POJO
* @author fcamblor
* @param <TFROM>
* @param <TTO>
*/
public interface GlobalBuildStatsDataMigrator<TFROM extends GlobalBuildStatsPOJO, TTO extends GlobalBuildStatsPOJO> {
public TTO migrate(TFROM pojo);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
/**
* Behavior for GlobalBuildStats readers
* @author fcamblor
* @param <T>
*/
public interface GlobalBuildStatsXStreamReader<T extends GlobalBuildStatsPOJO> {
T readGlobalBuildStatsPOJO(HierarchicalStreamReader reader, UnmarshallingContext context);
Expand Down
Loading

0 comments on commit 27c8a2e

Please sign in to comment.