diff --git a/README.adoc b/README.adoc index b54b0c851..93591540d 100644 --- a/README.adoc +++ b/README.adoc @@ -73,7 +73,7 @@ pipeline { git url: 'https://github.com/cyrille-leclerc/multi-module-maven-project' withMaven { sh "mvn clean verify" - } // withMaven will discover the generated Maven artifacts, JUnit Surefire & FailSafe reports and FindBugs reports + } // withMaven will discover the generated Maven artifacts, JUnit Surefire, FailSafe and other reports } } } @@ -143,7 +143,7 @@ pipeline { ) { // Run the maven build sh "mvn clean verify" - } // withMaven will discover the generated Maven artifacts, JUnit Surefire & FailSafe & FindBugs & SpotBugs reports... + } // withMaven will discover the generated Maven artifacts, JUnit Surefire, FailSafe and others reports } } } @@ -280,20 +280,20 @@ Maven build executions inside the `withMaven(){}` will be detected and Jenkins w * Concordion test reports (since 3.0.0) * And more (see below) ... -[WARNING] -.Deprecated publishers -==== -* Publish Findbugs reports (if the https://plugins.jenkins.io/findbugs/[Jenkins FindBugs Plugin] is installed) -* Publish a report of the tasks (`FIXME` and `TODO`) found in the java source code (if the https://plugins.jenkins.io/tasks/[Jenkins Tasks Scanner Plugin] is installed). -==== - -TIP: In the future, deprecated publishers should be replaced by https://plugins.jenkins.io/warnings-ng/[Warnings Next Generation] implementations (See: https://issues.jenkins-ci.org/browse/JENKINS-57427[JENKINS-57427]) - NOTE: The detection of Maven builds requires using Maven 3.2+. Generated Artifact:: Archiving and the fingerprinting of the artifacts and attached artifacts generated by the Maven build (jar, sources jar, javadocs jar...) +Generated Concordion reports:: +//TODO + +Generated Invoker reports:: +//TODO + +Generated JGiven reports:: +//TODO + Generated JUnit reports:: Requires https://plugins.jenkins.io/junit/[Jenkins JUnit Plugin]. If the plugin is not installed, then the Maven report is ignored. + @@ -324,17 +324,6 @@ Requires https://plugins.jenkins.io/coverage/[Jenkins Coverage Plugin]. If the p Publishing of the Cobertura or JaCoCo reports generated by the Maven build -Generated Findbugs reports:: -Requires the deprecated https://plugins.jenkins.io/findbugs/[Jenkins FindBugs Plugin]. -+ -Publishing of the Findbugs reports generated by the Maven build - -Tasks scanner report:: -Requires the deprecated https://plugins.jenkins.io/tasks/[Jenkins Tasks Scanner Plugin] -+ -Publishing of a report of the "`FIXME`" and "`TODO`" tasks found in the java source code. The keywords can be configured. - - Dependencies Fingerprinting:: Fingerprint the Maven dependencies. By default, only the snapshot dependencies of scope compile, runtime and provided are fingerprinted. @@ -361,6 +350,11 @@ A reason to disable this publisher is typically to not "pollute" the build scree Pipeline Graph Publisher:: Build the graph of dependencies between Jenkins pipelines and Maven artifacts in order to trigger downstream pipelines (when using the `snapshotDependencies` on downstream pipelines) +Warnings:: +Requires https://plugins.jenkins.io/warnings-ng/[Jenkins WarningsNG Plugin]. If the plugin is not installed, then the reports are ignored. + +Publishing of checkstyle, cpd, findbugs, java, javadoc, maven, open tasks, pmd and spotbugs reports generated by the Maven build + ==== Implicit or Explicit activation of Publishers By default, all the publishers are enabled by default. @@ -398,14 +392,6 @@ Since 3.11.0 more fine granular options: + |`withMaven(options: [coveragePublisher(disabled: true)],...)` |`.skip-publish-coverage-results` -|Generated Findbugs reports -|`withMaven(options: [findbugsPublisher(disabled: true)],...)` -|`.skip-publish-findbugs-results` - -|Tasks scanner report -|`withMaven(options: [openTasksPublisher(disabled: true)],...)` -|`.skip-task-scanner` - |Dependencies Fingerprinting |`withMaven(options: [dependenciesFingerprintPublisher(disabled: true)],...)` |`.skip-fingerprint-maven-dependencies` @@ -429,6 +415,10 @@ Since 3.11.0 more fine granular options: + |Pipeline Graph Publisher |`withMaven(options: [pipelineGraphPublisher(disabled: true)],...)` |`.skip-pipeline-graph` + +|Warnings Publisher +|`withMaven(options: [warningsPublisher(disabled: true)],...)` +|`.skip-publish-warnings` |=== [#feature-default-configuration] diff --git a/pipeline-maven-ui-tests/pom.xml b/pipeline-maven-ui-tests/pom.xml index f67701293..758ce8002 100644 --- a/pipeline-maven-ui-tests/pom.xml +++ b/pipeline-maven-ui-tests/pom.xml @@ -36,7 +36,7 @@ UI Tests of Pipeline Maven Integration Plugin - -Djava.awt.headless=true -Xmx1024m -Djenkins.test.timeout=1000 --add-opens java.base/sun.reflect.annotation=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.util.concurrent=ALL-UNNAMED + -Djava.awt.headless=true -Xmx1024m -Djenkins.test.timeout=1500 --add-opens java.base/sun.reflect.annotation=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.util.concurrent=ALL-UNNAMED firefox-container @@ -112,7 +112,6 @@ org.junit.vintage junit-vintage-engine - ${junit.version} test diff --git a/pipeline-maven-ui-tests/src/main/java/org/jenkinsci/plugins/maven/WithMaven.java b/pipeline-maven-ui-tests/src/main/java/org/jenkinsci/plugins/maven/WithMaven.java index b939f46e4..c4eaad37c 100644 --- a/pipeline-maven-ui-tests/src/main/java/org/jenkinsci/plugins/maven/WithMaven.java +++ b/pipeline-maven-ui-tests/src/main/java/org/jenkinsci/plugins/maven/WithMaven.java @@ -174,6 +174,41 @@ public enum LifecycleThreshold { DEPLOY } + public enum TrendChartType { + AGGREGATION_TOOLS, + TOOLS_AGGREGATION, + TOOLS_ONLY, + AGGREGATION_ONLY, + NONE + } + + public enum QualityGateType { + TOTAL, + TOTAL_ERROR, + TOTAL_HIGH, + TOTAL_NORMAL, + TOTAL_LOW, + TOTAL_MODIFIED, + NEW, + NEW_ERROR, + NEW_HIGH, + NEW_NORMAL, + NEW_LOW, + NEW_MODIFIED, + DELTA, + DELTA_ERROR, + DELTA_HIGH, + DELTA_NORMAL, + DELTA_LOW + } + + public enum QualityGateCriticality { + NOTE, + UNSTABLE, + ERROR, + FAILURE + } + public static class Publisher extends PageAreaImpl { private final Control disabled = control("disabled"); @@ -196,6 +231,19 @@ public static class Publisher extends PageAreaImpl { private final Control skipDownstreamTriggers = control("skipDownstreamTriggers"); private final Control ignoreUpstreamTriggers = control("ignoreUpstreamTriggers"); + private Control sourceCodeEncoding = control("sourceCodeEncoding"); + private Control isEnabledForFailure = control("enabledForFailure"); + private Control isBlameDisabled = control("skipBlames"); + private Control trendChartType = control("trendChartType"); + private Control qualityGateThreshold = control("qualityGateThreshold"); + private Control qualityGateType = control("qualityGateType"); + private Control qualityGateCriticality = control("qualityGateCriticality"); + private Control javaIgnorePatterns = control("javaIgnorePatterns"); + private Control highPriorityTaskIdentifiers = control("highPriorityTaskIdentifiers"); + private Control normalPriorityTaskIdentifiers = control("normalPriorityTaskIdentifiers"); + private Control tasksIncludePattern = control("tasksIncludePattern"); + private Control tasksExcludePattern = control("tasksExcludePattern"); + Publisher(final PageArea issuesRecorder, final String path) { super(issuesRecorder, path); } @@ -279,5 +327,65 @@ public Publisher setIgnoreUpstreamTriggers(boolean ignoreUpstreamTriggers) { this.ignoreUpstreamTriggers.check(ignoreUpstreamTriggers); return this; } + + public Publisher setSourceCodeEncoding(String sourceCodeEncoding) { + this.sourceCodeEncoding.set(sourceCodeEncoding); + return this; + } + + public Publisher setIsEnabledForFailure(boolean isEnabledForFailure) { + this.isEnabledForFailure.check(isEnabledForFailure); + return this; + } + + public Publisher setIsBlameDisabled(boolean isBlameDisabled) { + this.isBlameDisabled.check(isBlameDisabled); + return this; + } + + public Publisher setTrendChartType(TrendChartType trendChartType) { + this.trendChartType.select(trendChartType.toString()); + return this; + } + + public Publisher setQualityGateThreshold(int qualityGateThreshold) { + this.qualityGateThreshold.set(qualityGateThreshold); + return this; + } + + public Publisher setQualityGateType(QualityGateType qualityGateType) { + this.qualityGateType.select(qualityGateType.toString()); + return this; + } + + public Publisher setQualityGateCriticality(QualityGateCriticality qualityGateCriticality) { + this.qualityGateCriticality.select(qualityGateCriticality.toString()); + return this; + } + + public Publisher setJavaIgnorePatterns(String javaIgnorePatterns) { + this.javaIgnorePatterns.set(javaIgnorePatterns); + return this; + } + + public Publisher setHighPriorityTaskIdentifiers(String highPriorityTaskIdentifiers) { + this.highPriorityTaskIdentifiers.set(highPriorityTaskIdentifiers); + return this; + } + + public Publisher setNormalPriorityTaskIdentifiers(String normalPriorityTaskIdentifiers) { + this.normalPriorityTaskIdentifiers.set(normalPriorityTaskIdentifiers); + return this; + } + + public Publisher setTasksIncludePattern(String tasksIncludePattern) { + this.tasksIncludePattern.set(tasksIncludePattern); + return this; + } + + public Publisher setTasksExcludePattern(String tasksExcludePattern) { + this.tasksExcludePattern.set(tasksExcludePattern); + return this; + } } } diff --git a/pipeline-maven-ui-tests/src/test/java/org/jenkinsci/plugins/maven/GlobalSnippetGeneratorUiTest.java b/pipeline-maven-ui-tests/src/test/java/org/jenkinsci/plugins/maven/GlobalSnippetGeneratorUiTest.java index 1f2bf2de0..5c9c92759 100644 --- a/pipeline-maven-ui-tests/src/test/java/org/jenkinsci/plugins/maven/GlobalSnippetGeneratorUiTest.java +++ b/pipeline-maven-ui-tests/src/test/java/org/jenkinsci/plugins/maven/GlobalSnippetGeneratorUiTest.java @@ -4,7 +4,10 @@ import org.jenkinsci.plugins.maven.WithMaven.LifecycleThreshold; import org.jenkinsci.plugins.maven.WithMaven.PublisherStrategy; +import org.jenkinsci.plugins.maven.WithMaven.QualityGateCriticality; +import org.jenkinsci.plugins.maven.WithMaven.QualityGateType; import org.jenkinsci.plugins.maven.WithMaven.SourceCodeRetention; +import org.jenkinsci.plugins.maven.WithMaven.TrendChartType; import org.jenkinsci.test.acceptance.junit.AbstractJUnitTest; import org.jenkinsci.test.acceptance.junit.WithPlugins; import org.jenkinsci.test.acceptance.plugins.config_file_provider.ConfigFileProvider; @@ -50,7 +53,8 @@ public void defaultConfigurationExplicitTest() { .setMavenSettingsFilePath("") .setGlobalMavenSettingsConfig("") .setGlobalMavenSettingsFilePath("") - .setMavenOpts("") + .setMavenOpts( + "-Dmaven.test.failure.ignore -Dspotbugs.failOnError=false -Dcheckstyle.failOnViolation=false -Dcheckstyle.failsOnError=false -Dpmd.failOnViolation=false") .setTraceability(true) .setMavenLocalRepo("") .setPublisherStrategy(PublisherStrategy.IMPLICIT); @@ -645,6 +649,70 @@ public void explicitPipelineGraphPublisherTest() { }"""); } + @Test + public void defaultWarningsPublisherTest() throws InterruptedException { + WithMavenSnippetGenerator snippetGenerator = createSnippetGenerator(); + + snippetGenerator.selectWithMaven().addPublisher("Warnings Publisher"); + + assertThat(snippetGenerator.generateScript()) + .isEqualTo(""" +withMaven(options: [warningsPublisher()], traceability: true) { + // some block +}"""); + } + + @Test + public void defaultWarningsPublisherExplicitTest() { + WithMavenSnippetGenerator snippetGenerator = createSnippetGenerator(); + + snippetGenerator.selectWithMaven().addPublisher("Warnings Publisher", p -> p.setDisabled(false) + .setSourceCodeEncoding("UTF-8") + .setIsEnabledForFailure(true) + .setIsBlameDisabled(true) + .setTrendChartType(TrendChartType.TOOLS_ONLY) + .setQualityGateThreshold(1) + .setQualityGateType(QualityGateType.NEW) + .setQualityGateCriticality(QualityGateCriticality.UNSTABLE) + .setJavaIgnorePatterns("") + .setHighPriorityTaskIdentifiers("FIXME") + .setNormalPriorityTaskIdentifiers("TODO") + .setTasksIncludePattern("**/*.java") + .setTasksExcludePattern("**/target/**")); + + assertThat(snippetGenerator.generateScript()) + .isEqualTo(""" +withMaven(options: [warningsPublisher()], traceability: true) { + // some block +}"""); + } + + @Test + public void explicitWarningsPublisherTest() { + WithMavenSnippetGenerator snippetGenerator = createSnippetGenerator(); + + snippetGenerator.selectWithMaven().addPublisher("Warnings Publisher", p -> p.setDisabled(true) + .setSourceCodeEncoding("ISO-8859-1") + .setIsEnabledForFailure(false) + .setIsBlameDisabled(false) + .setTrendChartType(TrendChartType.NONE) + .setQualityGateThreshold(2) + .setQualityGateType(QualityGateType.DELTA) + .setQualityGateCriticality(QualityGateCriticality.FAILURE) + .setJavaIgnorePatterns("**/*Test.java") + .setHighPriorityTaskIdentifiers("FIX") + .setNormalPriorityTaskIdentifiers("TO-DO") + .setTasksIncludePattern("*.java") + .setTasksExcludePattern("target")); + + assertThat(snippetGenerator.generateScript()) + .isEqualTo( + """ +withMaven(options: [warningsPublisher(disabled: true, enabledForFailure: false, highPriorityTaskIdentifiers: 'FIX', javaIgnorePatterns: '**/*Test.java', normalPriorityTaskIdentifiers: 'TO-DO', qualityGateCriticality: 'FAILURE', qualityGateThreshold: 2, qualityGateType: 'DELTA', skipBlames: false, sourceCodeEncoding: 'ISO-8859-1', tasksExcludePattern: 'target', tasksIncludePattern: '*.java', trendChartType: 'NONE')], traceability: true) { + // some block +}"""); + } + private WithMavenSnippetGenerator createSnippetGenerator() { WithMavenSnippetGenerator snippetGenerator = new WithMavenSnippetGenerator(jenkins); snippetGenerator.open(); diff --git a/pipeline-maven-ui-tests/src/test/java/org/jenkinsci/plugins/maven/JobSnippetGeneratorUiTest.java b/pipeline-maven-ui-tests/src/test/java/org/jenkinsci/plugins/maven/JobSnippetGeneratorUiTest.java index 2e15839b6..b8d3f56aa 100644 --- a/pipeline-maven-ui-tests/src/test/java/org/jenkinsci/plugins/maven/JobSnippetGeneratorUiTest.java +++ b/pipeline-maven-ui-tests/src/test/java/org/jenkinsci/plugins/maven/JobSnippetGeneratorUiTest.java @@ -4,7 +4,10 @@ import org.jenkinsci.plugins.maven.WithMaven.LifecycleThreshold; import org.jenkinsci.plugins.maven.WithMaven.PublisherStrategy; +import org.jenkinsci.plugins.maven.WithMaven.QualityGateCriticality; +import org.jenkinsci.plugins.maven.WithMaven.QualityGateType; import org.jenkinsci.plugins.maven.WithMaven.SourceCodeRetention; +import org.jenkinsci.plugins.maven.WithMaven.TrendChartType; import org.jenkinsci.test.acceptance.junit.AbstractJUnitTest; import org.jenkinsci.test.acceptance.junit.WithPlugins; import org.jenkinsci.test.acceptance.plugins.config_file_provider.ConfigFileProvider; @@ -57,7 +60,8 @@ public void defaultConfigurationExplicitTest() { .setMavenSettingsFilePath("") .setGlobalMavenSettingsConfig("") .setGlobalMavenSettingsFilePath("") - .setMavenOpts("") + .setMavenOpts( + "-Dmaven.test.failure.ignore -Dspotbugs.failOnError=false -Dcheckstyle.failOnViolation=false -Dcheckstyle.failsOnError=false -Dpmd.failOnViolation=false") .setTraceability(true) .setMavenLocalRepo("") .setPublisherStrategy(PublisherStrategy.IMPLICIT); @@ -652,6 +656,70 @@ public void explicitPipelineGraphPublisherTest() { }"""); } + @Test + public void defaultWarningsPublisherTest() throws InterruptedException { + WithMavenSnippetGenerator snippetGenerator = createSnippetGenerator(); + + snippetGenerator.selectWithMaven().addPublisher("Warnings Publisher"); + + assertThat(snippetGenerator.generateScript()) + .isEqualTo(""" +withMaven(options: [warningsPublisher()], traceability: true) { + // some block +}"""); + } + + @Test + public void defaultWarningsPublisherExplicitTest() { + WithMavenSnippetGenerator snippetGenerator = createSnippetGenerator(); + + snippetGenerator.selectWithMaven().addPublisher("Warnings Publisher", p -> p.setDisabled(false) + .setSourceCodeEncoding("UTF-8") + .setIsEnabledForFailure(true) + .setIsBlameDisabled(true) + .setTrendChartType(TrendChartType.TOOLS_ONLY) + .setQualityGateThreshold(1) + .setQualityGateType(QualityGateType.NEW) + .setQualityGateCriticality(QualityGateCriticality.UNSTABLE) + .setJavaIgnorePatterns("") + .setHighPriorityTaskIdentifiers("FIXME") + .setNormalPriorityTaskIdentifiers("TODO") + .setTasksIncludePattern("**/*.java") + .setTasksExcludePattern("**/target/**")); + + assertThat(snippetGenerator.generateScript()) + .isEqualTo(""" +withMaven(options: [warningsPublisher()], traceability: true) { + // some block +}"""); + } + + @Test + public void explicitWarningsPublisherTest() { + WithMavenSnippetGenerator snippetGenerator = createSnippetGenerator(); + + snippetGenerator.selectWithMaven().addPublisher("Warnings Publisher", p -> p.setDisabled(true) + .setSourceCodeEncoding("ISO-8859-1") + .setIsEnabledForFailure(false) + .setIsBlameDisabled(false) + .setTrendChartType(TrendChartType.NONE) + .setQualityGateThreshold(2) + .setQualityGateType(QualityGateType.DELTA) + .setQualityGateCriticality(QualityGateCriticality.FAILURE) + .setJavaIgnorePatterns("**/*Test.java") + .setHighPriorityTaskIdentifiers("FIX") + .setNormalPriorityTaskIdentifiers("TO-DO") + .setTasksIncludePattern("*.java") + .setTasksExcludePattern("target")); + + assertThat(snippetGenerator.generateScript()) + .isEqualTo( + """ +withMaven(options: [warningsPublisher(disabled: true, enabledForFailure: false, highPriorityTaskIdentifiers: 'FIX', javaIgnorePatterns: '**/*Test.java', normalPriorityTaskIdentifiers: 'TO-DO', qualityGateCriticality: 'FAILURE', qualityGateThreshold: 2, qualityGateType: 'DELTA', skipBlames: false, sourceCodeEncoding: 'ISO-8859-1', tasksExcludePattern: 'target', tasksIncludePattern: '*.java', trendChartType: 'NONE')], traceability: true) { + // some block +}"""); + } + private WithMavenSnippetGenerator createSnippetGenerator() { WithMavenSnippetGenerator snippetGenerator = new WithMavenSnippetGenerator(job); snippetGenerator.open(); diff --git a/pipeline-maven/pom.xml b/pipeline-maven/pom.xml index 7d4879cbb..9cf194d42 100644 --- a/pipeline-maven/pom.xml +++ b/pipeline-maven/pom.xml @@ -40,6 +40,9 @@ https://github.com/jenkinsci/pipeline-maven-plugin/ + 1333 https://github.com/jenkinsci/pipeline-maven-plugin/releases @@ -54,6 +57,25 @@ coverage true + + io.jenkins.plugins + warnings-ng + true + + + org.antlr + antlr4-runtime + + + org.ow2.asm + asm + + + xml-apis + xml-apis + + + org.jenkins-ci.main maven-plugin @@ -227,42 +249,8 @@ workflow-step-api - org.jvnet.hudson.plugins - findbugs - ${jenkins-plugin-findbugs.version} - true - - - asm - asm - - - org.apache.commons - commons-lang3 - - - org.jenkins-ci - SECURITY-144-compat - - - org.jvnet.hudson.plugins.findbugs - library - - - xerces - xercesImpl - - - xml-apis - xml-apis - - - - - org.jvnet.hudson.plugins - tasks - ${jenkins-plugin-tasks.version} - true + org.slf4j + slf4j-simple @@ -456,6 +444,49 @@ + + copy-old-plugins + + copy + + process-test-resources + + + + org.jenkins-ci.plugins + jacoco + 3.3.7 + hpi + ${project.build.directory}/test-classes/plugins + jacoco.jpi + + + org.jvnet.hudson.plugins + analysis-core + 1.96 + hpi + ${project.build.directory}/test-classes/plugins + analysis-core.jpi + + + org.jvnet.hudson.plugins + findbugs + 5.0.0 + hpi + ${project.build.directory}/test-classes/plugins + findbugs.jpi + + + org.jvnet.hudson.plugins + tasks + 4.53 + hpi + ${project.build.directory}/test-classes/plugins + tasks.jpi + + + + @@ -482,6 +513,30 @@ + + maven-resources-plugin + + + copy-old-plugins-dependencies + + copy-resources + + process-test-classes + + ${project.build.directory}/test-classes/plugins + + + ${project.build.directory}/test-classes/test-dependencies + + *.hpi + *.jpi + + + + + + + diff --git a/pipeline-maven/src/main/java/org/jenkinsci/plugins/pipeline/maven/MavenPublisherStrategy.java b/pipeline-maven/src/main/java/org/jenkinsci/plugins/pipeline/maven/MavenPublisherStrategy.java index 35237d2ce..eade7159a 100644 --- a/pipeline-maven/src/main/java/org/jenkinsci/plugins/pipeline/maven/MavenPublisherStrategy.java +++ b/pipeline-maven/src/main/java/org/jenkinsci/plugins/pipeline/maven/MavenPublisherStrategy.java @@ -14,13 +14,29 @@ import java.util.logging.Level; import java.util.logging.Logger; import jenkins.model.Jenkins; +import org.jenkinsci.plugins.pipeline.maven.publishers.CoveragePublisher; +import org.jenkinsci.plugins.pipeline.maven.publishers.FindbugsAnalysisPublisher; import org.jenkinsci.plugins.pipeline.maven.publishers.JacocoReportPublisher; +import org.jenkinsci.plugins.pipeline.maven.publishers.SpotBugsAnalysisPublisher; +import org.jenkinsci.plugins.pipeline.maven.publishers.TasksScannerPublisher; +import org.jenkinsci.plugins.pipeline.maven.publishers.WarningsPublisher; /** * @author Cyrille Le Clerc */ public enum MavenPublisherStrategy { IMPLICIT(Messages.publisher_strategy_implicit_description()) { + + private static final Map, List> DEPRECATED = Map.of( + JacocoReportPublisher.DescriptorImpl.class, + List.of("Jacoco", new CoveragePublisher.DescriptorImpl().getDisplayName()), + FindbugsAnalysisPublisher.DescriptorImpl.class, + List.of("Findbugs", new WarningsPublisher.DescriptorImpl().getDisplayName()), + SpotBugsAnalysisPublisher.DescriptorImpl.class, + List.of("Findbugs", new WarningsPublisher.DescriptorImpl().getDisplayName()), + TasksScannerPublisher.DescriptorImpl.class, + List.of("Tasks", new WarningsPublisher.DescriptorImpl().getDisplayName())); + /** *

Build the list of {@link MavenPublisher}s that should be invoked for the build execution of the given {@link TaskListener} * with the desired configuration. @@ -72,14 +88,20 @@ public List buildPublishersList( Jenkins.get().getDescriptorList(MavenPublisher.class); for (Descriptor descriptor : descriptorList) { try { - if (JacocoReportPublisher.DescriptorImpl.class.isAssignableFrom(descriptor.getClass())) { + if (DEPRECATED.keySet().contains(descriptor.getClass())) { + String deprecatedPublisherName = descriptor.getDisplayName(); + String deprecatedPlugin = + DEPRECATED.get(descriptor.getClass()).get(0); + String replacementPublisherName = + DEPRECATED.get(descriptor.getClass()).get(1); + listener.getLogger() + .println("[withMaven] " + deprecatedPublisherName + + " is no longer implicitly used with `withMaven` step."); + listener.getLogger() + .println("[withMaven] " + deprecatedPlugin + + " plugin has been deprecated and should not be used anymore."); listener.getLogger() - .println( - """ - [withMaven] JacocoPublisher is no longer implicitly used with `withMaven` step. - [withMaven] Jacoco plugin has been deprecated and should not be used anymore. - [withMaven] CoveragePublisher will be used instead. - """); + .println("[withMaven] " + replacementPublisherName + " will be used instead."); } else { defaultPublishersById.put(descriptor.getId(), descriptor.clazz.newInstance()); } diff --git a/pipeline-maven/src/main/java/org/jenkinsci/plugins/pipeline/maven/WithMavenStep.java b/pipeline-maven/src/main/java/org/jenkinsci/plugins/pipeline/maven/WithMavenStep.java index 987be1bf4..d77115d9c 100644 --- a/pipeline-maven/src/main/java/org/jenkinsci/plugins/pipeline/maven/WithMavenStep.java +++ b/pipeline-maven/src/main/java/org/jenkinsci/plugins/pipeline/maven/WithMavenStep.java @@ -59,8 +59,9 @@ import org.kohsuke.stapler.DataBoundSetter; /** - * Configures maven environment to use within a pipeline job by calling sh mvn or bat mvn. - * The selected maven installation will be configured and prepended to the path. + * Configures maven environment to use within a pipeline job by calling + * sh mvn or bat mvn. The selected maven installation + * will be configured and prepended to the path. */ public class WithMavenStep extends Step { @@ -70,7 +71,8 @@ public class WithMavenStep extends Step { private String globalMavenSettingsConfig; private String globalMavenSettingsFilePath = ""; private String maven; - private String mavenOpts = ""; + private String mavenOpts = + "-Dmaven.test.failure.ignore -Dspotbugs.failOnError=false -Dcheckstyle.failOnViolation=false -Dcheckstyle.failsOnError=false -Dpmd.failOnViolation=false"; private String jdk; private String mavenLocalRepo = ""; private List options = new ArrayList<>(); @@ -326,7 +328,14 @@ public ListBoxModel doFillPublisherStrategyItems(@AncestorInPath Item item, @Anc * Return all the registered Maven publishers */ public DescriptorExtensionList getOptionsDescriptors() { - return Jenkins.get().getDescriptorList(MavenPublisher.class); + DescriptorExtensionList result = + Jenkins.get().getDescriptorList(MavenPublisher.class); + for (MavenPublisher.DescriptorImpl d : result) { + if (d.ordinal() < 0) { + result.remove(d); + } + } + return result; } } } diff --git a/pipeline-maven/src/main/java/org/jenkinsci/plugins/pipeline/maven/publishers/AbstractHealthAwarePublisher.java b/pipeline-maven/src/main/java/org/jenkinsci/plugins/pipeline/maven/publishers/AbstractHealthAwarePublisher.java deleted file mode 100644 index c543525c9..000000000 --- a/pipeline-maven/src/main/java/org/jenkinsci/plugins/pipeline/maven/publishers/AbstractHealthAwarePublisher.java +++ /dev/null @@ -1,104 +0,0 @@ -package org.jenkinsci.plugins.pipeline.maven.publishers; - -import hudson.plugins.analysis.core.HealthAwarePublisher; -import org.jenkinsci.plugins.pipeline.maven.MavenPublisher; -import org.kohsuke.stapler.DataBoundSetter; - -/** - * @see hudson.plugins.analysis.core.HealthAwarePublisher - * @author Cyrille Le Clerc - */ -public abstract class AbstractHealthAwarePublisher extends MavenPublisher { - - /** - * Default threshold priority limit. - */ - private static final String DEFAULT_PRIORITY_THRESHOLD_LIMIT = "low"; - - /** - * Report health as 100% when the number of warnings is less than this value. - * - * @see hudson.plugins.analysis.core.HealthAwareReporter#healthy - */ - private String healthy = ""; - /** - * Report health as 0% when the number of warnings is greater than this value. - * - * @see hudson.plugins.analysis.core.HealthAwareReporter#unHealthy - */ - private String unHealthy = ""; - - /** - * Determines which warning priorities should be considered when evaluating the build health. - * - * @see hudson.plugins.analysis.core.HealthAwareReporter#thresholdLimit - */ - private String thresholdLimit = DEFAULT_PRIORITY_THRESHOLD_LIMIT; - - public String getHealthy() { - return healthy; - } - - @DataBoundSetter - public void setHealthy(String healthy) { - this.healthy = healthy; - } - - public String getUnHealthy() { - return unHealthy; - } - - @DataBoundSetter - public void setUnHealthy(String unHealthy) { - this.unHealthy = unHealthy; - } - - public String getThresholdLimit() { - return thresholdLimit; - } - - @DataBoundSetter - public void setThresholdLimit(String thresholdLimit) { - this.thresholdLimit = thresholdLimit; - } - - /** - * WARNING due to JENKINS-50508, the MUST be NO reference to - * any class of the and of the Static Code Analysis Plug-ins - * and to its package "{@code hudson.plugins.analysis.core}". - * - * @param healthAwarePublisher typed as an @{code Object} instead of being typed as a {@code hudson.plugins.analysis.core.HealthAwarePublisher} due to JENKINS-50508 - */ - protected void setHealthAwarePublisherAttributes(Object healthAwarePublisher) { - Helper.setHealthAwarePublisherAttributes(healthAwarePublisher, this); - } - - @Override - public String toString() { - return getClass().getName() + "[" + "disabled='" - + isDisabled() + '\'' + ", healthy='" - + healthy + '\'' + ", unHealthy='" - + unHealthy + '\'' + ", thresholdLimit='" - + thresholdLimit + '\'' + ']'; - } - - /** - * Required by org/jenkinsci/plugins/pipeline/maven/publishers/AbstractHealthAwarePublisher/health.jelly - */ - public abstract static class DescriptorImpl extends MavenPublisher.DescriptorImpl {} - - /** - * @author Cyrille Le Clerc - */ - static class Helper { - protected static void setHealthAwarePublisherAttributes( - Object healthAwarePublisherAsObject, AbstractHealthAwarePublisher abstractHealthAwarePublisher) { - if (healthAwarePublisherAsObject instanceof HealthAwarePublisher) { - HealthAwarePublisher healthAwarePublisher = (HealthAwarePublisher) healthAwarePublisherAsObject; - healthAwarePublisher.setHealthy(abstractHealthAwarePublisher.getHealthy()); - healthAwarePublisher.setUnHealthy(abstractHealthAwarePublisher.getUnHealthy()); - healthAwarePublisher.setThresholdLimit(abstractHealthAwarePublisher.getThresholdLimit()); - } - } - } -} diff --git a/pipeline-maven/src/main/java/org/jenkinsci/plugins/pipeline/maven/publishers/CoveragePublisher.java b/pipeline-maven/src/main/java/org/jenkinsci/plugins/pipeline/maven/publishers/CoveragePublisher.java index d8b17876a..9b57b3aa0 100644 --- a/pipeline-maven/src/main/java/org/jenkinsci/plugins/pipeline/maven/publishers/CoveragePublisher.java +++ b/pipeline-maven/src/main/java/org/jenkinsci/plugins/pipeline/maven/publishers/CoveragePublisher.java @@ -147,6 +147,16 @@ public void process(StepContext context, Element mavenSpyLogsElt) throws IOExcep if (method != null) { makeAccessible(method); invokeMethod(method, stepExecution); + } else { + listener.error( + "[withMaven] coveragePublisher - error archiving coverage results: CoverageStep.Execution.run() method not found"); + LOGGER.log( + Level.WARNING, + "Error processing coverage results: CoverageStep.Execution.run() method not found"); + throw new MavenPipelinePublisherException( + "coveragePublisher", + "archiving coverage results", + new RuntimeException("CoverageStep.Execution.run() method not found")); } } catch (Exception e) { listener.error("[withMaven] coveragePublisher - exception archiving coverage results: " + e); @@ -249,7 +259,8 @@ private SourceCodeDirectory toSourceDirectory(Element e) { @Symbol("coveragePublisher") @OptionalExtension(requirePlugins = "coverage") - public static class DescriptorImpl extends AbstractHealthAwarePublisher.DescriptorImpl { + public static class DescriptorImpl extends MavenPublisher.DescriptorImpl { + @NonNull @Override public String getDisplayName() { diff --git a/pipeline-maven/src/main/java/org/jenkinsci/plugins/pipeline/maven/publishers/FindbugsAnalysisPublisher.java b/pipeline-maven/src/main/java/org/jenkinsci/plugins/pipeline/maven/publishers/FindbugsAnalysisPublisher.java index ffd78f9c0..17ab3cd40 100644 --- a/pipeline-maven/src/main/java/org/jenkinsci/plugins/pipeline/maven/publishers/FindbugsAnalysisPublisher.java +++ b/pipeline-maven/src/main/java/org/jenkinsci/plugins/pipeline/maven/publishers/FindbugsAnalysisPublisher.java @@ -25,31 +25,26 @@ package org.jenkinsci.plugins.pipeline.maven.publishers; import edu.umd.cs.findbugs.annotations.NonNull; -import hudson.FilePath; -import hudson.Launcher; -import hudson.model.Run; -import hudson.model.StreamBuildListener; -import hudson.model.TaskListener; -import hudson.plugins.findbugs.FindBugsPublisher; +import hudson.AbortException; import java.io.IOException; -import java.io.OutputStream; -import java.util.List; -import java.util.logging.Level; import java.util.logging.Logger; import org.jenkinsci.Symbol; -import org.jenkinsci.plugins.pipeline.maven.MavenArtifact; -import org.jenkinsci.plugins.pipeline.maven.MavenSpyLogProcessor; +import org.jenkinsci.plugins.pipeline.maven.MavenPublisher; import org.jenkinsci.plugins.pipeline.maven.Messages; -import org.jenkinsci.plugins.pipeline.maven.util.XmlUtils; import org.jenkinsci.plugins.variant.OptionalExtension; import org.jenkinsci.plugins.workflow.steps.StepContext; import org.kohsuke.stapler.DataBoundConstructor; +import org.kohsuke.stapler.DataBoundSetter; import org.w3c.dom.Element; /** * @author Cyrille Le Clerc + * + * @deprecated since TODO */ -public class FindbugsAnalysisPublisher extends AbstractHealthAwarePublisher { +@Deprecated +public class FindbugsAnalysisPublisher extends MavenPublisher { + private static final Logger LOGGER = Logger.getLogger(FindbugsAnalysisPublisher.class.getName()); private static final long serialVersionUID = 1L; @@ -57,200 +52,33 @@ public class FindbugsAnalysisPublisher extends AbstractHealthAwarePublisher { @DataBoundConstructor public FindbugsAnalysisPublisher() {} - /* - - - - - - ${project.build.outputDirectory} - ${project.compileSourceRoots} - ${findbugs.debug} - ${findbugs.effort} - ${findbugs.excludeBugsFile} - ${findbugs.excludeFilterFile} - ${findbugs.failOnError} - true - ${project.build.directory} - ${findbugs.fork} - ${findbugs.includeFilterFile} - ${findbugs.includeTests} - ${findbugs.jvmArgs} - ${localRepository} - ${findbugs.maxHeap} - ${findbugs.maxRank} - ${findbugs.nested} - ${findbugs.omitVisitors} - ${findbugs.onlyAnalyze} - ${project.reporting.outputDirectory} - ${outputEncoding} - ${plugin.artifacts} - ${findbugs.pluginList} - ${project} - ${findbugs.relaxed} - ${project.remoteArtifactRepositories} - ${project.remoteArtifactRepositories} - ${findbugs.skip} - ${findbugs.skipEmptyReport} - ${encoding} - ${project.build.testOutputDirectory} - ${project.testCompileSourceRoots} - ${findbugs.threshold} - ${findbugs.timeout} - ${findbugs.trace} - ${findbugs.userPrefs} - ${findbugs.visitors} - UTF-8 - ${findbugs.xmlOutput} - ${project.build.directory} - ${project.reporting.outputDirectory}/xref - ${project.reporting.outputDirectory}/xref-test - - - - - - - - ${project.build.outputDirectory} - ${project.compileSourceRoots} - ${findbugs.debug} - ${findbugs.effort} - ${findbugs.excludeBugsFile} - ${findbugs.excludeFilterFile} - ${findbugs.failOnError} - true - ${project.build.directory} - ${findbugs.fork} - ${findbugs.includeFilterFile} - ${findbugs.includeTests} - ${findbugs.jvmArgs} - ${localRepository} - ${findbugs.maxHeap} - ${findbugs.maxRank} - ${findbugs.nested} - ${findbugs.omitVisitors} - ${findbugs.onlyAnalyze} - ${project.reporting.outputDirectory} - ${outputEncoding} - ${plugin.artifacts} - ${findbugs.pluginList} - ${project} - ${findbugs.relaxed} - ${project.remoteArtifactRepositories} - ${project.remoteArtifactRepositories} - ${findbugs.skip} - ${findbugs.skipEmptyReport} - ${encoding} - ${project.build.testOutputDirectory} - ${project.testCompileSourceRoots} - ${findbugs.threshold} - ${findbugs.timeout} - ${findbugs.trace} - ${findbugs.userPrefs} - ${findbugs.visitors} - UTF-8 - ${findbugs.xmlOutput} - ${project.build.directory} - ${project.reporting.outputDirectory}/xref - ${project.reporting.outputDirectory}/xref-test - - - */ @Override public void process(@NonNull StepContext context, @NonNull Element mavenSpyLogsElt) throws IOException, InterruptedException { + throw new AbortException( + """ + The findbugsPublisher is deprecated as is the findbugs plugin and you should not use it. + Alternatively, you should rely on warningsPublisher. + Or, if continuing to use the findbugs plugin for now, run it explicitly rather than expecting withMaven to run it implicitly. + """); + } - TaskListener listener = context.get(TaskListener.class); - if (listener == null) { - LOGGER.warning("TaskListener is NULL, default to stderr"); - listener = new StreamBuildListener((OutputStream) System.err); - } - FilePath workspace = context.get(FilePath.class); - Run run = context.get(Run.class); - Launcher launcher = context.get(Launcher.class); - - try { - Class.forName("hudson.plugins.findbugs.FindBugsPublisher"); - } catch (ClassNotFoundException e) { - listener.getLogger().print("[withMaven] Jenkins "); - listener.hyperlink("https://wiki.jenkins-ci.org/display/JENKINS/FindBugs+Plugin", "FindBugs Plugin"); - listener.getLogger() - .println( - " not found, don't display org.codehaus.mojo:findbugs-maven-plugin:findbugs results in pipeline screen."); - return; - } - - List findbugsEvents = XmlUtils.getExecutionEventsByPlugin( - mavenSpyLogsElt, - "org.codehaus.mojo", - "findbugs-maven-plugin", - "findbugs", - "MojoSucceeded", - "MojoFailed"); - - if (findbugsEvents.isEmpty()) { - LOGGER.log(Level.FINE, "No org.codehaus.mojo:findbugs-maven-plugin:findbugs execution found"); - return; - } - - for (Element findBugsTestEvent : findbugsEvents) { - - Element pluginElt = XmlUtils.getUniqueChildElement(findBugsTestEvent, "plugin"); - Element xmlOutputDirectoryElt = XmlUtils.getUniqueChildElementOrNull(pluginElt, "xmlOutputDirectory"); - Element projectElt = XmlUtils.getUniqueChildElement(findBugsTestEvent, "project"); - MavenArtifact mavenArtifact = XmlUtils.newMavenArtifact(projectElt); - MavenSpyLogProcessor.PluginInvocation pluginInvocation = XmlUtils.newPluginInvocation(pluginElt); - - if (xmlOutputDirectoryElt == null) { - listener.getLogger() - .println("[withMaven] No element found for in " - + XmlUtils.toString(findBugsTestEvent)); - continue; - } - String xmlOutputDirectory = XmlUtils.resolveMavenPlaceholders(xmlOutputDirectoryElt, projectElt); - if (xmlOutputDirectory == null) { - listener.getLogger() - .println( - "[withMaven] could not resolve placeholder '${project.build.directory}' or '${basedir}' in " - + XmlUtils.toString(findBugsTestEvent)); - continue; - } - xmlOutputDirectory = XmlUtils.getPathInWorkspace(xmlOutputDirectory, workspace); - - String findBugsResultsFile = xmlOutputDirectory + "/findbugsXml.xml"; - listener.getLogger() - .println("[withMaven] findbugsPublisher - Archive FindBugs analysis results for Maven artifact " - + mavenArtifact.toString() + " generated by " + pluginInvocation + ": " - + findBugsResultsFile); - FindBugsPublisher findBugsPublisher = new FindBugsPublisher(); - - findBugsPublisher.setPattern(findBugsResultsFile); + @DataBoundSetter + public void setHealthy(String healthy) {} - setHealthAwarePublisherAttributes(findBugsPublisher); + @DataBoundSetter + public void setUnHealthy(String unHealthy) {} - try { - findBugsPublisher.perform(run, workspace, launcher, listener); - } catch (Exception e) { - listener.error( - "[withMaven] findbugsPublisher - exception archiving FindBugs results for Maven artifact " - + mavenArtifact.toString() + " generated by " + pluginInvocation + ": " + e); - LOGGER.log(Level.WARNING, "Exception processing " + XmlUtils.toString(findBugsTestEvent), e); - throw new MavenPipelinePublisherException( - "findbugsPublisher", - "archiving FindBugs results for Maven artifact " + mavenArtifact.getId() + " generated by " - + pluginInvocation.getId(), - e); - } - } - } + @DataBoundSetter + public void setThresholdLimit(String thresholdLimit) {} /** - * Don't use symbol "findbugs", it would collide with hudson.plugins.findbugs.FindBugsPublisher + * Don't use symbol "findbugs", it would collide with + * hudson.plugins.findbugs.FindBugsPublisher */ @Symbol("findbugsPublisher") @OptionalExtension(requirePlugins = "findbugs") - public static class DescriptorImpl extends AbstractHealthAwarePublisher.DescriptorImpl { + public static class DescriptorImpl extends MavenPublisher.DescriptorImpl { @NonNull @Override public String getDisplayName() { @@ -259,7 +87,7 @@ public String getDisplayName() { @Override public int ordinal() { - return 20; + return -1; } @NonNull diff --git a/pipeline-maven/src/main/java/org/jenkinsci/plugins/pipeline/maven/publishers/JacocoReportPublisher.java b/pipeline-maven/src/main/java/org/jenkinsci/plugins/pipeline/maven/publishers/JacocoReportPublisher.java index 48ca9734e..230f3fa30 100644 --- a/pipeline-maven/src/main/java/org/jenkinsci/plugins/pipeline/maven/publishers/JacocoReportPublisher.java +++ b/pipeline-maven/src/main/java/org/jenkinsci/plugins/pipeline/maven/publishers/JacocoReportPublisher.java @@ -26,11 +26,11 @@ import edu.umd.cs.findbugs.annotations.NonNull; import hudson.AbortException; -import hudson.Extension; import java.io.IOException; import org.jenkinsci.Symbol; import org.jenkinsci.plugins.pipeline.maven.MavenPublisher; import org.jenkinsci.plugins.pipeline.maven.Messages; +import org.jenkinsci.plugins.variant.OptionalExtension; import org.jenkinsci.plugins.workflow.steps.StepContext; import org.kohsuke.stapler.DataBoundConstructor; import org.w3c.dom.Element; @@ -38,7 +38,7 @@ /** * @author Cyrille Le Clerc * - * @deprecated since TODO + * @deprecated since 1563.v2e75645a_7d43 */ @Deprecated public class JacocoReportPublisher extends MavenPublisher { @@ -104,8 +104,10 @@ public JacocoReportPublisher() {} /** * TODO only collect the jacoco report if unit tests have run + * * @param context - * @param mavenSpyLogsElt maven spy report. WARNING experimental structure for the moment, subject to change. + * @param mavenSpyLogsElt maven spy report. WARNING experimental structure for + * the moment, subject to change. * @throws IOException * @throws InterruptedException */ @@ -121,9 +123,8 @@ public void process(@NonNull StepContext context, @NonNull Element mavenSpyLogsE } @Symbol("jacocoPublisher") - @Extension - // @OptionalExtension(requirePlugins = "jacoco") - public static class DescriptorImpl extends AbstractHealthAwarePublisher.DescriptorImpl { + @OptionalExtension(requirePlugins = "jacoco") + public static class DescriptorImpl extends MavenPublisher.DescriptorImpl { @NonNull @Override public String getDisplayName() { @@ -132,7 +133,7 @@ public String getDisplayName() { @Override public int ordinal() { - return 20; + return -1; } @NonNull diff --git a/pipeline-maven/src/main/java/org/jenkinsci/plugins/pipeline/maven/publishers/SpotBugsAnalysisPublisher.java b/pipeline-maven/src/main/java/org/jenkinsci/plugins/pipeline/maven/publishers/SpotBugsAnalysisPublisher.java index d536e4038..a3b0818df 100644 --- a/pipeline-maven/src/main/java/org/jenkinsci/plugins/pipeline/maven/publishers/SpotBugsAnalysisPublisher.java +++ b/pipeline-maven/src/main/java/org/jenkinsci/plugins/pipeline/maven/publishers/SpotBugsAnalysisPublisher.java @@ -25,31 +25,28 @@ package org.jenkinsci.plugins.pipeline.maven.publishers; import edu.umd.cs.findbugs.annotations.NonNull; -import hudson.FilePath; -import hudson.Launcher; -import hudson.model.Run; -import hudson.model.TaskListener; -import hudson.plugins.findbugs.FindBugsPublisher; +import hudson.AbortException; import java.io.IOException; -import java.util.List; -import java.util.logging.Level; import java.util.logging.Logger; import org.jenkinsci.Symbol; -import org.jenkinsci.plugins.pipeline.maven.MavenArtifact; -import org.jenkinsci.plugins.pipeline.maven.MavenSpyLogProcessor; +import org.jenkinsci.plugins.pipeline.maven.MavenPublisher; import org.jenkinsci.plugins.pipeline.maven.Messages; -import org.jenkinsci.plugins.pipeline.maven.util.XmlUtils; import org.jenkinsci.plugins.variant.OptionalExtension; import org.jenkinsci.plugins.workflow.steps.StepContext; import org.kohsuke.stapler.DataBoundConstructor; +import org.kohsuke.stapler.DataBoundSetter; import org.w3c.dom.Element; /** * handle {@code mvn spotbugs:spotbugs} invocations. * * @author Cyrille Le Clerc + * + * @deprecated since TODO */ -public class SpotBugsAnalysisPublisher extends AbstractHealthAwarePublisher { +@Deprecated +public class SpotBugsAnalysisPublisher extends MavenPublisher { + private static final Logger LOGGER = Logger.getLogger(SpotBugsAnalysisPublisher.class.getName()); private static final long serialVersionUID = 1L; @@ -57,198 +54,29 @@ public class SpotBugsAnalysisPublisher extends AbstractHealthAwarePublisher { @DataBoundConstructor public SpotBugsAnalysisPublisher() {} - /* - - - - - - ${project.build.outputDirectory} - ${project.compileSourceRoots} - ${spotbugs.debug} - ${spotbugs.effort} - ${spotbugs.excludeBugsFile} - ${spotbugs.excludeFilterFile} - ${spotbugs.failOnError} - ${spotbugs.fork} - ${spotbugs.includeFilterFile} - ${spotbugs.includeTests} - ${encoding} - ${spotbugs.jvmArgs} - ${localRepository} - ${spotbugs.maxHeap} - ${spotbugs.maxRank} - ${spotbugs.nested} - ${spotbugs.omitVisitors} - ${spotbugs.onlyAnalyze} - ${project.reporting.outputDirectory} - ${outputEncoding} - ${plugin.artifacts} - ${spotbugs.pluginList} - ${project} - ${spotbugs.relaxed} - ${project.remoteArtifactRepositories} - ${project.remoteArtifactRepositories} - ${spotbugs.skip} - ${spotbugs.skipEmptyReport} - ${encoding} - true - ${project.build.directory} - ${project.build.testOutputDirectory} - ${project.testCompileSourceRoots} - ${spotbugs.threshold} - ${spotbugs.timeout} - ${spotbugs.trace} - ${spotbugs.userPrefs} - ${spotbugs.visitors} - UTF-8 - ${spotbugs.xmlOutput} - ${project.build.directory} - ${project.reporting.outputDirectory}/xref - ${project.reporting.outputDirectory}/xref-test - - - - - - - - ${project.build.outputDirectory} - ${project.compileSourceRoots} - ${spotbugs.debug} - ${spotbugs.effort} - ${spotbugs.excludeBugsFile} - ${spotbugs.excludeFilterFile} - ${spotbugs.failOnError} - ${spotbugs.fork} - ${spotbugs.includeFilterFile} - ${spotbugs.includeTests} - ${encoding} - ${spotbugs.jvmArgs} - ${localRepository} - ${spotbugs.maxHeap} - ${spotbugs.maxRank} - ${spotbugs.nested} - ${spotbugs.omitVisitors} - ${spotbugs.onlyAnalyze} - ${project.reporting.outputDirectory} - ${outputEncoding} - ${plugin.artifacts} - ${spotbugs.pluginList} - ${project} - ${spotbugs.relaxed} - ${project.remoteArtifactRepositories} - ${project.remoteArtifactRepositories} - ${spotbugs.skip} - ${spotbugs.skipEmptyReport} - ${encoding} - true - ${project.build.directory} - ${project.build.testOutputDirectory} - ${project.testCompileSourceRoots} - ${spotbugs.threshold} - ${spotbugs.timeout} - ${spotbugs.trace} - ${spotbugs.userPrefs} - ${spotbugs.visitors} - UTF-8 - ${spotbugs.xmlOutput} - ${project.build.directory} - ${project.reporting.outputDirectory}/xref - ${project.reporting.outputDirectory}/xref-test - - - */ @Override public void process(@NonNull StepContext context, @NonNull Element mavenSpyLogsElt) throws IOException, InterruptedException { + throw new AbortException( + """ + The spotbugsPublisher is deprecated as is the findbugs plugin and you should not use it. + Alternatively, you should rely on warningsPublisher. + Or, if continuing to use the findbugs plugin for now, run it explicitly rather than expecting withMaven to run it implicitly. + """); + } - TaskListener listener = context.get(TaskListener.class); - FilePath workspace = context.get(FilePath.class); - Run run = context.get(Run.class); - Launcher launcher = context.get(Launcher.class); - - List spotbugsEvents = XmlUtils.getExecutionEventsByPlugin( - mavenSpyLogsElt, - "com.github.spotbugs", - "spotbugs-maven-plugin", - "spotbugs", - "MojoSucceeded", - "MojoFailed"); - - if (spotbugsEvents.isEmpty()) { - LOGGER.log(Level.FINE, "No com.github.spotbugs:spotbugs-maven-plugin:spotbugs execution found"); - return; - } - try { - Class.forName("hudson.plugins.findbugs.FindBugsPublisher"); - } catch (ClassNotFoundException e) { - listener.getLogger().print("[withMaven] Jenkins "); - listener.hyperlink("https://wiki.jenkins-ci.org/display/JENKINS/FindBugs+Plugin", "FindBugs Plugin"); - listener.getLogger() - .println( - " not found, don't display com.github.spotbugs:spotbugs-maven-plugin:spotbugs results in pipeline screen."); - return; - } - - for (Element spotbugsEvent : spotbugsEvents) { - String findBugsEventType = spotbugsEvent.getAttribute("type"); - if (!findBugsEventType.equals("MojoSucceeded") && !findBugsEventType.equals("MojoFailed")) { - continue; - } - - Element pluginElt = XmlUtils.getUniqueChildElement(spotbugsEvent, "plugin"); - Element xmlOutputDirectoryElt = XmlUtils.getUniqueChildElementOrNull(pluginElt, "xmlOutputDirectory"); - Element projectElt = XmlUtils.getUniqueChildElement(spotbugsEvent, "project"); - MavenArtifact mavenArtifact = XmlUtils.newMavenArtifact(projectElt); - MavenSpyLogProcessor.PluginInvocation pluginInvocation = XmlUtils.newPluginInvocation(pluginElt); - - if (xmlOutputDirectoryElt == null) { - listener.getLogger() - .println("[withMaven] No element found for in " - + XmlUtils.toString(spotbugsEvent)); - continue; - } - String xmlOutputDirectory = XmlUtils.resolveMavenPlaceholders(xmlOutputDirectoryElt, projectElt); - if (xmlOutputDirectory == null) { - listener.getLogger() - .println( - "[withMaven] could not resolve placeholder '${project.build.directory}' or '${basedir}' in " - + XmlUtils.toString(spotbugsEvent)); - continue; - } - xmlOutputDirectory = XmlUtils.getPathInWorkspace(xmlOutputDirectory, workspace); - - String spotbugsResultsFile = xmlOutputDirectory + "/spotbugsXml.xml"; - listener.getLogger() - .println("[withMaven] SpotBugsPublisher - Archive SpotBugs analysis results for Maven artifact " - + mavenArtifact.toString() + " generated by " + pluginInvocation + ": " - + spotbugsResultsFile); - FindBugsPublisher findBugsPublisher = new FindBugsPublisher(); - - findBugsPublisher.setPattern(spotbugsResultsFile); + @DataBoundSetter + public void setHealthy(String healthy) {} - setHealthAwarePublisherAttributes(findBugsPublisher); + @DataBoundSetter + public void setUnHealthy(String unHealthy) {} - try { - findBugsPublisher.perform(run, workspace, launcher, listener); - } catch (Exception e) { - listener.error( - "[withMaven] SpotBugsPublisher - exception archiving FindBugs results for Maven artifact " - + mavenArtifact.toString() + " generated by " + pluginInvocation + ": " + e); - LOGGER.log(Level.WARNING, "Exception processing " + XmlUtils.toString(spotbugsEvent), e); - throw new MavenPipelinePublisherException( - "SpotBugsPublisher", - "archiving FindBugs results for Maven artifact " + mavenArtifact.getId() + " generated by " - + pluginInvocation.getId(), - e); - } - } - } + @DataBoundSetter + public void setThresholdLimit(String thresholdLimit) {} @Symbol("spotbugsPublisher") @OptionalExtension(requirePlugins = "findbugs") - public static class DescriptorImpl extends AbstractHealthAwarePublisher.DescriptorImpl { + public static class DescriptorImpl extends MavenPublisher.DescriptorImpl { @NonNull @Override public String getDisplayName() { @@ -257,7 +85,7 @@ public String getDisplayName() { @Override public int ordinal() { - return 20; + return -1; } @NonNull diff --git a/pipeline-maven/src/main/java/org/jenkinsci/plugins/pipeline/maven/publishers/TasksScannerPublisher.java b/pipeline-maven/src/main/java/org/jenkinsci/plugins/pipeline/maven/publishers/TasksScannerPublisher.java index 940c078c6..308d6b0eb 100644 --- a/pipeline-maven/src/main/java/org/jenkinsci/plugins/pipeline/maven/publishers/TasksScannerPublisher.java +++ b/pipeline-maven/src/main/java/org/jenkinsci/plugins/pipeline/maven/publishers/TasksScannerPublisher.java @@ -1,24 +1,12 @@ package org.jenkinsci.plugins.pipeline.maven.publishers; import edu.umd.cs.findbugs.annotations.NonNull; -import hudson.FilePath; -import hudson.Launcher; -import hudson.model.Run; -import hudson.model.StreamBuildListener; -import hudson.model.TaskListener; +import hudson.AbortException; import java.io.IOException; -import java.io.OutputStream; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; -import java.util.Optional; -import java.util.function.Predicate; -import java.util.logging.Level; import java.util.logging.Logger; import org.jenkinsci.Symbol; -import org.jenkinsci.plugins.pipeline.maven.MavenArtifact; +import org.jenkinsci.plugins.pipeline.maven.MavenPublisher; import org.jenkinsci.plugins.pipeline.maven.Messages; -import org.jenkinsci.plugins.pipeline.maven.util.XmlUtils; import org.jenkinsci.plugins.variant.OptionalExtension; import org.jenkinsci.plugins.workflow.steps.StepContext; import org.kohsuke.stapler.DataBoundConstructor; @@ -27,240 +15,63 @@ /** * @author Cyrille Le Clerc - * @see hudson.plugins.tasks.TasksPublisher + * + * @deprecated since TODO */ -public class TasksScannerPublisher extends AbstractHealthAwarePublisher { +@Deprecated +public class TasksScannerPublisher extends MavenPublisher { + private static final Logger LOGGER = Logger.getLogger(TasksScannerPublisher.class.getName()); private static final long serialVersionUID = 1L; - /** - * Coma separated high priority task identifiers - * - * @see hudson.plugins.tasks.TasksPublisher#getHigh() - */ - private String highPriorityTaskIdentifiers = ""; - /** - * @see hudson.plugins.tasks.TasksPublisher#getNormal() - */ - private String normalPriorityTaskIdentifiers = ""; - /** - * @see hudson.plugins.tasks.TasksPublisher#getLow() - */ - private String lowPriorityTaskIdentifiers = ""; - /** - * @see hudson.plugins.tasks.TasksPublisher#getIgnoreCase() - */ - private boolean ignoreCase = false; - /** - * @see hudson.plugins.tasks.TasksPublisher#getPattern() - */ - private String pattern = ""; - /** - * @see hudson.plugins.tasks.TasksPublisher#getExcludePattern() - */ - private String excludePattern = ""; - - /** - * @see hudson.plugins.tasks.TasksPublisher#getAsRegexp() - */ - private boolean asRegexp = false; - @DataBoundConstructor public TasksScannerPublisher() {} - /* - - - - - ... - - */ @Override public void process(@NonNull StepContext context, @NonNull Element mavenSpyLogsElt) throws IOException, InterruptedException { - TaskListener listener = context.get(TaskListener.class); - if (listener == null) { - LOGGER.warning("TaskListener is NULL, default to stderr"); - listener = new StreamBuildListener((OutputStream) System.err); - } - FilePath workspace = context.get(FilePath.class); - final String fileSeparatorOnAgent = XmlUtils.getFileSeparatorOnRemote(workspace); - - Run run = context.get(Run.class); - Launcher launcher = context.get(Launcher.class); - - try { - Class.forName("hudson.plugins.tasks.TasksPublisher"); - } catch (ClassNotFoundException e) { - listener.getLogger().print("[withMaven] Jenkins "); - listener.hyperlink( - "https://wiki.jenkins-ci.org/display/JENKINS/Task+Scanner+Plugin", "Task Scanner Plugin"); - listener.getLogger() - .println( - " not found, don't display results of source code scanning for 'TODO' and 'FIXME' in pipeline screen."); - return; - } - - List sourceDirectoriesPatterns = new ArrayList<>(); - for (Element executionEvent : - XmlUtils.getExecutionEvents(mavenSpyLogsElt, "ProjectSucceeded", "ProjectFailed")) { - - /* - - - - - ... - - */ - Element buildElement = XmlUtils.getUniqueChildElementOrNull(executionEvent, "project", "build"); - if (buildElement == null) { - if (LOGGER.isLoggable(Level.FINE)) - LOGGER.log( - Level.FINE, - "Ignore execution event with missing 'build' child:" + XmlUtils.toString(executionEvent)); - continue; - } - Element projectElt = XmlUtils.getUniqueChildElement(executionEvent, "project"); - MavenArtifact mavenArtifact = XmlUtils.newMavenArtifact(projectElt); - - String sourceDirectory = buildElement.getAttribute("sourceDirectory"); - - // JENKINS-44359 - if (Objects.equals(sourceDirectory, "${project.basedir}/src/main/java")) { - if (LOGGER.isLoggable(Level.FINE)) - LOGGER.log(Level.FINE, "Skip task scanning for " + XmlUtils.toString(executionEvent)); - continue; - } - - String sourceDirectoryRelativePath = XmlUtils.getPathInWorkspace(sourceDirectory, workspace); - - if (workspace.child(sourceDirectoryRelativePath).exists()) { - sourceDirectoriesPatterns.add( - sourceDirectoryRelativePath + fileSeparatorOnAgent + "**" + fileSeparatorOnAgent + "*"); - listener.getLogger() - .println("[withMaven] openTasksPublisher - Scan Tasks for Maven artifact " - + mavenArtifact.getId() + " in source directory " + sourceDirectoryRelativePath); - } else { - LOGGER.log(Level.FINE, "Skip task scanning for {0}, folder {1} does not exist", new Object[] { - mavenArtifact, sourceDirectoryRelativePath - }); - } - } - - if (sourceDirectoriesPatterns.isEmpty()) { - if (LOGGER.isLoggable(Level.FINE)) { - listener.getLogger().println("[withMaven] openTasksPublisher - no folder to scan"); - } - return; - } - - // To avoid duplicates - hudson.plugins.tasks.TasksResultAction tasksResult = - run.getAction(hudson.plugins.tasks.TasksResultAction.class); - if (tasksResult != null) { - run.removeAction(tasksResult); - } - - hudson.plugins.tasks.TasksPublisher tasksPublisher = new hudson.plugins.tasks.TasksPublisher(); - String pattern = this.pattern == null || this.pattern.isEmpty() - ? XmlUtils.join(sourceDirectoriesPatterns, ",") - : this.pattern; - tasksPublisher.setPattern(pattern); - tasksPublisher.setExcludePattern( - Optional.ofNullable(this.excludePattern).map(String::trim).orElse(null)); - - tasksPublisher.setHigh(Optional.ofNullable(this.highPriorityTaskIdentifiers) - .filter(Predicate.not(String::isEmpty)) - .orElse("FIXME")); - tasksPublisher.setNormal(Optional.ofNullable(this.normalPriorityTaskIdentifiers) - .filter(Predicate.not(String::isEmpty)) - .orElse("TODO")); - tasksPublisher.setLow(Optional.ofNullable(this.lowPriorityTaskIdentifiers) - .map(String::trim) - .orElse(null)); - tasksPublisher.setIgnoreCase(this.ignoreCase); - tasksPublisher.setAsRegexp(this.asRegexp); - - setHealthAwarePublisherAttributes(tasksPublisher); - - try { - tasksPublisher.perform(run, workspace, launcher, listener); - } catch (Exception e) { - listener.error("[withMaven] openTasksPublisher - exception scanning tasks in " + pattern + ": " + e); - LOGGER.log(Level.WARNING, "Exception scanning tasks in " + pattern, e); - throw new MavenPipelinePublisherException("openTasksPublisher", "scanning tasks in " + pattern, e); - } - } - - public String getHighPriorityTaskIdentifiers() { - return highPriorityTaskIdentifiers; + throw new AbortException( + """ + The openTasksPublisher is deprecated as is the tasks plugin and you should not use it. + Alternatively, you should rely on warningsPublisher. + Or, if continuing to use the tasks plugin for now, run it explicitly rather than expecting withMaven to run it implicitly. + """); } @DataBoundSetter - public void setHighPriorityTaskIdentifiers(String highPriorityTaskIdentifiers) { - this.highPriorityTaskIdentifiers = highPriorityTaskIdentifiers; - } - - public String getNormalPriorityTaskIdentifiers() { - return normalPriorityTaskIdentifiers; - } + public void setHealthy(String healthy) {} @DataBoundSetter - public void setNormalPriorityTaskIdentifiers(String normalPriorityTaskIdentifiers) { - this.normalPriorityTaskIdentifiers = normalPriorityTaskIdentifiers; - } - - public String getLowPriorityTaskIdentifiers() { - return lowPriorityTaskIdentifiers; - } + public void setUnHealthy(String unHealthy) {} @DataBoundSetter - public void setLowPriorityTaskIdentifiers(String lowPriorityTaskIdentifiers) { - this.lowPriorityTaskIdentifiers = lowPriorityTaskIdentifiers; - } - - public boolean isIgnoreCase() { - return ignoreCase; - } + public void setThresholdLimit(String thresholdLimit) {} @DataBoundSetter - public void setIgnoreCase(boolean ignoreCase) { - this.ignoreCase = ignoreCase; - } + public void setHighPriorityTaskIdentifiers(String highPriorityTaskIdentifiers) {} - public String getPattern() { - return pattern; - } + @DataBoundSetter + public void setNormalPriorityTaskIdentifiers(String normalPriorityTaskIdentifiers) {} @DataBoundSetter - public void setPattern(String pattern) { - this.pattern = pattern; - } + public void setLowPriorityTaskIdentifiers(String lowPriorityTaskIdentifiers) {} - public String getExcludePattern() { - return excludePattern; - } + @DataBoundSetter + public void setIgnoreCase(boolean ignoreCase) {} @DataBoundSetter - public void setExcludePattern(String excludePattern) { - this.excludePattern = excludePattern; - } + public void setPattern(String pattern) {} - public boolean isAsRegexp() { - return asRegexp; - } + @DataBoundSetter + public void setExcludePattern(String excludePattern) {} @DataBoundSetter - public void setAsRegexp(boolean asRegexp) { - this.asRegexp = asRegexp; - } + public void setAsRegexp(boolean asRegexp) {} @Symbol("openTasksPublisher") @OptionalExtension(requirePlugins = "tasks") - public static class DescriptorImpl extends AbstractHealthAwarePublisher.DescriptorImpl { + public static class DescriptorImpl extends MavenPublisher.DescriptorImpl { @NonNull @Override public String getDisplayName() { @@ -269,7 +80,7 @@ public String getDisplayName() { @Override public int ordinal() { - return 100; + return -1; } @NonNull diff --git a/pipeline-maven/src/main/java/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher.java b/pipeline-maven/src/main/java/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher.java new file mode 100644 index 000000000..1b30988fc --- /dev/null +++ b/pipeline-maven/src/main/java/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher.java @@ -0,0 +1,711 @@ +package org.jenkinsci.plugins.pipeline.maven.publishers; + +import static org.springframework.util.ReflectionUtils.findMethod; +import static org.springframework.util.ReflectionUtils.invokeMethod; +import static org.springframework.util.ReflectionUtils.makeAccessible; + +import edu.umd.cs.findbugs.annotations.NonNull; +import hudson.FilePath; +import hudson.model.BuildableItem; +import hudson.model.Item; +import hudson.model.Run; +import hudson.model.TaskListener; +import hudson.util.ComboBoxModel; +import hudson.util.FormValidation; +import hudson.util.ListBoxModel; +import io.jenkins.plugins.analysis.core.filter.ExcludeFile; +import io.jenkins.plugins.analysis.core.model.Tool; +import io.jenkins.plugins.analysis.core.steps.RecordIssuesStep; +import io.jenkins.plugins.analysis.core.util.ModelValidation; +import io.jenkins.plugins.analysis.core.util.TrendChartType; +import io.jenkins.plugins.analysis.core.util.WarningsQualityGate; +import io.jenkins.plugins.analysis.core.util.WarningsQualityGate.QualityGateType; +import io.jenkins.plugins.analysis.warnings.CheckStyle; +import io.jenkins.plugins.analysis.warnings.Cpd; +import io.jenkins.plugins.analysis.warnings.Java; +import io.jenkins.plugins.analysis.warnings.JavaDoc; +import io.jenkins.plugins.analysis.warnings.MavenConsole; +import io.jenkins.plugins.analysis.warnings.Pmd; +import io.jenkins.plugins.analysis.warnings.SpotBugs; +import io.jenkins.plugins.analysis.warnings.tasks.OpenTasks; +import io.jenkins.plugins.util.JenkinsFacade; +import io.jenkins.plugins.util.QualityGate.QualityGateCriticality; +import io.jenkins.plugins.util.ValidationUtilities; +import java.io.File; +import java.io.IOException; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +import java.util.function.BiFunction; +import java.util.function.Consumer; +import java.util.logging.Level; +import java.util.logging.Logger; +import jenkins.model.Jenkins; +import org.jenkinsci.Symbol; +import org.jenkinsci.plugins.pipeline.maven.MavenArtifact; +import org.jenkinsci.plugins.pipeline.maven.MavenPublisher; +import org.jenkinsci.plugins.pipeline.maven.MavenSpyLogProcessor; +import org.jenkinsci.plugins.pipeline.maven.Messages; +import org.jenkinsci.plugins.pipeline.maven.util.XmlUtils; +import org.jenkinsci.plugins.variant.OptionalExtension; +import org.jenkinsci.plugins.workflow.graph.FlowNode; +import org.jenkinsci.plugins.workflow.steps.StepContext; +import org.jenkinsci.plugins.workflow.steps.StepExecution; +import org.kohsuke.stapler.AncestorInPath; +import org.kohsuke.stapler.DataBoundConstructor; +import org.kohsuke.stapler.DataBoundSetter; +import org.kohsuke.stapler.QueryParameter; +import org.kohsuke.stapler.verb.POST; +import org.w3c.dom.Element; + +/** + * @author Cyrille Le Clerc + */ +public class WarningsPublisher extends MavenPublisher { + + private static final Logger LOGGER = Logger.getLogger(WarningsPublisher.class.getName()); + + private static final long serialVersionUID = 1L; + + private static final String PMD_GROUP_ID = "org.apache.maven.plugins"; + private static final String PMD_ID = "maven-pmd-plugin"; + private static final String PMD_GOAL = "pmd"; + private static final String CPD_GOAL = "cpd"; + + private static final String CHECKSTYLE_GROUP_ID = "org.apache.maven.plugins"; + private static final String CHECKSTYLE_ID = "maven-checkstyle-plugin"; + private static final String CHECKSTYLE_GOAL = "checkstyle"; + + private static final String FINDBUGS_GROUP_ID = "org.codehaus.mojo"; + private static final String FINDBUGS_ID = "findbugs-maven-plugin"; + private static final String FINDBUGS_GOAL = "findbugs"; + + private static final String SPOTBUGS_GROUP_ID = "com.github.spotbugs"; + private static final String SPOTBUGS_ID = "spotbugs-maven-plugin"; + private static final String SPOTBUGS_GOAL = "spotbugs"; + + private String sourceCodeEncoding = "UTF-8"; + private boolean isEnabledForFailure = true; + private boolean isBlameDisabled = true; + private TrendChartType trendChartType = TrendChartType.TOOLS_ONLY; + private int qualityGateThreshold = 1; + private QualityGateType qualityGateType = QualityGateType.NEW; + private QualityGateCriticality qualityGateCriticality = QualityGateCriticality.UNSTABLE; + private String javaIgnorePatterns; + private String highPriorityTaskIdentifiers = "FIXME"; + private String normalPriorityTaskIdentifiers = "TODO"; + private String tasksIncludePattern = "**/*.java"; + private String tasksExcludePattern = "**/target/**"; + + @DataBoundConstructor + public WarningsPublisher() {} + + public String getSourceCodeEncoding() { + return sourceCodeEncoding; + } + + @DataBoundSetter + public void setSourceCodeEncoding(final String sourceCodeEncoding) { + this.sourceCodeEncoding = sourceCodeEncoding; + } + + public boolean isEnabledForFailure() { + return isEnabledForFailure; + } + + @DataBoundSetter + public void setEnabledForFailure(final boolean enabledForFailure) { + isEnabledForFailure = enabledForFailure; + } + + public boolean isSkipBlames() { + return isBlameDisabled; + } + + @DataBoundSetter + public void setSkipBlames(final boolean skipBlames) { + isBlameDisabled = skipBlames; + } + + public TrendChartType getTrendChartType() { + return trendChartType; + } + + @DataBoundSetter + public void setTrendChartType(final TrendChartType trendChartType) { + this.trendChartType = trendChartType; + } + + public int getQualityGateThreshold() { + return qualityGateThreshold; + } + + @DataBoundSetter + public void setQualityGateThreshold(int qualityGateThreshold) { + this.qualityGateThreshold = qualityGateThreshold; + } + + public QualityGateType getQualityGateType() { + return qualityGateType; + } + + @DataBoundSetter + public void setQualityGateType(QualityGateType qualityGateType) { + this.qualityGateType = qualityGateType; + } + + public QualityGateCriticality getQualityGateCriticality() { + return qualityGateCriticality; + } + + @DataBoundSetter + public void setQualityGateCriticality(QualityGateCriticality qualityGateCriticality) { + this.qualityGateCriticality = qualityGateCriticality; + } + + public String getJavaIgnorePatterns() { + return javaIgnorePatterns; + } + + @DataBoundSetter + public void setJavaIgnorePatterns(String javaIgnorePatterns) { + this.javaIgnorePatterns = + javaIgnorePatterns != null && !javaIgnorePatterns.isEmpty() ? javaIgnorePatterns : null; + } + + public String getHighPriorityTaskIdentifiers() { + return highPriorityTaskIdentifiers; + } + + @DataBoundSetter + public void setHighPriorityTaskIdentifiers(String highPriorityTaskIdentifiers) { + this.highPriorityTaskIdentifiers = highPriorityTaskIdentifiers; + } + + public String getNormalPriorityTaskIdentifiers() { + return normalPriorityTaskIdentifiers; + } + + @DataBoundSetter + public void setNormalPriorityTaskIdentifiers(String normalPriorityTaskIdentifiers) { + this.normalPriorityTaskIdentifiers = normalPriorityTaskIdentifiers; + } + + public String getTasksIncludePattern() { + return tasksIncludePattern; + } + + @DataBoundSetter + public void setTasksIncludePattern(String tasksIncludePattern) { + this.tasksIncludePattern = tasksIncludePattern; + } + + public String getTasksExcludePattern() { + return tasksExcludePattern; + } + + @DataBoundSetter + public void setTasksExcludePattern(String tasksExcludePattern) { + this.tasksExcludePattern = tasksExcludePattern; + } + + @Override + public void process(@NonNull StepContext context, @NonNull Element mavenSpyLogsElt) + throws IOException, InterruptedException { + + TaskListener listener = context.get(TaskListener.class); + + try { + Class.forName("org.jenkinsci.plugins.workflow.steps.StepExecution"); + } catch (ClassNotFoundException e) { + listener.getLogger().print("[withMaven] Jenkins "); + listener.hyperlink( + "https://wiki.jenkins.io/display/JENKINS/Warnings+Next+Generation+Plugin", "Warnings NG Plugin"); + listener.getLogger().print(" not found, do not display static analysis reports in pipeline screen."); + return; + } + + perform(List.of(maven(context)), context, listener, "Maven console", step -> {}); + perform(java(context), context, listener, "Java and JavaDoc", step -> { + if (javaIgnorePatterns != null && !javaIgnorePatterns.isEmpty()) { + step.setFilters(List.of(new ExcludeFile(javaIgnorePatterns))); + } + }); + perform(List.of(taskScanner(context)), context, listener, "Open tasks", step -> {}); + List pmdEvents = XmlUtils.getExecutionEventsByPlugin( + mavenSpyLogsElt, PMD_GROUP_ID, PMD_ID, PMD_GOAL, "MojoSucceeded", "MojoFailed"); + if (pmdEvents.isEmpty()) { + if (LOGGER.isLoggable(Level.FINE)) { + listener.getLogger() + .println("[withMaven] warningsPublisher - No " + PMD_GROUP_ID + ":" + PMD_ID + ":" + PMD_GOAL + + " execution found"); + } + } else { + processPmd(pmdEvents, context, listener); + } + List cpdEvents = XmlUtils.getExecutionEventsByPlugin( + mavenSpyLogsElt, PMD_GROUP_ID, PMD_ID, CPD_GOAL, "MojoSucceeded", "MojoFailed"); + if (cpdEvents.isEmpty()) { + if (LOGGER.isLoggable(Level.FINE)) { + listener.getLogger() + .println("[withMaven] warningsPublisher - No " + PMD_GROUP_ID + ":" + PMD_ID + ":" + CPD_GOAL + + " execution found"); + } + } else { + processCpd(cpdEvents, context, listener); + } + List checkstyleEvents = XmlUtils.getExecutionEventsByPlugin( + mavenSpyLogsElt, CHECKSTYLE_GROUP_ID, CHECKSTYLE_ID, CHECKSTYLE_GOAL, "MojoSucceeded", "MojoFailed"); + if (checkstyleEvents.isEmpty()) { + if (LOGGER.isLoggable(Level.FINE)) { + listener.getLogger() + .println("[withMaven] warningsPublisher - No " + CHECKSTYLE_GROUP_ID + ":" + CHECKSTYLE_ID + ":" + + CHECKSTYLE_GOAL + " execution found"); + } + } else { + processCheckstyle(checkstyleEvents, context, listener); + } + List findbugsEvents = XmlUtils.getExecutionEventsByPlugin( + mavenSpyLogsElt, FINDBUGS_GROUP_ID, FINDBUGS_ID, FINDBUGS_GOAL, "MojoSucceeded", "MojoFailed"); + if (findbugsEvents.isEmpty()) { + if (LOGGER.isLoggable(Level.FINE)) { + listener.getLogger() + .println("[withMaven] warningsPublisher - No " + FINDBUGS_GROUP_ID + ":" + FINDBUGS_ID + ":" + + FINDBUGS_GOAL + " execution found"); + } + } else { + processFindBugs(findbugsEvents, context, listener); + } + List spotbugsEvents = XmlUtils.getExecutionEventsByPlugin( + mavenSpyLogsElt, SPOTBUGS_GROUP_ID, SPOTBUGS_ID, SPOTBUGS_GOAL, "MojoSucceeded", "MojoFailed"); + if (spotbugsEvents.isEmpty()) { + if (LOGGER.isLoggable(Level.FINE)) { + listener.getLogger() + .println("[withMaven] warningsPublisher - No " + SPOTBUGS_GROUP_ID + ":" + SPOTBUGS_ID + ":" + + SPOTBUGS_GOAL + " execution found"); + } + } else { + processSpotBugs(spotbugsEvents, context, listener); + } + } + + private void processPmd(List events, StepContext context, TaskListener listener) + throws IOException, InterruptedException { + FilePath workspace = context.get(FilePath.class); + List tools = new ArrayList<>(); + for (Element event : events) { + ResultFile result = extractResultFile( + event, + "targetDirectory", + null, + (dir, file) -> dir + File.separator + "pmd.xml", + workspace, + listener); + if (result != null) { + tools.add( + pmd(context, result.getMavenArtifact(), result.getPluginInvocation(), result.getResultFile())); + } + } + perform(tools, context, listener, "pmd", this::configureQualityGate); + } + + private void processCpd(List events, StepContext context, TaskListener listener) + throws IOException, InterruptedException { + FilePath workspace = context.get(FilePath.class); + List tools = new ArrayList<>(); + for (Element event : events) { + ResultFile result = extractResultFile( + event, + "targetDirectory", + null, + (dir, file) -> dir + File.separator + "cpd.xml", + workspace, + listener); + if (result != null) { + tools.add( + cpd(context, result.getMavenArtifact(), result.getPluginInvocation(), result.getResultFile())); + } + } + perform(tools, context, listener, "cpd", this::configureQualityGate); + } + + private void processCheckstyle(List events, StepContext context, TaskListener listener) + throws IOException, InterruptedException { + FilePath workspace = context.get(FilePath.class); + List tools = new ArrayList<>(); + for (Element event : events) { + ResultFile result = extractResultFile( + event, + null, + "outputFile", + (dir, file) -> file.contains("${checkstyle.output.file}") + ? file.replace( + "${checkstyle.output.file}", "${project.build.directory}/checkstyle-result.xml") + : file, + workspace, + listener); + if (result != null) { + tools.add(checkstyle( + context, result.getMavenArtifact(), result.getPluginInvocation(), result.getResultFile())); + } + } + perform(tools, context, listener, "checkstyle", this::configureQualityGate); + } + + private void processFindBugs(List events, StepContext context, TaskListener listener) + throws IOException, InterruptedException { + FilePath workspace = context.get(FilePath.class); + List tools = new ArrayList<>(); + for (Element event : events) { + ResultFile result = extractResultFile( + event, + "xmlOutputDirectory", + null, + (dir, file) -> dir + File.separator + "findbugsXml.xml", + workspace, + listener); + if (result != null) { + tools.add(spotBugs( + context, result.getMavenArtifact(), result.getPluginInvocation(), result.getResultFile())); + } + } + perform(tools, context, listener, "findbugs", this::configureQualityGate); + } + + private void processSpotBugs(List events, StepContext context, TaskListener listener) + throws IOException, InterruptedException { + FilePath workspace = context.get(FilePath.class); + List tools = new ArrayList<>(); + for (Element event : events) { + ResultFile result = extractResultFile( + event, + "spotbugsXmlOutputDirectory", + "spotbugsXmlOutputFilename", + (dir, file) -> + dir + File.separator + file.replace("${spotbugs.outputXmlFilename}", "spotbugsXml.xml"), + workspace, + listener); + if (result != null) { + tools.add(spotBugs( + context, result.getMavenArtifact(), result.getPluginInvocation(), result.getResultFile())); + } + } + perform(tools, context, listener, "spotbugs", this::configureQualityGate); + } + + private void perform( + List tools, + StepContext context, + TaskListener listener, + String kind, + Consumer stepConfigurer) { + + if (tools == null || tools.isEmpty()) { + return; + } + + listener.getLogger().println("[withMaven] warningsPublisher - Processing " + kind + " warnings"); + RecordIssuesStep step = new RecordIssuesStep(); + step.setTools(tools); + stepConfigurer.accept(step); + + try { + StepExecution stepExecution = step.start(context); + Method method = findMethod(stepExecution.getClass(), "run"); + if (method != null) { + makeAccessible(method); + invokeMethod(method, stepExecution); + } else { + listener.error("[withMaven] warningsPublisher - error archiving " + kind + + " warnings results: RecordIssuesStep.Execution.run() method not found"); + LOGGER.log( + Level.WARNING, + "Error processing " + kind + + " warnings results: RecordIssuesStep.Execution.run() method not found"); + throw new MavenPipelinePublisherException( + "warningsPublisher", + "archiving " + kind + " warnings results", + new RuntimeException("RecordIssuesStep.Execution.run() method not found")); + } + } catch (Exception e) { + listener.error("[withMaven] warningsPublisher - exception archiving " + kind + " warnings results: " + e); + LOGGER.log(Level.WARNING, "Exception processing " + kind + " warnings results", e); + throw new MavenPipelinePublisherException( + "warningsPublisher", "archiving " + kind + " warnings results", e); + } + } + + private Tool maven(StepContext context) throws IOException, InterruptedException { + MavenConsole tool = new MavenConsole(); + String name = computeName(tool, context); + tool.setId(toId(name)); + tool.setName(name); + return tool; + } + + private List java(StepContext context) throws IOException, InterruptedException { + Java java = new Java(); + String name = computeName(java, context); + java.setId(toId(name)); + java.setName(name); + JavaDoc javadoc = new JavaDoc(); + name = computeName(javadoc, context); + javadoc.setId(toId(name)); + javadoc.setName(name); + return List.of(java, javadoc); + } + + private Tool taskScanner(StepContext context) throws IOException, InterruptedException { + OpenTasks tool = new OpenTasks(); + String name = computeName(tool, context); + tool.setId(toId(name)); + tool.setName(name); + tool.setIncludePattern(tasksIncludePattern); + tool.setExcludePattern(tasksExcludePattern); + tool.setHighTags(highPriorityTaskIdentifiers); + tool.setNormalTags(normalPriorityTaskIdentifiers); + return tool; + } + + private Tool pmd( + StepContext context, + MavenArtifact mavenArtifact, + MavenSpyLogProcessor.PluginInvocation pluginInvocation, + String reportFile) + throws IOException, InterruptedException { + Pmd tool = new Pmd(); + String name = computeName(tool, context) + " " + mavenArtifact.getId() + " " + pluginInvocation.getId(); + tool.setId(toId(name)); + tool.setName(name); + tool.setPattern(reportFile); + return tool; + } + + private Tool cpd( + StepContext context, + MavenArtifact mavenArtifact, + MavenSpyLogProcessor.PluginInvocation pluginInvocation, + String reportFile) + throws IOException, InterruptedException { + Cpd tool = new Cpd(); + String name = computeName(tool, context) + " " + mavenArtifact.getId() + " " + pluginInvocation.getId(); + tool.setId(toId(name)); + tool.setName(name); + tool.setPattern(reportFile); + return tool; + } + + private Tool checkstyle( + StepContext context, + MavenArtifact mavenArtifact, + MavenSpyLogProcessor.PluginInvocation pluginInvocation, + String reportFile) + throws IOException, InterruptedException { + CheckStyle tool = new CheckStyle(); + String name = computeName(tool, context) + " " + mavenArtifact.getId() + " " + pluginInvocation.getId(); + tool.setId(toId(name)); + tool.setName(name); + tool.setPattern(reportFile); + return tool; + } + + private Tool spotBugs( + StepContext context, + MavenArtifact mavenArtifact, + MavenSpyLogProcessor.PluginInvocation pluginInvocation, + String reportFile) + throws IOException, InterruptedException { + SpotBugs tool = new SpotBugs(); + String name = computeName(tool, context) + " " + mavenArtifact.getId() + " " + pluginInvocation.getId(); + tool.setId(toId(name)); + tool.setName(name); + tool.setPattern(reportFile); + return tool; + } + + private void configureQualityGate(RecordIssuesStep step) { + step.setEnabledForFailure(isEnabledForFailure); + step.setSourceCodeEncoding(sourceCodeEncoding); + step.setSkipBlames(isBlameDisabled); + step.setTrendChartType(trendChartType); + step.setQualityGates( + List.of(new WarningsQualityGate(qualityGateThreshold, qualityGateType, qualityGateCriticality))); + } + + private ResultFile extractResultFile( + Element event, + String reportDirectoryAttribute, + String reportFileAttribute, + BiFunction reportFilepathBuilder, + FilePath workspace, + TaskListener listener) { + String eventType = event.getAttribute("type"); + if (!eventType.equals("MojoSucceeded") && !eventType.equals("MojoFailed")) { + return null; + } + + Element pluginElt = XmlUtils.getUniqueChildElement(event, "plugin"); + Element directoryElt = XmlUtils.getUniqueChildElementOrNull(pluginElt, reportDirectoryAttribute); + Element fileElt = XmlUtils.getUniqueChildElementOrNull(pluginElt, reportFileAttribute); + Element projectElt = XmlUtils.getUniqueChildElement(event, "project"); + MavenArtifact mavenArtifact = XmlUtils.newMavenArtifact(projectElt); + MavenSpyLogProcessor.PluginInvocation pluginInvocation = XmlUtils.newPluginInvocation(pluginElt); + + if (reportDirectoryAttribute != null && !reportDirectoryAttribute.isEmpty() && directoryElt == null) { + listener.getLogger() + .println("[withMaven] warningsPublisher - No <" + reportDirectoryAttribute + + "> element found for in " + XmlUtils.toString(event)); + return null; + } + if (reportFileAttribute != null && !reportFileAttribute.isEmpty() && fileElt == null) { + listener.getLogger() + .println("[withMaven] warningsPublisher - No <" + reportFileAttribute + + "> element found for in " + XmlUtils.toString(event)); + return null; + } + + String output = reportFilepathBuilder.apply( + Optional.ofNullable(directoryElt) + .map(Element::getTextContent) + .map(String::trim) + .orElse(null), + Optional.ofNullable(fileElt) + .map(Element::getTextContent) + .map(String::trim) + .orElse(null)); + output = XmlUtils.resolveMavenPlaceholders(output, projectElt); + if (output == null) { + listener.getLogger() + .println( + "[withMaven] could not resolve placeholder '${project.build.directory}' or '${project.reporting.outputDirectory}' or '${basedir}' in " + + XmlUtils.toString(event)); + return null; + } + + return new ResultFile(mavenArtifact, pluginInvocation, XmlUtils.getPathInWorkspace(output, workspace)); + } + + private String computeName(Tool tool, StepContext context) throws IOException, InterruptedException { + return tool.getDescriptor().getName() + " " + context.get(Run.class).toString() + " " + + context.get(FlowNode.class).getId(); + } + + private String toId(String name) { + return name.replaceAll("[^\\p{Alnum}-_.]", "_"); + } + + private static class ResultFile { + + private MavenArtifact mavenArtifact; + private MavenSpyLogProcessor.PluginInvocation pluginInvocation; + private String resultFile; + + public ResultFile( + MavenArtifact mavenArtifact, + MavenSpyLogProcessor.PluginInvocation pluginInvocation, + String resultFile) { + this.mavenArtifact = mavenArtifact; + this.pluginInvocation = pluginInvocation; + this.resultFile = resultFile; + } + + public MavenArtifact getMavenArtifact() { + return mavenArtifact; + } + + public MavenSpyLogProcessor.PluginInvocation getPluginInvocation() { + return pluginInvocation; + } + + public String getResultFile() { + return resultFile; + } + } + + @Symbol("warningsPublisher") + @OptionalExtension(requirePlugins = "warnings-ng") + public static class DescriptorImpl extends MavenPublisher.DescriptorImpl { + private static final ValidationUtilities VALIDATION_UTILITIES = new ValidationUtilities(); + private static final JenkinsFacade JENKINS = new JenkinsFacade(); + private final ModelValidation model = new ModelValidation(); + + @NonNull + @Override + public String getDisplayName() { + return Messages.publisher_warnings_description(); + } + + @Override + public int ordinal() { + return 10; + } + + @NonNull + @Override + public String getSkipFileName() { + return ".skip-publish-warnings"; + } + + @POST + public ComboBoxModel doFillSourceCodeEncodingItems(@AncestorInPath final BuildableItem project) { + if (JENKINS.hasPermission(Item.READ, project)) { + return VALIDATION_UTILITIES.getAllCharsets(); + } + return new ComboBoxModel(); + } + + @POST + public FormValidation doCheckSourceCodeEncoding( + @AncestorInPath final BuildableItem project, @QueryParameter final String sourceCodeEncoding) { + if (!JENKINS.hasPermission(Item.CONFIGURE, project)) { + return FormValidation.ok(); + } + return VALIDATION_UTILITIES.validateCharset(sourceCodeEncoding); + } + + @POST + public ListBoxModel doFillTrendChartTypeItems() { + if (JENKINS.hasPermission(Jenkins.READ)) { + return model.getAllTrendChartTypes(); + } + return new ListBoxModel(); + } + + @POST + public ListBoxModel doFillQualityGateTypeItems() { + var model = new ListBoxModel(); + if (JENKINS.hasPermission(Jenkins.READ)) { + for (QualityGateType qualityGateType : QualityGateType.values()) { + model.add(qualityGateType.getDisplayName(), qualityGateType.name()); + } + } + return model; + } + + @POST + public ListBoxModel doFillQualityGateCriticalityItems(@AncestorInPath final BuildableItem project) { + if (JENKINS.hasPermission(Jenkins.READ)) { + var options = new ListBoxModel(); + options.add(Messages.QualityGate_UnstableStage(), QualityGateCriticality.NOTE.name()); + options.add(Messages.QualityGate_UnstableRun(), QualityGateCriticality.UNSTABLE.name()); + options.add(Messages.QualityGate_FailureStage(), QualityGateCriticality.ERROR.name()); + options.add(Messages.QualityGate_FailureRun(), QualityGateCriticality.FAILURE.name()); + return options; + } + return new ListBoxModel(); + } + + @POST + public FormValidation doCheckQualityGateThreshold( + @AncestorInPath final BuildableItem project, @QueryParameter final int qualityGateThreshold) { + if (!JENKINS.hasPermission(Item.CONFIGURE, project)) { + return FormValidation.ok(); + } + if (qualityGateThreshold > 0) { + return FormValidation.ok(); + } + return FormValidation.error(Messages.FieldValidator_Error_NegativeThreshold()); + } + } +} diff --git a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/Messages.properties b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/Messages.properties index 375411929..1a6e24c15 100644 --- a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/Messages.properties +++ b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/Messages.properties @@ -13,6 +13,7 @@ publisher.maven_linker.description=Maven Linker Publisher publisher.pipeline_graph.description=Pipeline Graph Publisher publisher.spotbugs_analysis.description=SpotBugs Publisher publisher.tasks_scanner.description=Open Task Scanner Publisher +publisher.warnings.description=Warnings Publisher publisher_strategy.explicit.description=Explicit publisher_strategy.implicit.description=Implicit report.maven.description=Maven @@ -20,4 +21,10 @@ settings.default_maven.description=Use system default Maven settings.default_jdk.description=Use system default JDK settings.default_settings.description=Use system default settings or file path step.with_maven.description=Provide Maven environment -trigger.workflow_job_dependency.description=Build whenever a SNAPSHOT dependency is built \ No newline at end of file +trigger.workflow_job_dependency.description=Build whenever a SNAPSHOT dependency is built + +FieldValidator.Error.NegativeThreshold=Threshold must be an integer value greater 0. +QualityGate.FailureRun=Fail the step and the build +QualityGate.FailureStage=Fail the step but not the build +QualityGate.UnstableRun=Mark the step and the build as unstable +QualityGate.UnstableStage=Mark the step as unstable diff --git a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/Messages_fr.properties b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/Messages_fr.properties index 25b36d3ef..0e6713ba5 100644 --- a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/Messages_fr.properties +++ b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/Messages_fr.properties @@ -13,6 +13,7 @@ publisher.maven_linker.description=Maven Linker Publisher publisher.pipeline_graph.description=Pipeline Graph Publisher publisher.spotbugs_analysis.description=SpotBugs Publisher publisher.tasks_scanner.description=Open Task Scanner Publisher +publisher.warnings.description=Warnings Publisher publisher_strategy.explicit.description=Explicite publisher_strategy.implicit.description=Implicite report.maven.description=Maven @@ -20,4 +21,10 @@ settings.default_maven.description=Utiliser l''installation Maven par d settings.default_jdk.description=Utiliser l''installation JDK par d�faut settings.default_settings.description=Utiliser les param�tres par d�faut ou indiquer un fichier step.with_maven.description=Fournir un environnement Maven -trigger.workflow_job_dependency.description=Construire d�s qu''une d�pendance SNAPSHOT est modifi�e \ No newline at end of file +trigger.workflow_job_dependency.description=Construire d�s qu''une d�pendance SNAPSHOT est modifi�e + +FieldValidator.Error.NegativeThreshold=Le seuil doit �tre une valeur positive +QualityGate.FailureRun=Faire �chouer l''�tape et la construction +QualityGate.FailureStage=Faire �chouer l''�tape mais pas la construction +QualityGate.UnstableRun=Marquer l''�tape et la construction instables +QualityGate.UnstableStage=Marquer l''�tape instable diff --git a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/WithMavenStep/config.jelly b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/WithMavenStep/config.jelly index c2092908c..0ecd4c841 100644 --- a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/WithMavenStep/config.jelly +++ b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/WithMavenStep/config.jelly @@ -49,8 +49,8 @@ THE SOFTWARE. - - + + diff --git a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/WithMavenStep/config.properties b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/WithMavenStep/config.properties index ce03a0308..0e997e1a3 100644 --- a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/WithMavenStep/config.properties +++ b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/WithMavenStep/config.properties @@ -6,6 +6,7 @@ maven_settings_file_path=Maven Settings File Path global_maven_settings_config=Global Maven Settings Config global_maven_settings_file_path=Global Maven Settings File Path maven_jvm_opts=Maven JVM Opts +description.maven_jvm_opts=Defaults to -Dmaven.test.failure.ignore -Dspotbugs.failOnError=false -Dcheckstyle.failOnViolation=false -Dcheckstyle.failsOnError=false -Dpmd.failOnViolation=false to avoid build interruption and let Jenkins records all problems. maven_traceability=Maven Traceability maven_local_repository=Maven Local Repository publisher_strategy=Publisher Strategy diff --git a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/WithMavenStep/config_fr.properties b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/WithMavenStep/config_fr.properties index db5dbc984..0d272ea68 100644 --- a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/WithMavenStep/config_fr.properties +++ b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/WithMavenStep/config_fr.properties @@ -6,6 +6,7 @@ maven_settings_file_path=Fichier contenant les param global_maven_settings_config=Param�tres de configuration globaux Maven global_maven_settings_file_path=Fichier contenant les param�tres globaux Maven maven_jvm_opts=Options de la JVM Maven +description.maven_jvm_opts=Par d�faut -Dmaven.test.failure.ignore -Dspotbugs.failOnError=false -Dcheckstyle.failOnViolation=false -Dcheckstyle.failsOnError=false -Dpmd.failOnViolation=false pour �viter toute interruption de la construction et laisser Jenkins enregistrer les probl�mes. maven_traceability=Tra�abilit� maven_local_repository=D�p�t local Maven publisher_strategy=Strat�gie pour les publishers diff --git a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/FindbugsAnalysisPublisher/config.jelly b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/FindbugsAnalysisPublisher/config.jelly index 4e37e363f..a4aa90683 100644 --- a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/FindbugsAnalysisPublisher/config.jelly +++ b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/FindbugsAnalysisPublisher/config.jelly @@ -28,5 +28,4 @@ THE SOFTWARE. - diff --git a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/FindbugsAnalysisPublisher/help.html b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/FindbugsAnalysisPublisher/help.html index 139f9e022..f3c92f3d4 100644 --- a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/FindbugsAnalysisPublisher/help.html +++ b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/FindbugsAnalysisPublisher/help.html @@ -1,6 +1,4 @@

- Publish FindBugs reports generated by "org.codehaus.mojo:findbugs-maven-plugin:findbugs".
- - FindBugs results are by default published if the - Jenkins FindBugs Plugin is installed. + The findbugsPublisher is deprecated as is the findbugs plugin and you should not use it. + Alternatively, you should rely on warningsPublisher.
\ No newline at end of file diff --git a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/FindbugsAnalysisPublisher/help_fr.html b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/FindbugsAnalysisPublisher/help_fr.html index 7ecf3d6a5..6c1617b86 100644 --- a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/FindbugsAnalysisPublisher/help_fr.html +++ b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/FindbugsAnalysisPublisher/help_fr.html @@ -1,6 +1,4 @@
- Publier les rapports FindBugs générés par le plugin Maven "org.codehaus.mojo:findbugs-maven-plugin:findbugs".
- - Les rapports FindBugs sont publiés par défaut si le plugin - Jenkins FindBugs est installé. + Le publisher findbugsPublisher est déprécié, tout comme le findbugs Jacoco, et ne devrait plus être utilisé. + L'alternative est le publisher warningsPublisher.
\ No newline at end of file diff --git a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/InvokerRunsPublisher/help.html b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/InvokerRunsPublisher/help.html index f368cd2b7..0660a391f 100644 --- a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/InvokerRunsPublisher/help.html +++ b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/InvokerRunsPublisher/help.html @@ -2,5 +2,6 @@ Publish Invoker reports generated by "org.apache.maven.plugins:maven-invoker-plugin:run".
Invoker results are by default published if the - Jenkins Maven Invoker Plugin is installed. + Jenkins JUnit Plugin, or the + Jenkins Maven Invoker Plugin, is installed. \ No newline at end of file diff --git a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/JacocoReportPublisher/help.html b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/JacocoReportPublisher/help.html index d55bd6923..ce618ed9b 100644 --- a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/JacocoReportPublisher/help.html +++ b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/JacocoReportPublisher/help.html @@ -1,5 +1,4 @@
- Publish JaCoCo Java Code Coverage Library reports, if found.
- - Test results are by default published if the Jenkins JaCoCo Plugin is installed. + The jacocoPublisher is deprecated as is the Jacoco plugin and you should not use it. + Alternatively, you should rely on CoveragePublisher.
\ No newline at end of file diff --git a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/JacocoReportPublisher/help_fr.html b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/JacocoReportPublisher/help_fr.html index 81dd02e7b..c22632456 100644 --- a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/JacocoReportPublisher/help_fr.html +++ b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/JacocoReportPublisher/help_fr.html @@ -1,5 +1,4 @@
- Publier les rapports JaCoCo Java Code Coverage, s'ils existent.
- - Ces rapports sont publiés par défaut si le plugin Jenkins JaCoCo est installé. + Le publisher jacocoPublisher est déprécié, tout comme le plugin Jacoco, et ne devrait plus être utilisé. + L'alternative est le publisher CoveragePublisher.
\ No newline at end of file diff --git a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/SpotBugsAnalysisPublisher/config.jelly b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/SpotBugsAnalysisPublisher/config.jelly index 4e37e363f..a4aa90683 100644 --- a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/SpotBugsAnalysisPublisher/config.jelly +++ b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/SpotBugsAnalysisPublisher/config.jelly @@ -28,5 +28,4 @@ THE SOFTWARE. - diff --git a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/SpotBugsAnalysisPublisher/help.html b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/SpotBugsAnalysisPublisher/help.html index 144337f62..9a25f7f43 100644 --- a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/SpotBugsAnalysisPublisher/help.html +++ b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/SpotBugsAnalysisPublisher/help.html @@ -1,6 +1,4 @@
- Publish SpotBugs reports generated by "com.github.spotbugs:spotbugs-maven-plugin:spotbugs".
- - SpotBugs results are by default published if the - Jenkins FindBugs Plugin is installed. + The spotbugsPublisher is deprecated as is the findbugs plugin and you should not use it. + Alternatively, you should rely on warningsPublisher.
\ No newline at end of file diff --git a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/SpotBugsAnalysisPublisher/help_fr.html b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/SpotBugsAnalysisPublisher/help_fr.html index 8a1c195af..a8a9057a4 100644 --- a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/SpotBugsAnalysisPublisher/help_fr.html +++ b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/SpotBugsAnalysisPublisher/help_fr.html @@ -1,6 +1,4 @@
- Publier les rapports SpotBugs générés par le plugin Maven "com.github.spotbugs:spotbugs-maven-plugin:spotbugs".
- - Ces rapports sont publiés par défaut si le plugin - Jenkins FindBugs est installé. + Le publisher spotbugsPublisher est déprécié, tout comme le findbugs Jacoco, et ne devrait plus être utilisé. + L'alternative est le publisher warningsPublisher.
\ No newline at end of file diff --git a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/TasksScannerPublisher/config.jelly b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/TasksScannerPublisher/config.jelly index 0ef4a903c..74db1efa9 100644 --- a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/TasksScannerPublisher/config.jelly +++ b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/TasksScannerPublisher/config.jelly @@ -28,33 +28,4 @@ THE SOFTWARE. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/TasksScannerPublisher/config.properties b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/TasksScannerPublisher/config.properties deleted file mode 100644 index 954dcc121..000000000 --- a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/TasksScannerPublisher/config.properties +++ /dev/null @@ -1,9 +0,0 @@ -source_code=Source Code -pattern=Pattern -exclude_pattern=Exclude Pattern -task_identifiers=Task Identifiers -high_priority_tasks=High Priority Tasks -normal_priority_tasks=Normal Priority Tasks -low_priority_tasks=Low Priority Tasks -ignore_case=Ignore Case -as_regexp=As Regexp diff --git a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/TasksScannerPublisher/config_fr.properties b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/TasksScannerPublisher/config_fr.properties deleted file mode 100644 index e3e5e5c3c..000000000 --- a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/TasksScannerPublisher/config_fr.properties +++ /dev/null @@ -1,9 +0,0 @@ -source_code=Code source -pattern=Motif -exclude_pattern=Motif d''exclusion -task_identifiers=Identifiants de t�che -high_priority_tasks=T�ches prioritaires -normal_priority_tasks=T�ches de priorit� normale -low_priority_tasks=T�ches de basse priorit� -ignore_case=Ignorer la case -as_regexp=Il s''agit d''une expression r�guli�re diff --git a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/TasksScannerPublisher/help-asRegexp.html b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/TasksScannerPublisher/help-asRegexp.html deleted file mode 100644 index 16f640995..000000000 --- a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/TasksScannerPublisher/help-asRegexp.html +++ /dev/null @@ -1,3 +0,0 @@ -
- Use task identifiers as regular expressions. -
\ No newline at end of file diff --git a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/TasksScannerPublisher/help-asRegexp_fr.html b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/TasksScannerPublisher/help-asRegexp_fr.html deleted file mode 100644 index 1c127e245..000000000 --- a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/TasksScannerPublisher/help-asRegexp_fr.html +++ /dev/null @@ -1,3 +0,0 @@ -
- Considérer les identifiants de tâche comme des expressions régulières. -
\ No newline at end of file diff --git a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/TasksScannerPublisher/help-ignoreCase.html b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/TasksScannerPublisher/help-ignoreCase.html deleted file mode 100644 index 0a2afe500..000000000 --- a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/TasksScannerPublisher/help-ignoreCase.html +++ /dev/null @@ -1,3 +0,0 @@ -
- Ignore case when scanning task identifiers. -
\ No newline at end of file diff --git a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/TasksScannerPublisher/help-ignoreCase_fr.html b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/TasksScannerPublisher/help-ignoreCase_fr.html deleted file mode 100644 index b9b77e8a9..000000000 --- a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/TasksScannerPublisher/help-ignoreCase_fr.html +++ /dev/null @@ -1,3 +0,0 @@ -
- Ignorer la case lors de la détection des identifiants de tâche. -
\ No newline at end of file diff --git a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/TasksScannerPublisher/help-lowPriorityTaskIdentifiers.html b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/TasksScannerPublisher/help-lowPriorityTaskIdentifiers.html deleted file mode 100644 index 5737e7f2f..000000000 --- a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/TasksScannerPublisher/help-lowPriorityTaskIdentifiers.html +++ /dev/null @@ -1,3 +0,0 @@ -
- Coma separated list of low priority task identifiers. -
\ No newline at end of file diff --git a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/TasksScannerPublisher/help-lowPriorityTaskIdentifiers_fr.html b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/TasksScannerPublisher/help-lowPriorityTaskIdentifiers_fr.html deleted file mode 100644 index 1b4511932..000000000 --- a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/TasksScannerPublisher/help-lowPriorityTaskIdentifiers_fr.html +++ /dev/null @@ -1,3 +0,0 @@ -
- Liste, séparée par des virgules, des identifiants des tâches de priorité basse. -
\ No newline at end of file diff --git a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/TasksScannerPublisher/help-pattern_fr.html b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/TasksScannerPublisher/help-pattern_fr.html deleted file mode 100644 index 1d8ad55bd..000000000 --- a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/TasksScannerPublisher/help-pattern_fr.html +++ /dev/null @@ -1,3 +0,0 @@ -
- Motif Ant style des fichiers source à scanner. -
\ No newline at end of file diff --git a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/TasksScannerPublisher/help.html b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/TasksScannerPublisher/help.html index 29e5c31d3..729b89831 100644 --- a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/TasksScannerPublisher/help.html +++ b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/TasksScannerPublisher/help.html @@ -1,9 +1,4 @@
- Publish Open Task Scanner reports.
- - Open Task Scanner reports are by default published if the - Jenkins Task Scanner Plugin is installed.
- - The default setup is to look in Java source code for "FIXME" comments as high priority tasks - and for "TODO" comments as normal priority tasks. + The openTasksPublisher is deprecated as is the tasks plugin and you should not use it. + Alternatively, you should rely on warningsPublisher.
\ No newline at end of file diff --git a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/TasksScannerPublisher/help_fr.html b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/TasksScannerPublisher/help_fr.html index d3b113a77..b0014d6d0 100644 --- a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/TasksScannerPublisher/help_fr.html +++ b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/TasksScannerPublisher/help_fr.html @@ -1,9 +1,4 @@
- Publier les rapports du Scanner Open Task.
- - Ces rapports sont publiés par défaut si le plugin - Jenkins Task Scanner Plugin est installé.
- - Le paramètrage par défaut remonte tous les commentaires "FIXME" dans le code Java comme tâches de priorité haute - et tous les commentaires "TODO" comme tâches de priorité normale. + Le publisher openTasksPublisher est déprécié, tout comme le tasks Jacoco, et ne devrait plus être utilisé. + L'alternative est le publisher warningsPublisher.
\ No newline at end of file diff --git a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/config.jelly b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/config.jelly new file mode 100644 index 000000000..2b771d726 --- /dev/null +++ b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/config.jelly @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/config.properties b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/config.properties new file mode 100644 index 000000000..969b3c1dc --- /dev/null +++ b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/config.properties @@ -0,0 +1,44 @@ +title.sourceCodeEncoding=Source Code Encoding +description.sourceCodeEncoding= + +title.enabledForFailure=Enable recording for failed builds +description.enabledForFailure= + +title.blameDisabled=Disable retrieval of blame information (author and commit) from SCM +description.blameDisabled= + +title.trendChartType=Trend Chart Type and Position +description.trendChartType= + +title.qualityGateThreshold=Quality gates threshold +description.qualityGateThreshold=If the actual number of issues is greater or equal than this threshold \ + then a build is considered as unstable or failed, respectively. + +title.qualityGateType=Quality gates type +description.qualityGateType=You can choose which property will be used to compare the provided threshold to \ + (overall number of issues, issues of a given severity, new issues, delta between two builds, etc.). + +title.qualityGateCriticality=Quality gates criticality +description.qualityGateCriticality=Determines if the build should be set to unstable or failed if the quality gate is not passed. + +title.javaIgnorePatterns=File patterns to ignore, when scanning Java files for warnings +description.javaIgnorePatterns=Fileset ''excludes'' syntax \ + specifying the Java files to ignore. + +title.highPriorityTaskIdentifiers=High Priority Tasks +description.highPriorityTaskIdentifiers=Coma separated list of high priority task identifiers. \ + Defaults to FIXME + +title.normalPriorityTaskIdentifiers=Normal Priority Tasks +description.normalPriorityTaskIdentifiers=Coma separated list of normal priority task identifiers. \ + Defaults to TODO + +title.tasksIncludePattern=File patterns to scan for tasks +description.tasksIncludePattern=Fileset ''includes'' syntax \ + specifying the files to scan. \ + Defaults to **/*.java. + +title.tasksExcludePattern=File patterns to exclude from tasks scan +description.tasksExcludePattern=Fileset ''excludes'' syntax \ + specifying the files to ignore. \ + Defaults to **/target/**. \ No newline at end of file diff --git a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/config_fr.properties b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/config_fr.properties new file mode 100644 index 000000000..6e1eaa046 --- /dev/null +++ b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/config_fr.properties @@ -0,0 +1,44 @@ +title.sourceCodeEncoding=Encodage des fichiers sources +description.sourceCodeEncoding= + +title.enabledForFailure=Activer l''analyse pour les constructions en erreur +description.enabledForFailure= + +title.blameDisabled=Ne pas r�cup�rer les informations de derni�re modification (auteur et commit) depuis le SCM +description.blameDisabled= + +title.trendChartType=Position et type du diagramme d''�volution +description.trendChartType= + +title.qualityGateThreshold=Seuil pour les profils de qualit� +description.qualityGateThreshold=Si le nombre courant de probl�mes est plus grand ou �qual que ce seuil \ + alors la construction sera marqu�e instable ou �chou�e. + +title.qualityGateType=Type des profils de qualit� +description.qualityGateType=Quel propri�t� utiliser pour la comparer avec le seuil \ + (nombre total de probl�mes, probl�mes d''une certaine gravit�, nouveaux probl�mes, diff�rence entre deux constructions, etc.). + +title.qualityGateCriticality=Criticit� des profils de qualit� +description.qualityGateCriticality=D�fini si la construction doit �tre marqu�e comme instable ou �chou�e si le profil de qualit� �choue. + +title.javaIgnorePatterns=Motifs de fichiers � ignorer lors du scan des fichiers Java +description.javaIgnorePatterns=configuration d''exclusion d''ensemble de fichiers Ant \ + qui d�finit les fichiers � ignorer lors du scan des fichiers Java. + +title.highPriorityTaskIdentifiers=T�ches de priorit� haute +description.highPriorityTaskIdentifiers=Liste s�par�e par des virgules d''identifiants de t�ches. \ + Par d�faut : FIXME + +title.normalPriorityTaskIdentifiers=T�ches de priorit� normale +description.normalPriorityTaskIdentifiers=Liste s�par�e par des virgules d''identifiants de t�ches. \ + Par d�fault : TODO + +title.tasksIncludePattern=Motifs de fichiers � scanner pour les t�ches +description.tasksIncludePattern=configuration d''inclusion d''ensemble de fichiers Ant \ + qui d�finit les fichiers � scanner. \ + Par d�faut : **/*.java. + +title.tasksExcludePattern=Motifs de fichiers � ignorer lors du scan des t�ches +description.tasksExcludePattern=configuration d''exclusion d''ensemble de fichiers Ant \ + qui d�finit les fichiers � ignorer. \ + Par d�faut : **/target/**. \ No newline at end of file diff --git a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/help-disabled.html b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/help-disabled.html new file mode 100644 index 000000000..a095aba3e --- /dev/null +++ b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/help-disabled.html @@ -0,0 +1,3 @@ +
+ Skip the publishing of static analysis tools reports. +
\ No newline at end of file diff --git a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/help-disabled_fr.html b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/help-disabled_fr.html new file mode 100644 index 000000000..cc703490a --- /dev/null +++ b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/help-disabled_fr.html @@ -0,0 +1,3 @@ +
+ Ne pas publier les rapports des outils d'analyse statique. +
\ No newline at end of file diff --git a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/help-enabledForFailure.html b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/help-enabledForFailure.html new file mode 100644 index 000000000..0e3ef7693 --- /dev/null +++ b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/help-enabledForFailure.html @@ -0,0 +1,5 @@ +
+ By default, static analysis results are only recorded for stable or unstable builds, but not for failed builds: + analysis results might be inaccurate if the build failed. If recording should be enabled for failed builds as well + then activate this check box. +
diff --git a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/help-enabledForFailure_fr.html b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/help-enabledForFailure_fr.html new file mode 100644 index 000000000..b25a6143a --- /dev/null +++ b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/help-enabledForFailure_fr.html @@ -0,0 +1,5 @@ +
+ Par défaut, les analyses statiques n'ont lieu que pour des constructions réussies ou instables, mais pas lorsqu'elles échouent : + les résultats peuvent être faussés si la construction échoue. Si les analyses doivent tout de même avoir lieu pour les + constructions échouées, cocher la case. +
diff --git a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/TasksScannerPublisher/help-highPriorityTaskIdentifiers.html b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/help-highPriorityTaskIdentifiers.html similarity index 100% rename from pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/TasksScannerPublisher/help-highPriorityTaskIdentifiers.html rename to pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/help-highPriorityTaskIdentifiers.html diff --git a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/TasksScannerPublisher/help-highPriorityTaskIdentifiers_fr.html b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/help-highPriorityTaskIdentifiers_fr.html similarity index 100% rename from pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/TasksScannerPublisher/help-highPriorityTaskIdentifiers_fr.html rename to pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/help-highPriorityTaskIdentifiers_fr.html diff --git a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/help-javaIgnorePatterns.html b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/help-javaIgnorePatterns.html new file mode 100644 index 000000000..c50f4784a --- /dev/null +++ b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/help-javaIgnorePatterns.html @@ -0,0 +1,5 @@ +
+ A pattern is defined by an Ant Fileset excludes + setting that specifies the Java files to ignore during scannning. Separate multiple patterns by space or comma. + Note that such a pattern is resolved in Jenkins' workspace, so the paths must be relative only. +
diff --git a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/help-javaIgnorePatterns_fr.html b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/help-javaIgnorePatterns_fr.html new file mode 100644 index 000000000..575839020 --- /dev/null +++ b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/help-javaIgnorePatterns_fr.html @@ -0,0 +1,5 @@ +
+ Un modèle est défini par une configuration d'exclusion d'ensemble de fichiers Ant + qui définit les fichiers à exclure lors du scan des fichiers Java. Séparer les modèles par des espaces ou des virugles. + Ces modèles sont déterminés dans l'espace de travail de Jenkins, les chemins doivent donc être obligatoirement relatifs. +
diff --git a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/TasksScannerPublisher/help-normalPriorityTaskIdentifiers.html b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/help-normalPriorityTaskIdentifiers.html similarity index 100% rename from pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/TasksScannerPublisher/help-normalPriorityTaskIdentifiers.html rename to pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/help-normalPriorityTaskIdentifiers.html diff --git a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/TasksScannerPublisher/help-normalPriorityTaskIdentifiers_fr.html b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/help-normalPriorityTaskIdentifiers_fr.html similarity index 100% rename from pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/TasksScannerPublisher/help-normalPriorityTaskIdentifiers_fr.html rename to pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/help-normalPriorityTaskIdentifiers_fr.html diff --git a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/help-qualityGateCriticality.html b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/help-qualityGateCriticality.html new file mode 100644 index 000000000..999ef7c57 --- /dev/null +++ b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/help-qualityGateCriticality.html @@ -0,0 +1,25 @@ +
+ When a quality gate has been missed, this property determines whether the result of the associated step + or the overall build will be marked as unstable or failure. + + The following enum values are possible: + +
+
UNSTABLE
+
+ Set the step and build status to unstable if the quality gate has been missed. +
+
FAILURE
+
+ Fail the step and build if the quality gate has been missed. +
+
NOTE
+
+ Set the step to unstable if the quality gate has been missed. +
+
ERROR
+
+ Fail the step if the quality gate has been missed. +
+
+
diff --git a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/help-qualityGateCriticality_fr.html b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/help-qualityGateCriticality_fr.html new file mode 100644 index 000000000..1a0d8df47 --- /dev/null +++ b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/help-qualityGateCriticality_fr.html @@ -0,0 +1,25 @@ +
+ Quand un profil de qualité échoue, cette propriété défini le résultat de l'étape associée, + ou de l'entière construction. + + Les valeurs possibles sont : + +
+
UNSTABLE
+
+ Marquer l'étape et la construction complète comme instables. +
+
FAILURE
+
+ Marquer l'étape et la construction complète comme échoués. +
+
NOTE
+
+ Marquer l'étape comme instable. +
+
ERROR
+
+ Marquer l'étape comme échouée. +
+
+
diff --git a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/help-qualityGateThreshold.html b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/help-qualityGateThreshold.html new file mode 100644 index 000000000..1ff7a911a --- /dev/null +++ b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/help-qualityGateThreshold.html @@ -0,0 +1,4 @@ +
+ The threshold defines the minimum number of warnings that will miss the quality gate. Values less or equal zero are ignored. + So if you want to fail a build that has one warning, set this field to 1. +
diff --git a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/help-qualityGateThreshold_fr.html b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/help-qualityGateThreshold_fr.html new file mode 100644 index 000000000..9071dba34 --- /dev/null +++ b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/help-qualityGateThreshold_fr.html @@ -0,0 +1,5 @@ +
+ Le seuil défini le nombre minimum de problèmes qui vont faire échouer le profil de qualité. + Les valeurs inférieures ou équales à 0 sont ignorées. + Pour qu'une construction ayant un problème échoue, saisir une valeur de 1. +
diff --git a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/help-qualityGateType.html b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/help-qualityGateType.html new file mode 100644 index 000000000..ce8a21439 --- /dev/null +++ b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/help-qualityGateType.html @@ -0,0 +1,20 @@ +
+ In order to simplify the user interface you can select the property that will be compared with the specified + threshold. Basically, three different properties are available: +
+
Total
+
Selects the total number of issues in the current build.
+
New
+
Selects the total number of new issues in the current build with respect to the reference build. + New issues will be calculated by a sophisticated algorithm + that tries to track issues from build to build, even if the source code has been modified. Note that this + algorithm sometimes detects outstanding warnings as new, e.g., if a source file has been refactored heavily. +
+
Delta
+
Selects the difference between the total number of issues in the current build subtracted by the total + number of issues in the reference build. This is a simple subtraction, so if you have a build that + adds a new warning and removes a completely different warning, then the result will be zero. +
+
+ Additionally, you can select to choose all issues, or issues of a given severity only (error, high, normal or low). +
diff --git a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/help-qualityGateType_fr.html b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/help-qualityGateType_fr.html new file mode 100644 index 000000000..7305a092c --- /dev/null +++ b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/help-qualityGateType_fr.html @@ -0,0 +1,18 @@ +
+ Afin de simplifier l'interface utilisateur, il est possible de choisir la propriété qui sera comparée avec + le seuil spécifié. Il y a trois propriétés possibles : +
+
Total
+
Le nombre total de problèmes dans la construction courante.
+
New
+
Le nombre total de nouveaux problèmes dans la construction courante, par rapport à la construction de référence. + Les nouveaux problèmes sont déterminés par un algorithme sofistiqué qui tente de suivre les problèmes + d'une construction à une autre, même si le code source a été modifié. +
+
Delta
+
La différence entre le nombre totale de problèmes dans la construction courante et le nombre total de problèmes + dans la construction de référence. Il s'agit d'une simple soustraction, donc si une construction ajoute un nouveau + problème mais un corrige un autre, le résultat sera 0. +
+
+
diff --git a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/help-skipBlames.html b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/help-skipBlames.html new file mode 100644 index 000000000..f7cb3328d --- /dev/null +++ b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/help-skipBlames.html @@ -0,0 +1,5 @@ +
+ If this option is unchecked, then the plugin automatically shows what revision and author (name and email) + last modified the lines of the affected files that contain issues. If this operation slows down your build, + or you don't want to publish sensitive user data, you can use this option to deactivate this feature. +
diff --git a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/help-skipBlames_fr.html b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/help-skipBlames_fr.html new file mode 100644 index 000000000..575ab017a --- /dev/null +++ b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/help-skipBlames_fr.html @@ -0,0 +1,5 @@ +
+ Cette option décochée, la dernière révision et le dernier auteur (nom et email) ayant modifié les lignes + contenant des problèmes seront affichés. Si cette opération est trop couteuse ou que vous ne souhaitez pas + afficher de données sensibles, il est possible de désactiver cette fonctionnalité. +
diff --git a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/help-sourceCodeEncoding.html b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/help-sourceCodeEncoding.html new file mode 100644 index 000000000..a7cb26ab1 --- /dev/null +++ b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/help-sourceCodeEncoding.html @@ -0,0 +1,6 @@ +
+ In order to correctly show all your affected source code files in the detail views, + the plugin must open these files with the correct character encoding (UTF-8, ISO-8859-1, etc.). + If you leave this field empty then the default encoding of the platform will be used. This might work but + is not recommended. +
diff --git a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/help-sourceCodeEncoding_fr.html b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/help-sourceCodeEncoding_fr.html new file mode 100644 index 000000000..5d16c2bf3 --- /dev/null +++ b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/help-sourceCodeEncoding_fr.html @@ -0,0 +1,5 @@ +
+ Afin d'afficher correctement le code source dans la vue détaillée, il est nécessaire de connaître + leur encodage (UTF-8, ISO-8859-1, etc.). + Si ce champ est laissé vide, la valeur par défaut du système sera utilisée. Cela peut marcher mais n'est pas recommandé. +
diff --git a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/TasksScannerPublisher/help-excludePattern.html b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/help-tasksExcludePattern.html similarity index 100% rename from pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/TasksScannerPublisher/help-excludePattern.html rename to pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/help-tasksExcludePattern.html diff --git a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/TasksScannerPublisher/help-excludePattern_fr.html b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/help-tasksExcludePattern_fr.html similarity index 100% rename from pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/TasksScannerPublisher/help-excludePattern_fr.html rename to pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/help-tasksExcludePattern_fr.html diff --git a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/TasksScannerPublisher/help-pattern.html b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/help-tasksIncludePattern.html similarity index 100% rename from pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/TasksScannerPublisher/help-pattern.html rename to pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/help-tasksIncludePattern.html diff --git a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/help-tasksIncludePattern_fr.html b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/help-tasksIncludePattern_fr.html new file mode 100644 index 000000000..37df78209 --- /dev/null +++ b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/help-tasksIncludePattern_fr.html @@ -0,0 +1,3 @@ +
+ Motif Ant des fichiers source à scanner. +
\ No newline at end of file diff --git a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/help-trendChartType.html b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/help-trendChartType.html new file mode 100644 index 000000000..1839997d1 --- /dev/null +++ b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/help-trendChartType.html @@ -0,0 +1,17 @@ +
+ If there is more than one static analysis result available then an aggregation trend chart will be shown + on the project page that shows the analysis results in a single trend chart. You can choose the position of + this aggregation trend: +
+
AGGREGATION_TOOLS
+
The aggregation trend is shown before all other analysis tool trend charts.
+
TOOLS_AGGREGATION
+
The aggregation trend is shown after all other analysis tool trend charts.
+
TOOLS_ONLY
+
The aggregation trend is not shown, only the analysis tool trend charts are shown.
+
AGGREGATION_ONLY
+
The aggregation trend is only shown, no other analysis tool trend charts are shown.
+
NONE
+
Neither the aggregation trend nor analysis tool trend charts are shown.
+
+
diff --git a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/help-trendChartType_fr.html b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/help-trendChartType_fr.html new file mode 100644 index 000000000..714b6af07 --- /dev/null +++ b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/help-trendChartType_fr.html @@ -0,0 +1,16 @@ +
+ S'il y a plus d'une analyse statique, un diagramme d'aggrégation s'affichera sur la page du projet. + Il est possible de choisir la position de ce diagramme d'aggrégation : +
+
AGGREGATION_TOOLS
+
avant les autres diagrammes.
+
TOOLS_AGGREGATION
+
après les autres diagrammes.
+
TOOLS_ONLY
+
Le diagramme aggrégé ne s'affiche pas, seulement ceux propres à chaque analyse.
+
AGGREGATION_ONLY
+
Seul le diagramme aggrégé est affichés, ceux propres à chaque analyse sont masqués.
+
NONE
+
Aucun diagramme n'est affiché.
+
+
diff --git a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/help.html b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/help.html new file mode 100644 index 000000000..0554b45fa --- /dev/null +++ b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/help.html @@ -0,0 +1,6 @@ +
+ Publish reports generated by static analysis tools, like "findbugs" or "spotbugs".
+ + Invoker results are by default published if the + Jenkins Warnings Plugin is installed. +
\ No newline at end of file diff --git a/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/help_fr.html b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/help_fr.html new file mode 100644 index 000000000..3e5d4c28a --- /dev/null +++ b/pipeline-maven/src/main/resources/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisher/help_fr.html @@ -0,0 +1,6 @@ +
+ Publier les rapports des analyseurs statiques de code, tels que "findbugs" ou "spotbugs".
+ + Ces rapports sont publiés par défaut si le plugin + Warnings est installé. +
\ No newline at end of file diff --git a/pipeline-maven/src/test/java/org/jenkinsci/plugins/pipeline/maven/AbstractIntegrationTest.java b/pipeline-maven/src/test/java/org/jenkinsci/plugins/pipeline/maven/AbstractIntegrationTest.java index fcb1ea937..7fcb3160f 100644 --- a/pipeline-maven/src/test/java/org/jenkinsci/plugins/pipeline/maven/AbstractIntegrationTest.java +++ b/pipeline-maven/src/test/java/org/jenkinsci/plugins/pipeline/maven/AbstractIntegrationTest.java @@ -38,6 +38,7 @@ import org.jvnet.hudson.test.BuildWatcher; import org.jvnet.hudson.test.JenkinsRule; import org.jvnet.hudson.test.junit.jupiter.WithJenkins; +import org.testcontainers.containers.Container.ExecResult; import org.testcontainers.containers.ExecConfig; import org.testcontainers.containers.ExecInContainerPattern; import org.testcontainers.containers.GenericContainer; @@ -138,7 +139,7 @@ protected String exposeGitRepositoryIntoAgent(GenericContainer container) String gitRepoPath = this.gitRepoRule.toString(); container.copyFileToContainer(MountableFile.forHostPath(gitRepoPath), containerPath); container.execInContainer("chmod", "-R", "777", containerPath); - System.out.println(ExecInContainerPattern.execInContainer( + ExecResult execResult = ExecInContainerPattern.execInContainer( container.getDockerClient(), container.getContainerInfo(), ExecConfig.builder() @@ -146,7 +147,8 @@ protected String exposeGitRepositoryIntoAgent(GenericContainer container) .command(new String[] { "git", "config", "--global", "--add", "safe.directory", containerPath + "/.git" }) - .build())); + .build()); + assertThat(execResult.getExitCode()).isZero(); return containerPath; } diff --git a/pipeline-maven/src/test/java/org/jenkinsci/plugins/pipeline/maven/ConfigurationAsCodeTest.java b/pipeline-maven/src/test/java/org/jenkinsci/plugins/pipeline/maven/ConfigurationAsCodeTest.java index 1c4b76aa0..c0ac0e0e2 100644 --- a/pipeline-maven/src/test/java/org/jenkinsci/plugins/pipeline/maven/ConfigurationAsCodeTest.java +++ b/pipeline-maven/src/test/java/org/jenkinsci/plugins/pipeline/maven/ConfigurationAsCodeTest.java @@ -6,22 +6,23 @@ import static java.util.Collections.singletonList; import static org.assertj.core.api.Assertions.assertThat; +import io.jenkins.plugins.analysis.core.util.TrendChartType; +import io.jenkins.plugins.analysis.core.util.WarningsQualityGate.QualityGateType; import io.jenkins.plugins.casc.ConfigurationAsCode; import io.jenkins.plugins.casc.ConfigurationContext; import io.jenkins.plugins.casc.ConfiguratorRegistry; import io.jenkins.plugins.prism.SourceCodeRetention; +import io.jenkins.plugins.util.QualityGate.QualityGateCriticality; import org.jenkinsci.plugins.pipeline.maven.publishers.ConcordionTestsPublisher; import org.jenkinsci.plugins.pipeline.maven.publishers.CoveragePublisher; import org.jenkinsci.plugins.pipeline.maven.publishers.DependenciesFingerprintPublisher; -import org.jenkinsci.plugins.pipeline.maven.publishers.FindbugsAnalysisPublisher; import org.jenkinsci.plugins.pipeline.maven.publishers.GeneratedArtifactsPublisher; import org.jenkinsci.plugins.pipeline.maven.publishers.InvokerRunsPublisher; import org.jenkinsci.plugins.pipeline.maven.publishers.JGivenTestsPublisher; import org.jenkinsci.plugins.pipeline.maven.publishers.JunitTestsPublisher; import org.jenkinsci.plugins.pipeline.maven.publishers.MavenLinkerPublisher2; import org.jenkinsci.plugins.pipeline.maven.publishers.PipelineGraphPublisher; -import org.jenkinsci.plugins.pipeline.maven.publishers.SpotBugsAnalysisPublisher; -import org.jenkinsci.plugins.pipeline.maven.publishers.TasksScannerPublisher; +import org.jenkinsci.plugins.pipeline.maven.publishers.WarningsPublisher; import org.junit.jupiter.api.Test; import org.jvnet.hudson.test.JenkinsRule; import org.jvnet.hudson.test.junit.jupiter.WithJenkins; @@ -133,7 +134,7 @@ public void should_support_publishers_configuration(JenkinsRule r) throws Except GlobalPipelineMavenConfig config = r.jenkins.getExtensionList(GlobalPipelineMavenConfig.class).get(0); - assertThat(config.getPublisherOptions()).hasSize(12); + assertThat(config.getPublisherOptions()).hasSize(10); assertThat(config.getPublisherOptions().get(0)).isInstanceOf(ConcordionTestsPublisher.class); ConcordionTestsPublisher concordionPublisher = @@ -158,60 +159,37 @@ public void should_support_publishers_configuration(JenkinsRule r) throws Except assertThat(dependenciesFingerprintPublisher.isIncludeScopeRuntime()).isTrue(); assertThat(dependenciesFingerprintPublisher.isIncludeScopeTest()).isTrue(); - assertThat(config.getPublisherOptions().get(3)).isInstanceOf(FindbugsAnalysisPublisher.class); - FindbugsAnalysisPublisher findBugsPublisher = - (FindbugsAnalysisPublisher) config.getPublisherOptions().get(3); - assertThat(findBugsPublisher.isDisabled()).isTrue(); - assertThat(findBugsPublisher.getHealthy()).isEqualTo("5"); - assertThat(findBugsPublisher.getThresholdLimit()).isEqualTo("high"); - assertThat(findBugsPublisher.getUnHealthy()).isEqualTo("15"); - - assertThat(config.getPublisherOptions().get(4)).isInstanceOf(GeneratedArtifactsPublisher.class); + assertThat(config.getPublisherOptions().get(3)).isInstanceOf(GeneratedArtifactsPublisher.class); GeneratedArtifactsPublisher generatedArtifactsPublisher = - (GeneratedArtifactsPublisher) config.getPublisherOptions().get(4); + (GeneratedArtifactsPublisher) config.getPublisherOptions().get(3); assertThat(generatedArtifactsPublisher.isDisabled()).isTrue(); - assertThat(config.getPublisherOptions().get(5)).isInstanceOf(InvokerRunsPublisher.class); + assertThat(config.getPublisherOptions().get(4)).isInstanceOf(InvokerRunsPublisher.class); InvokerRunsPublisher invokerRunsPublisher = - (InvokerRunsPublisher) config.getPublisherOptions().get(5); + (InvokerRunsPublisher) config.getPublisherOptions().get(4); assertThat(invokerRunsPublisher.isDisabled()).isTrue(); - assertThat(config.getPublisherOptions().get(6)).isInstanceOf(JGivenTestsPublisher.class); + assertThat(config.getPublisherOptions().get(5)).isInstanceOf(JGivenTestsPublisher.class); JGivenTestsPublisher jGivenTestsPublisher = - (JGivenTestsPublisher) config.getPublisherOptions().get(6); + (JGivenTestsPublisher) config.getPublisherOptions().get(5); assertThat(jGivenTestsPublisher.isDisabled()).isTrue(); - assertThat(config.getPublisherOptions().get(7)).isInstanceOf(JunitTestsPublisher.class); + assertThat(config.getPublisherOptions().get(6)).isInstanceOf(JunitTestsPublisher.class); JunitTestsPublisher junitTestsPublisher = - (JunitTestsPublisher) config.getPublisherOptions().get(7); + (JunitTestsPublisher) config.getPublisherOptions().get(6); assertThat(junitTestsPublisher.isDisabled()).isTrue(); assertThat(junitTestsPublisher.getHealthScaleFactor()).isEqualTo(5.0); assertThat(junitTestsPublisher.getIgnoreAttachments()).isTrue(); assertThat(junitTestsPublisher.isKeepLongStdio()).isTrue(); - assertThat(config.getPublisherOptions().get(8)).isInstanceOf(MavenLinkerPublisher2.class); + assertThat(config.getPublisherOptions().get(7)).isInstanceOf(MavenLinkerPublisher2.class); MavenLinkerPublisher2 mavenLinkerPublisher = - (MavenLinkerPublisher2) config.getPublisherOptions().get(8); + (MavenLinkerPublisher2) config.getPublisherOptions().get(7); assertThat(mavenLinkerPublisher.isDisabled()).isTrue(); - assertThat(config.getPublisherOptions().get(9)).isInstanceOf(TasksScannerPublisher.class); - TasksScannerPublisher tasksScannerPublisher = - (TasksScannerPublisher) config.getPublisherOptions().get(9); - assertThat(tasksScannerPublisher.isDisabled()).isTrue(); - assertThat(tasksScannerPublisher.isAsRegexp()).isTrue(); - assertThat(tasksScannerPublisher.getExcludePattern()).isEqualTo("**/*.xml"); - assertThat(tasksScannerPublisher.getHealthy()).isEqualTo("5"); - assertThat(tasksScannerPublisher.getHighPriorityTaskIdentifiers()).isEqualTo("task1,task2"); - assertThat(tasksScannerPublisher.isIgnoreCase()).isTrue(); - assertThat(tasksScannerPublisher.getLowPriorityTaskIdentifiers()).isEqualTo("task4"); - assertThat(tasksScannerPublisher.getNormalPriorityTaskIdentifiers()).isEqualTo("task3"); - assertThat(tasksScannerPublisher.getPattern()).isEqualTo("**/*.java"); - assertThat(tasksScannerPublisher.getThresholdLimit()).isEqualTo("normal"); - assertThat(tasksScannerPublisher.getUnHealthy()).isEqualTo("15"); - - assertThat(config.getPublisherOptions().get(10)).isInstanceOf(PipelineGraphPublisher.class); + assertThat(config.getPublisherOptions().get(8)).isInstanceOf(PipelineGraphPublisher.class); PipelineGraphPublisher pipelineGraphPublisher = - (PipelineGraphPublisher) config.getPublisherOptions().get(10); + (PipelineGraphPublisher) config.getPublisherOptions().get(8); assertThat(pipelineGraphPublisher.isDisabled()).isTrue(); assertThat(pipelineGraphPublisher.isIgnoreUpstreamTriggers()).isTrue(); assertThat(pipelineGraphPublisher.isIncludeReleaseVersions()).isTrue(); @@ -222,13 +200,22 @@ public void should_support_publishers_configuration(JenkinsRule r) throws Except assertThat(pipelineGraphPublisher.getLifecycleThreshold()).isEqualTo("install"); assertThat(pipelineGraphPublisher.isSkipDownstreamTriggers()).isTrue(); - assertThat(config.getPublisherOptions().get(11)).isInstanceOf(SpotBugsAnalysisPublisher.class); - SpotBugsAnalysisPublisher spotBugsAnalysisPublisher = - (SpotBugsAnalysisPublisher) config.getPublisherOptions().get(11); - assertThat(spotBugsAnalysisPublisher.isDisabled()).isTrue(); - assertThat(spotBugsAnalysisPublisher.getHealthy()).isEqualTo("5"); - assertThat(spotBugsAnalysisPublisher.getThresholdLimit()).isEqualTo("high"); - assertThat(spotBugsAnalysisPublisher.getUnHealthy()).isEqualTo("15"); + assertThat(config.getPublisherOptions().get(9)).isInstanceOf(WarningsPublisher.class); + WarningsPublisher warningsPublisher = + (WarningsPublisher) config.getPublisherOptions().get(9); + assertThat(warningsPublisher.isDisabled()).isTrue(); + assertThat(warningsPublisher.getSourceCodeEncoding()).isEqualTo("ISO-8859-15"); + assertThat(warningsPublisher.isEnabledForFailure()).isFalse(); + assertThat(warningsPublisher.isSkipBlames()).isFalse(); + assertThat(warningsPublisher.getTrendChartType()).isEqualTo(TrendChartType.NONE); + assertThat(warningsPublisher.getQualityGateThreshold()).isEqualTo(10); + assertThat(warningsPublisher.getQualityGateType()).isEqualTo(QualityGateType.DELTA); + assertThat(warningsPublisher.getQualityGateCriticality()).isEqualTo(QualityGateCriticality.ERROR); + assertThat(warningsPublisher.getJavaIgnorePatterns()).isEqualTo("**/*Test.java"); + assertThat(warningsPublisher.getHighPriorityTaskIdentifiers()).isEqualTo("FIX"); + assertThat(warningsPublisher.getNormalPriorityTaskIdentifiers()).isEqualTo("TO-DO"); + assertThat(warningsPublisher.getTasksIncludePattern()).isEqualTo("**/*.*"); + assertThat(warningsPublisher.getTasksExcludePattern()).isEqualTo("**/target/*.*"); ConfiguratorRegistry registry = ConfiguratorRegistry.get(); ConfigurationContext context = new ConfigurationContext(registry); diff --git a/pipeline-maven/src/test/java/org/jenkinsci/plugins/pipeline/maven/GlobalPipelineMavenConfigTest.java b/pipeline-maven/src/test/java/org/jenkinsci/plugins/pipeline/maven/GlobalPipelineMavenConfigTest.java index 4f81e9c1c..4276bd887 100644 --- a/pipeline-maven/src/test/java/org/jenkinsci/plugins/pipeline/maven/GlobalPipelineMavenConfigTest.java +++ b/pipeline-maven/src/test/java/org/jenkinsci/plugins/pipeline/maven/GlobalPipelineMavenConfigTest.java @@ -8,7 +8,10 @@ import com.zaxxer.hikari.HikariDataSource; import com.zaxxer.hikari.pool.HikariProxyConnection; import hudson.ExtensionList; +import io.jenkins.plugins.analysis.core.util.TrendChartType; +import io.jenkins.plugins.analysis.core.util.WarningsQualityGate.QualityGateType; import io.jenkins.plugins.prism.SourceCodeRetention; +import io.jenkins.plugins.util.QualityGate.QualityGateCriticality; import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.sql.Connection; @@ -23,15 +26,13 @@ import org.jenkinsci.plugins.pipeline.maven.publishers.ConcordionTestsPublisher; import org.jenkinsci.plugins.pipeline.maven.publishers.CoveragePublisher; import org.jenkinsci.plugins.pipeline.maven.publishers.DependenciesFingerprintPublisher; -import org.jenkinsci.plugins.pipeline.maven.publishers.FindbugsAnalysisPublisher; import org.jenkinsci.plugins.pipeline.maven.publishers.GeneratedArtifactsPublisher; import org.jenkinsci.plugins.pipeline.maven.publishers.InvokerRunsPublisher; import org.jenkinsci.plugins.pipeline.maven.publishers.JGivenTestsPublisher; import org.jenkinsci.plugins.pipeline.maven.publishers.JunitTestsPublisher; import org.jenkinsci.plugins.pipeline.maven.publishers.MavenLinkerPublisher2; import org.jenkinsci.plugins.pipeline.maven.publishers.PipelineGraphPublisher; -import org.jenkinsci.plugins.pipeline.maven.publishers.SpotBugsAnalysisPublisher; -import org.jenkinsci.plugins.pipeline.maven.publishers.TasksScannerPublisher; +import org.jenkinsci.plugins.pipeline.maven.publishers.WarningsPublisher; import org.jenkinsci.plugins.pipeline.maven.util.FakeCredentialsProvider; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; @@ -91,12 +92,6 @@ public void configRoundTrip() throws Exception { dependenciesFingerprintPublisher.setIncludeScopeRuntime(true); dependenciesFingerprintPublisher.setIncludeScopeTest(true); - FindbugsAnalysisPublisher findBugsPublisher = new FindbugsAnalysisPublisher(); - findBugsPublisher.setDisabled(true); - findBugsPublisher.setHealthy("5"); - findBugsPublisher.setThresholdLimit("high"); - findBugsPublisher.setUnHealthy("15"); - GeneratedArtifactsPublisher generatedArtifactsPublisher = new GeneratedArtifactsPublisher(); generatedArtifactsPublisher.setDisabled(true); @@ -115,19 +110,6 @@ public void configRoundTrip() throws Exception { MavenLinkerPublisher2 mavenLinkerPublisher = new MavenLinkerPublisher2(); mavenLinkerPublisher.setDisabled(true); - TasksScannerPublisher tasksScannerPublisher = new TasksScannerPublisher(); - tasksScannerPublisher.setDisabled(true); - tasksScannerPublisher.setAsRegexp(true); - tasksScannerPublisher.setExcludePattern("**/*.xml"); - tasksScannerPublisher.setHealthy("5"); - tasksScannerPublisher.setHighPriorityTaskIdentifiers("task1,task2"); - tasksScannerPublisher.setIgnoreCase(true); - tasksScannerPublisher.setLowPriorityTaskIdentifiers("task4"); - tasksScannerPublisher.setNormalPriorityTaskIdentifiers("task3"); - tasksScannerPublisher.setPattern("**/*.java"); - tasksScannerPublisher.setThresholdLimit("normal"); - tasksScannerPublisher.setUnHealthy("15"); - PipelineGraphPublisher pipelineGraphPublisher = new PipelineGraphPublisher(); pipelineGraphPublisher.setDisabled(true); pipelineGraphPublisher.setIgnoreUpstreamTriggers(true); @@ -139,25 +121,32 @@ public void configRoundTrip() throws Exception { pipelineGraphPublisher.setLifecycleThreshold("install"); pipelineGraphPublisher.setSkipDownstreamTriggers(true); - SpotBugsAnalysisPublisher spotBugsAnalysisPublisher = new SpotBugsAnalysisPublisher(); - spotBugsAnalysisPublisher.setDisabled(true); - spotBugsAnalysisPublisher.setHealthy("5"); - spotBugsAnalysisPublisher.setThresholdLimit("high"); - spotBugsAnalysisPublisher.setUnHealthy("15"); + WarningsPublisher warningsPublisher = new WarningsPublisher(); + warningsPublisher.setDisabled(true); + warningsPublisher.setSourceCodeEncoding("ISO-8859-15"); + warningsPublisher.setEnabledForFailure(false); + warningsPublisher.setSkipBlames(false); + warningsPublisher.setTrendChartType(TrendChartType.NONE); + warningsPublisher.setQualityGateThreshold(10); + warningsPublisher.setQualityGateType(QualityGateType.DELTA); + warningsPublisher.setQualityGateCriticality(QualityGateCriticality.ERROR); + warningsPublisher.setJavaIgnorePatterns("**/*Test.java"); + warningsPublisher.setHighPriorityTaskIdentifiers("FIX"); + warningsPublisher.setNormalPriorityTaskIdentifiers("TO-DO"); + warningsPublisher.setTasksIncludePattern("**/*.*"); + warningsPublisher.setTasksExcludePattern("**/target/*.*"); c.setPublisherOptions(List.of( concordionTestsPublisher, coveragePublisher, dependenciesFingerprintPublisher, - findBugsPublisher, generatedArtifactsPublisher, invokerRunsPublisher, jGivenTestsPublisher, junitTestsPublisher, mavenLinkerPublisher, - tasksScannerPublisher, pipelineGraphPublisher, - spotBugsAnalysisPublisher)); + warningsPublisher)); j.configRoundtrip(); diff --git a/pipeline-maven/src/test/java/org/jenkinsci/plugins/pipeline/maven/MavenPublisherStrategyTest.java b/pipeline-maven/src/test/java/org/jenkinsci/plugins/pipeline/maven/MavenPublisherStrategyTest.java index 9f670d41b..b5f5dc813 100644 --- a/pipeline-maven/src/test/java/org/jenkinsci/plugins/pipeline/maven/MavenPublisherStrategyTest.java +++ b/pipeline-maven/src/test/java/org/jenkinsci/plugins/pipeline/maven/MavenPublisherStrategyTest.java @@ -11,15 +11,13 @@ import org.jenkinsci.plugins.pipeline.maven.publishers.ConcordionTestsPublisher; import org.jenkinsci.plugins.pipeline.maven.publishers.CoveragePublisher; import org.jenkinsci.plugins.pipeline.maven.publishers.DependenciesFingerprintPublisher; -import org.jenkinsci.plugins.pipeline.maven.publishers.FindbugsAnalysisPublisher; import org.jenkinsci.plugins.pipeline.maven.publishers.GeneratedArtifactsPublisher; import org.jenkinsci.plugins.pipeline.maven.publishers.InvokerRunsPublisher; import org.jenkinsci.plugins.pipeline.maven.publishers.JGivenTestsPublisher; import org.jenkinsci.plugins.pipeline.maven.publishers.JunitTestsPublisher; import org.jenkinsci.plugins.pipeline.maven.publishers.MavenLinkerPublisher2; import org.jenkinsci.plugins.pipeline.maven.publishers.PipelineGraphPublisher; -import org.jenkinsci.plugins.pipeline.maven.publishers.SpotBugsAnalysisPublisher; -import org.jenkinsci.plugins.pipeline.maven.publishers.TasksScannerPublisher; +import org.jenkinsci.plugins.pipeline.maven.publishers.WarningsPublisher; import org.junit.jupiter.api.Test; import org.jvnet.hudson.test.JenkinsRule; import org.jvnet.hudson.test.junit.jupiter.WithJenkins; @@ -38,16 +36,14 @@ public void listMavenPublishers(JenkinsRule r) throws Exception { List mavenPublishers = MavenPublisherStrategy.IMPLICIT.buildPublishersList( Collections.emptyList(), new StreamTaskListener(baos)); - assertThat(mavenPublishers).hasSize(12); + assertThat(mavenPublishers).hasSize(10); Map reportersByDescriptorId = new HashMap<>(); for (MavenPublisher mavenPublisher : mavenPublishers) { reportersByDescriptorId.put(mavenPublisher.getDescriptor().getId(), mavenPublisher); } - assertThat(reportersByDescriptorId).containsKey(new FindbugsAnalysisPublisher.DescriptorImpl().getId()); - assertThat(reportersByDescriptorId).containsKey(new SpotBugsAnalysisPublisher.DescriptorImpl().getId()); - assertThat(reportersByDescriptorId).containsKey(new TasksScannerPublisher.DescriptorImpl().getId()); assertThat(reportersByDescriptorId).containsKey(new ConcordionTestsPublisher.DescriptorImpl().getId()); + assertThat(reportersByDescriptorId).containsKey(new CoveragePublisher.DescriptorImpl().getId()); assertThat(reportersByDescriptorId).containsKey(new DependenciesFingerprintPublisher.DescriptorImpl().getId()); assertThat(reportersByDescriptorId).containsKey(new GeneratedArtifactsPublisher.DescriptorImpl().getId()); assertThat(reportersByDescriptorId).containsKey(new InvokerRunsPublisher.DescriptorImpl().getId()); @@ -55,6 +51,6 @@ public void listMavenPublishers(JenkinsRule r) throws Exception { assertThat(reportersByDescriptorId).containsKey(new JunitTestsPublisher.DescriptorImpl().getId()); assertThat(reportersByDescriptorId).containsKey(new MavenLinkerPublisher2.DescriptorImpl().getId()); assertThat(reportersByDescriptorId).containsKey(new PipelineGraphPublisher.DescriptorImpl().getId()); - assertThat(reportersByDescriptorId).containsKey(new CoveragePublisher.DescriptorImpl().getId()); + assertThat(reportersByDescriptorId).containsKey(new WarningsPublisher.DescriptorImpl().getId()); } } diff --git a/pipeline-maven/src/test/java/org/jenkinsci/plugins/pipeline/maven/WithMavenStepGlobalConfigurationTest.java b/pipeline-maven/src/test/java/org/jenkinsci/plugins/pipeline/maven/WithMavenStepGlobalConfigurationTest.java index 6e552c077..17a59b258 100644 --- a/pipeline-maven/src/test/java/org/jenkinsci/plugins/pipeline/maven/WithMavenStepGlobalConfigurationTest.java +++ b/pipeline-maven/src/test/java/org/jenkinsci/plugins/pipeline/maven/WithMavenStepGlobalConfigurationTest.java @@ -35,15 +35,13 @@ import org.jenkinsci.plugins.pipeline.maven.publishers.ConcordionTestsPublisher; import org.jenkinsci.plugins.pipeline.maven.publishers.CoveragePublisher; import org.jenkinsci.plugins.pipeline.maven.publishers.DependenciesFingerprintPublisher; -import org.jenkinsci.plugins.pipeline.maven.publishers.FindbugsAnalysisPublisher; import org.jenkinsci.plugins.pipeline.maven.publishers.GeneratedArtifactsPublisher; import org.jenkinsci.plugins.pipeline.maven.publishers.InvokerRunsPublisher; import org.jenkinsci.plugins.pipeline.maven.publishers.JGivenTestsPublisher; import org.jenkinsci.plugins.pipeline.maven.publishers.JunitTestsPublisher; import org.jenkinsci.plugins.pipeline.maven.publishers.MavenLinkerPublisher2; import org.jenkinsci.plugins.pipeline.maven.publishers.PipelineGraphPublisher; -import org.jenkinsci.plugins.pipeline.maven.publishers.SpotBugsAnalysisPublisher; -import org.jenkinsci.plugins.pipeline.maven.publishers.TasksScannerPublisher; +import org.jenkinsci.plugins.pipeline.maven.publishers.WarningsPublisher; import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition; import org.jenkinsci.plugins.workflow.job.WorkflowJob; import org.jenkinsci.plugins.workflow.job.WorkflowRun; @@ -163,9 +161,7 @@ public void maven_build_jar_project_on_master_with_publisher_configured_both_glo private static Stream mavenPublisherDescriptors() { return Stream.of( - arguments(named("Findbugs", new FindbugsAnalysisPublisher.DescriptorImpl())), - arguments(named("SpotBugs", new SpotBugsAnalysisPublisher.DescriptorImpl())), - arguments(named("TasksScanner", new TasksScannerPublisher.DescriptorImpl())), + arguments(named("Coverage", new CoveragePublisher.DescriptorImpl())), arguments(named("Concordion", new ConcordionTestsPublisher.DescriptorImpl())), arguments(named("DependenciesFingerprint", new DependenciesFingerprintPublisher.DescriptorImpl())), arguments(named("GeneratedArtifacts", new GeneratedArtifactsPublisher.DescriptorImpl())), @@ -174,6 +170,6 @@ private static Stream mavenPublisherDescriptors() { arguments(named("Junit", new JunitTestsPublisher.DescriptorImpl())), arguments(named("MavenLinker", new MavenLinkerPublisher2.DescriptorImpl())), arguments(named("PipelineGraph", new PipelineGraphPublisher.DescriptorImpl())), - arguments(named("Coverage", new CoveragePublisher.DescriptorImpl()))); + arguments(named("Warnings", new WarningsPublisher.DescriptorImpl()))); } } diff --git a/pipeline-maven/src/test/java/org/jenkinsci/plugins/pipeline/maven/WithMavenStepOnMasterTest.java b/pipeline-maven/src/test/java/org/jenkinsci/plugins/pipeline/maven/WithMavenStepOnMasterTest.java index 77b9dae2b..764c2b204 100644 --- a/pipeline-maven/src/test/java/org/jenkinsci/plugins/pipeline/maven/WithMavenStepOnMasterTest.java +++ b/pipeline-maven/src/test/java/org/jenkinsci/plugins/pipeline/maven/WithMavenStepOnMasterTest.java @@ -31,7 +31,6 @@ import com.cloudbees.hudson.plugins.folder.Folder; import com.google.common.base.Predicate; import hudson.model.Result; -import hudson.plugins.tasks.TasksResultAction; import hudson.tasks.junit.CaseResult; import hudson.tasks.junit.TestResult; import hudson.tasks.junit.TestResultAction; @@ -64,15 +63,13 @@ import org.jenkinsci.plugins.pipeline.maven.publishers.ConcordionTestsPublisher; import org.jenkinsci.plugins.pipeline.maven.publishers.CoveragePublisher; import org.jenkinsci.plugins.pipeline.maven.publishers.DependenciesFingerprintPublisher; -import org.jenkinsci.plugins.pipeline.maven.publishers.FindbugsAnalysisPublisher; import org.jenkinsci.plugins.pipeline.maven.publishers.GeneratedArtifactsPublisher; import org.jenkinsci.plugins.pipeline.maven.publishers.InvokerRunsPublisher; import org.jenkinsci.plugins.pipeline.maven.publishers.JGivenTestsPublisher; import org.jenkinsci.plugins.pipeline.maven.publishers.JunitTestsPublisher; import org.jenkinsci.plugins.pipeline.maven.publishers.MavenLinkerPublisher2; import org.jenkinsci.plugins.pipeline.maven.publishers.PipelineGraphPublisher; -import org.jenkinsci.plugins.pipeline.maven.publishers.SpotBugsAnalysisPublisher; -import org.jenkinsci.plugins.pipeline.maven.publishers.TasksScannerPublisher; +import org.jenkinsci.plugins.pipeline.maven.publishers.WarningsPublisher; import org.jenkinsci.plugins.workflow.actions.LabelAction; import org.jenkinsci.plugins.workflow.actions.ThreadNameAction; import org.jenkinsci.plugins.workflow.actions.WarningAction; @@ -244,13 +241,6 @@ public void maven_build_no_traceability() throws Exception { "[withMaven] junitPublisher - Archive test results for Maven artifact jenkins.mvn.test:mono-module-maven-app:jar:0.1-SNAPSHOT " + "generated by maven-failsafe-plugin:integration-test", build); - - // verify Task Scanner is called for jenkins.mvn.test:mono-module-maven-app - jenkinsRule.assertLogContains( - "[withMaven] openTasksPublisher - Scan Tasks for Maven artifact jenkins.mvn.test:mono-module-maven-app:jar:0.1-SNAPSHOT", - build); - TasksResultAction tasksResultAction = build.getAction(TasksResultAction.class); - assertThat(tasksResultAction.getProjectActions()).hasSize(1); } @Issue("JENKINS-70543") @@ -382,13 +372,6 @@ public void maven_build_jar_project_on_master_succeeds() throws Exception { "[withMaven] junitPublisher - Archive test results for Maven artifact jenkins.mvn.test:mono-module-maven-app:jar:0.1-SNAPSHOT " + "generated by maven-failsafe-plugin:integration-test", build); - - // verify Task Scanner is called for jenkins.mvn.test:mono-module-maven-app - jenkinsRule.assertLogContains( - "[withMaven] openTasksPublisher - Scan Tasks for Maven artifact jenkins.mvn.test:mono-module-maven-app:jar:0.1-SNAPSHOT", - build); - TasksResultAction tasksResultAction = build.getAction(TasksResultAction.class); - assertThat(tasksResultAction.getProjectActions()).hasSize(1); } @Issue("JENKINS-48264") @@ -440,10 +423,8 @@ public void maven_build_jar_project_with_whitespace_char_in_name() throws Except private static Stream mavenPublisherDescriptors() { return Stream.of( - Arguments.of(new FindbugsAnalysisPublisher.DescriptorImpl(), "findbugsPublisher"), - Arguments.of(new SpotBugsAnalysisPublisher.DescriptorImpl(), "spotbugsPublisher"), - Arguments.of(new TasksScannerPublisher.DescriptorImpl(), "openTasksPublisher"), Arguments.of(new ConcordionTestsPublisher.DescriptorImpl(), "concordionPublisher"), + Arguments.of(new CoveragePublisher.DescriptorImpl(), "coveragePublisher"), Arguments.of(new DependenciesFingerprintPublisher.DescriptorImpl(), "dependenciesFingerprintPublisher"), Arguments.of(new GeneratedArtifactsPublisher.DescriptorImpl(), "artifactsPublisher"), Arguments.of(new InvokerRunsPublisher.DescriptorImpl(), "invokerPublisher"), @@ -451,7 +432,7 @@ private static Stream mavenPublisherDescriptors() { Arguments.of(new JunitTestsPublisher.DescriptorImpl(), "junitPublisher"), Arguments.of(new MavenLinkerPublisher2.DescriptorImpl(), "mavenLinkerPublisher"), Arguments.of(new PipelineGraphPublisher.DescriptorImpl(), "pipelineGraphPublisher"), - Arguments.of(new CoveragePublisher.DescriptorImpl(), "coveragePublisher")); + Arguments.of(new WarningsPublisher.DescriptorImpl(), "warningsPublisher")); } @ParameterizedTest @@ -501,44 +482,6 @@ public void maven_build_jar_project_on_master_with_disabled_publisher_param_succ } } - @Test - public void maven_build_jar_project_on_master_with_open_task_scanner_config_succeeds() throws Exception { - - MavenPublisher.DescriptorImpl descriptor = new TasksScannerPublisher.DescriptorImpl(); - String displayName = descriptor.getDisplayName(); - - Symbol symbolAnnotation = descriptor.getClass().getAnnotation(Symbol.class); - String[] symbols = symbolAnnotation.value(); - assertThat(new String[] {"openTasksPublisher"}).isEqualTo(symbols); - - loadMavenJarProjectInGitRepo(this.gitRepoRule); - - // @formatter:off - String pipelineScript = "node() {\n" + - " git($/" + gitRepoRule.toString() + "/$)\n" + - " withMaven(options:[openTasksPublisher(" + - " disabled:false, " + - " pattern:'src/main/java', excludePattern:'a/path'," + - " ignoreCase:true, asRegexp:false, " + - " lowPriorityTaskIdentifiers:'minor', normalPriorityTaskIdentifiers:'todo', highPriorityTaskIdentifiers:'fixme')]) {\n" + - " if (isUnix()) {\n" + - " sh 'mvn package verify'\n" + - " } else {\n" + - " bat 'mvn package verify'\n" + - " }\n" + - " }\n" + - "}"; - // @formatter:on - - WorkflowJob pipeline = - jenkinsRule.createProject(WorkflowJob.class, "build-on-master-openTasksPublisher-publisher-config"); - pipeline.setDefinition(new CpsFlowDefinition(pipelineScript, true)); - WorkflowRun build = jenkinsRule.assertBuildStatus(Result.SUCCESS, pipeline.scheduleBuild2(0)); - - String message = "[withMaven] Skip '" + displayName + "' disabled by configuration"; - jenkinsRule.assertLogNotContains(message, build); - } - @Test public void maven_build_maven_jar_with_flatten_pom_project_on_master_succeeds() throws Exception { loadSourceCodeInGitRepository( @@ -602,12 +545,6 @@ public void maven_build_maven_jar_with_flatten_pom_project_on_master_succeeds() jenkinsRule.assertLogContains( "[withMaven] junitPublisher - Archive test results for Maven artifact jenkins.mvn.test:maven-jar-with-flattened-pom:jar:0.1-SNAPSHOT generated by", build); - - // verify Task Scanner is called for - // jenkins.mvn.test:maven-jar-with-flattened-pom - jenkinsRule.assertLogContains( - "[withMaven] openTasksPublisher - Scan Tasks for Maven artifact jenkins.mvn.test:maven-jar-with-flattened-pom:jar:0.1-SNAPSHOT in source directory", - build); } @Test @@ -665,11 +602,6 @@ public void maven_build_maven_hpi_project_on_master_succeeds() throws Exception jenkinsRule.assertLogContains( "[withMaven] junitPublisher - Archive test results for Maven artifact jenkins.mvn.test:test-jenkins-hpi:hpi:0.1-SNAPSHOT generated by", build); - - // verify Task Scanner is called for jenkins.mvn.test:test-jenkins-hpi - jenkinsRule.assertLogContains( - "[withMaven] openTasksPublisher - Scan Tasks for Maven artifact jenkins.mvn.test:test-jenkins-hpi:hpi:0.1-SNAPSHOT in source directory", - build); } @Issue("JENKINS-43678") diff --git a/pipeline-maven/src/test/java/org/jenkinsci/plugins/pipeline/maven/listeners/DownstreamPipelineTriggerRunListenerIntegrationTest.java b/pipeline-maven/src/test/java/org/jenkinsci/plugins/pipeline/maven/listeners/DownstreamPipelineTriggerRunListenerIntegrationTest.java index ad0ecbc93..0ac21f310 100644 --- a/pipeline-maven/src/test/java/org/jenkinsci/plugins/pipeline/maven/listeners/DownstreamPipelineTriggerRunListenerIntegrationTest.java +++ b/pipeline-maven/src/test/java/org/jenkinsci/plugins/pipeline/maven/listeners/DownstreamPipelineTriggerRunListenerIntegrationTest.java @@ -15,7 +15,6 @@ import org.jenkinsci.plugins.pipeline.maven.MavenDependency; import org.jenkinsci.plugins.pipeline.maven.MavenPublisher; import org.jenkinsci.plugins.pipeline.maven.db.PipelineMavenPluginH2Dao; -import org.jenkinsci.plugins.pipeline.maven.publishers.FindbugsAnalysisPublisher; import org.jenkinsci.plugins.pipeline.maven.publishers.PipelineGraphPublisher; import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition; import org.jenkinsci.plugins.workflow.job.WorkflowJob; @@ -57,11 +56,6 @@ public void setup() throws Exception { publisher.setIncludeScopeTest(true); publisherOptions.add(publisher); } - { - FindbugsAnalysisPublisher publisher = new FindbugsAnalysisPublisher(); - publisher.setDisabled(true); - publisherOptions.add(publisher); - } } @Test diff --git a/pipeline-maven/src/test/java/org/jenkinsci/plugins/pipeline/maven/publishers/FindbugsAnalysisPublisherTest.java b/pipeline-maven/src/test/java/org/jenkinsci/plugins/pipeline/maven/publishers/FindbugsAnalysisPublisherTest.java new file mode 100644 index 000000000..205c04541 --- /dev/null +++ b/pipeline-maven/src/test/java/org/jenkinsci/plugins/pipeline/maven/publishers/FindbugsAnalysisPublisherTest.java @@ -0,0 +1,166 @@ +package org.jenkinsci.plugins.pipeline.maven.publishers; + +import hudson.model.Result; +import org.jenkinsci.plugins.pipeline.maven.AbstractIntegrationTest; +import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition; +import org.jenkinsci.plugins.workflow.job.WorkflowJob; +import org.jenkinsci.plugins.workflow.job.WorkflowRun; +import org.junit.jupiter.api.Test; +import org.jvnet.hudson.test.recipes.WithPlugin; + +public class FindbugsAnalysisPublisherTest extends AbstractIntegrationTest { + + @Test + @WithPlugin({ + "findbugs.jpi", + "analysis-core.jpi", + "antisamy-markup-formatter.hpi", + "apache-httpcomponents-client-4-api.hpi", + "asm-api.hpi", + "bootstrap5-api.hpi", + "caffeine-api.hpi", + "checks-api.hpi", + "commons-lang3-api.hpi", + "commons-text-api.hpi", + "credentials.hpi", + "display-url-api.hpi", + "durable-task.hpi", + "echarts-api.hpi", + "font-awesome-api.hpi", + "ionicons-api.hpi", + "jackson2-api.hpi", + "jakarta-activation-api.hpi", + "jakarta-mail-api.hpi", + "javadoc.hpi", + "jquery3-api.hpi", + "jsch.hpi", + "json-api.hpi", + "jsoup.hpi", + "junit.hpi", + "mailer.hpi", + "matrix-project.hpi", + "maven-plugin.hpi", + "oss-symbols-api.hpi", + "plugin-util-api.hpi", + "scm-api.hpi", + "script-security.hpi", + "snakeyaml-api.hpi", + "ssh-credentials.hpi", + "structs.hpi", + "variant.hpi", + "workflow-api.hpi", + "workflow-step-api.hpi", + "workflow-support.hpi" + }) + public void maven_build_jar_with_implicit_findbugs_success() throws Exception { + loadMavenJarProjectInGitRepo(this.gitRepoRule); + + // @formatter:off + String pipelineScript = "node() {\n" + + " git($/" + gitRepoRule.toString() + "/$)\n" + + " withMaven() {\n" + + " if (isUnix()) {\n" + + " sh 'mvn package verify'\n" + + " } else {\n" + + " bat 'mvn package verify'\n" + + " }\n" + + " }\n" + + "}"; + // @formatter:on + + WorkflowJob pipeline = jenkinsRule.createProject(WorkflowJob.class, "jar-with-findbugs"); + pipeline.setDefinition(new CpsFlowDefinition(pipelineScript, true)); + WorkflowRun build = jenkinsRule.assertBuildStatus(Result.SUCCESS, pipeline.scheduleBuild2(0)); + jenkinsRule.assertLogContains( + "[withMaven] Findbugs Publisher is no longer implicitly used with `withMaven` step.", build); + } + + @Test + @WithPlugin({ + "findbugs.jpi", + "analysis-core.jpi", + "antisamy-markup-formatter.hpi", + "apache-httpcomponents-client-4-api.hpi", + "asm-api.hpi", + "bootstrap5-api.hpi", + "caffeine-api.hpi", + "checks-api.hpi", + "commons-lang3-api.hpi", + "commons-text-api.hpi", + "credentials.hpi", + "display-url-api.hpi", + "durable-task.hpi", + "echarts-api.hpi", + "font-awesome-api.hpi", + "ionicons-api.hpi", + "jackson2-api.hpi", + "jakarta-activation-api.hpi", + "jakarta-mail-api.hpi", + "javadoc.hpi", + "jquery3-api.hpi", + "jsch.hpi", + "json-api.hpi", + "jsoup.hpi", + "junit.hpi", + "mailer.hpi", + "matrix-project.hpi", + "maven-plugin.hpi", + "oss-symbols-api.hpi", + "plugin-util-api.hpi", + "scm-api.hpi", + "script-security.hpi", + "snakeyaml-api.hpi", + "ssh-credentials.hpi", + "structs.hpi", + "variant.hpi", + "workflow-api.hpi", + "workflow-step-api.hpi", + "workflow-support.hpi" + }) + public void maven_build_jar_with_explicit_findbugs_failure() throws Exception { + loadMavenJarProjectInGitRepo(this.gitRepoRule); + + // @formatter:off + String pipelineScript = "node() {\n" + + " git($/" + gitRepoRule.toString() + "/$)\n" + + " withMaven(options: [findbugsPublisher()], publisherStrategy: 'EXPLICIT') {\n" + + " if (isUnix()) {\n" + + " sh 'mvn package verify'\n" + + " } else {\n" + + " bat 'mvn package verify'\n" + + " }\n" + + " }\n" + + "}"; + // @formatter:on + + WorkflowJob pipeline = jenkinsRule.createProject(WorkflowJob.class, "jar-with-findbugs-explicit"); + pipeline.setDefinition(new CpsFlowDefinition(pipelineScript, true)); + WorkflowRun build = jenkinsRule.assertBuildStatus(Result.FAILURE, pipeline.scheduleBuild2(0)); + jenkinsRule.assertLogContains( + "The findbugsPublisher is deprecated as is the findbugs plugin and you should not use it", build); + } + + @Test + public void maven_build_jar_without_findbugs_success() throws Exception { + loadMavenJarProjectInGitRepo(this.gitRepoRule); + + // @formatter:off + String pipelineScript = "node() {\n" + + " git($/" + gitRepoRule.toString() + "/$)\n" + + " withMaven() {\n" + + " if (isUnix()) {\n" + + " sh 'mvn package verify'\n" + + " } else {\n" + + " bat 'mvn package verify'\n" + + " }\n" + + " }\n" + + "}"; + // @formatter:on + + WorkflowJob pipeline = jenkinsRule.createProject(WorkflowJob.class, "jar-without-findbugs"); + pipeline.setDefinition(new CpsFlowDefinition(pipelineScript, true)); + WorkflowRun build = jenkinsRule.assertBuildStatus(Result.SUCCESS, pipeline.scheduleBuild2(0)); + jenkinsRule.assertLogNotContains( + "[withMaven] Findbugs Publisher is no longer implicitly used with `withMaven` step.", build); + } +} diff --git a/pipeline-maven/src/test/java/org/jenkinsci/plugins/pipeline/maven/publishers/JacocoReportPublisherTest.java b/pipeline-maven/src/test/java/org/jenkinsci/plugins/pipeline/maven/publishers/JacocoReportPublisherTest.java index 6bc756a7e..8d4b05bfa 100644 --- a/pipeline-maven/src/test/java/org/jenkinsci/plugins/pipeline/maven/publishers/JacocoReportPublisherTest.java +++ b/pipeline-maven/src/test/java/org/jenkinsci/plugins/pipeline/maven/publishers/JacocoReportPublisherTest.java @@ -6,10 +6,52 @@ import org.jenkinsci.plugins.workflow.job.WorkflowJob; import org.jenkinsci.plugins.workflow.job.WorkflowRun; import org.junit.jupiter.api.Test; +import org.jvnet.hudson.test.recipes.WithPlugin; public class JacocoReportPublisherTest extends AbstractIntegrationTest { @Test + @WithPlugin({ + "jacoco.jpi", + "analysis-core.jpi", + "antisamy-markup-formatter.hpi", + "apache-httpcomponents-client-4-api.hpi", + "asm-api.hpi", + "bootstrap5-api.hpi", + "caffeine-api.hpi", + "checks-api.hpi", + "commons-lang3-api.hpi", + "commons-text-api.hpi", + "credentials.hpi", + "display-url-api.hpi", + "durable-task.hpi", + "echarts-api.hpi", + "font-awesome-api.hpi", + "ionicons-api.hpi", + "jackson2-api.hpi", + "jakarta-activation-api.hpi", + "jakarta-mail-api.hpi", + "javadoc.hpi", + "jquery3-api.hpi", + "jsch.hpi", + "json-api.hpi", + "jsoup.hpi", + "junit.hpi", + "mailer.hpi", + "matrix-project.hpi", + "maven-plugin.hpi", + "oss-symbols-api.hpi", + "plugin-util-api.hpi", + "scm-api.hpi", + "script-security.hpi", + "snakeyaml-api.hpi", + "ssh-credentials.hpi", + "structs.hpi", + "variant.hpi", + "workflow-api.hpi", + "workflow-step-api.hpi", + "workflow-support.hpi" + }) public void maven_build_jar_with_implicit_jacoco_success() throws Exception { loadSourceCodeInGitRepository( this.gitRepoRule, @@ -33,10 +75,51 @@ public void maven_build_jar_with_implicit_jacoco_success() throws Exception { pipeline.setDefinition(new CpsFlowDefinition(pipelineScript, true)); WorkflowRun build = jenkinsRule.assertBuildStatus(Result.SUCCESS, pipeline.scheduleBuild2(0)); jenkinsRule.assertLogContains( - "[withMaven] JacocoPublisher is no longer implicitly used with `withMaven` step.", build); + "[withMaven] Jacoco Publisher is no longer implicitly used with `withMaven` step.", build); } @Test + @WithPlugin({ + "jacoco.jpi", + "analysis-core.jpi", + "antisamy-markup-formatter.hpi", + "apache-httpcomponents-client-4-api.hpi", + "asm-api.hpi", + "bootstrap5-api.hpi", + "caffeine-api.hpi", + "checks-api.hpi", + "commons-lang3-api.hpi", + "commons-text-api.hpi", + "credentials.hpi", + "display-url-api.hpi", + "durable-task.hpi", + "echarts-api.hpi", + "font-awesome-api.hpi", + "ionicons-api.hpi", + "jackson2-api.hpi", + "jakarta-activation-api.hpi", + "jakarta-mail-api.hpi", + "javadoc.hpi", + "jquery3-api.hpi", + "jsch.hpi", + "json-api.hpi", + "jsoup.hpi", + "junit.hpi", + "mailer.hpi", + "matrix-project.hpi", + "maven-plugin.hpi", + "oss-symbols-api.hpi", + "plugin-util-api.hpi", + "scm-api.hpi", + "script-security.hpi", + "snakeyaml-api.hpi", + "ssh-credentials.hpi", + "structs.hpi", + "variant.hpi", + "workflow-api.hpi", + "workflow-step-api.hpi", + "workflow-support.hpi" + }) public void maven_build_jar_with_explicit_jacoco_failure() throws Exception { loadSourceCodeInGitRepository( this.gitRepoRule, @@ -55,10 +138,37 @@ public void maven_build_jar_with_explicit_jacoco_failure() throws Exception { "}"; // @formatter:on - WorkflowJob pipeline = jenkinsRule.createProject(WorkflowJob.class, "jar-with-jacoco"); + WorkflowJob pipeline = jenkinsRule.createProject(WorkflowJob.class, "jar-with-jacoco-explicit"); pipeline.setDefinition(new CpsFlowDefinition(pipelineScript, true)); WorkflowRun build = jenkinsRule.assertBuildStatus(Result.FAILURE, pipeline.scheduleBuild2(0)); jenkinsRule.assertLogContains( "The jacocoPublisher is deprecated as is the Jacoco plugin and you should not use it", build); } + + @Test + public void maven_build_jar_without_jacoco_success() throws Exception { + loadSourceCodeInGitRepository( + this.gitRepoRule, + "/org/jenkinsci/plugins/pipeline/maven/test/test_maven_projects/maven_jar_with_jacoco_project/"); + + // @formatter:off + String pipelineScript = "node() {\n" + + " git($/" + gitRepoRule.toString() + "/$)\n" + + " writeFile(encoding: 'UTF-8', file: '.skip-publish-coverage-results', text: '')\n" + + " withMaven() {\n" + + " if (isUnix()) {\n" + + " sh 'mvn package verify'\n" + + " } else {\n" + + " bat 'mvn package verify'\n" + + " }\n" + + " }\n" + + "}"; + // @formatter:on + + WorkflowJob pipeline = jenkinsRule.createProject(WorkflowJob.class, "jar-without-jacoco"); + pipeline.setDefinition(new CpsFlowDefinition(pipelineScript, true)); + WorkflowRun build = jenkinsRule.assertBuildStatus(Result.SUCCESS, pipeline.scheduleBuild2(0)); + jenkinsRule.assertLogNotContains( + "[withMaven] Jacoco Publisher is no longer implicitly used with `withMaven` step.", build); + } } diff --git a/pipeline-maven/src/test/java/org/jenkinsci/plugins/pipeline/maven/publishers/SpotBugsAnalysisPublisherTest.java b/pipeline-maven/src/test/java/org/jenkinsci/plugins/pipeline/maven/publishers/SpotBugsAnalysisPublisherTest.java new file mode 100644 index 000000000..84459196b --- /dev/null +++ b/pipeline-maven/src/test/java/org/jenkinsci/plugins/pipeline/maven/publishers/SpotBugsAnalysisPublisherTest.java @@ -0,0 +1,166 @@ +package org.jenkinsci.plugins.pipeline.maven.publishers; + +import hudson.model.Result; +import org.jenkinsci.plugins.pipeline.maven.AbstractIntegrationTest; +import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition; +import org.jenkinsci.plugins.workflow.job.WorkflowJob; +import org.jenkinsci.plugins.workflow.job.WorkflowRun; +import org.junit.jupiter.api.Test; +import org.jvnet.hudson.test.recipes.WithPlugin; + +public class SpotBugsAnalysisPublisherTest extends AbstractIntegrationTest { + + @Test + @WithPlugin({ + "findbugs.jpi", + "analysis-core.jpi", + "antisamy-markup-formatter.hpi", + "apache-httpcomponents-client-4-api.hpi", + "asm-api.hpi", + "bootstrap5-api.hpi", + "caffeine-api.hpi", + "checks-api.hpi", + "commons-lang3-api.hpi", + "commons-text-api.hpi", + "credentials.hpi", + "display-url-api.hpi", + "durable-task.hpi", + "echarts-api.hpi", + "font-awesome-api.hpi", + "ionicons-api.hpi", + "jackson2-api.hpi", + "jakarta-activation-api.hpi", + "jakarta-mail-api.hpi", + "javadoc.hpi", + "jquery3-api.hpi", + "jsch.hpi", + "json-api.hpi", + "jsoup.hpi", + "junit.hpi", + "mailer.hpi", + "matrix-project.hpi", + "maven-plugin.hpi", + "oss-symbols-api.hpi", + "plugin-util-api.hpi", + "scm-api.hpi", + "script-security.hpi", + "snakeyaml-api.hpi", + "ssh-credentials.hpi", + "structs.hpi", + "variant.hpi", + "workflow-api.hpi", + "workflow-step-api.hpi", + "workflow-support.hpi" + }) + public void maven_build_jar_with_implicit_spotbugs_success() throws Exception { + loadMavenJarProjectInGitRepo(this.gitRepoRule); + + // @formatter:off + String pipelineScript = "node() {\n" + + " git($/" + gitRepoRule.toString() + "/$)\n" + + " withMaven() {\n" + + " if (isUnix()) {\n" + + " sh 'mvn package verify'\n" + + " } else {\n" + + " bat 'mvn package verify'\n" + + " }\n" + + " }\n" + + "}"; + // @formatter:on + + WorkflowJob pipeline = jenkinsRule.createProject(WorkflowJob.class, "jar-with-spotbugs"); + pipeline.setDefinition(new CpsFlowDefinition(pipelineScript, true)); + WorkflowRun build = jenkinsRule.assertBuildStatus(Result.SUCCESS, pipeline.scheduleBuild2(0)); + jenkinsRule.assertLogContains( + "[withMaven] SpotBugs Publisher is no longer implicitly used with `withMaven` step.", build); + } + + @Test + @WithPlugin({ + "findbugs.jpi", + "analysis-core.jpi", + "antisamy-markup-formatter.hpi", + "apache-httpcomponents-client-4-api.hpi", + "asm-api.hpi", + "bootstrap5-api.hpi", + "caffeine-api.hpi", + "checks-api.hpi", + "commons-lang3-api.hpi", + "commons-text-api.hpi", + "credentials.hpi", + "display-url-api.hpi", + "durable-task.hpi", + "echarts-api.hpi", + "font-awesome-api.hpi", + "ionicons-api.hpi", + "jackson2-api.hpi", + "jakarta-activation-api.hpi", + "jakarta-mail-api.hpi", + "javadoc.hpi", + "jquery3-api.hpi", + "jsch.hpi", + "json-api.hpi", + "jsoup.hpi", + "junit.hpi", + "mailer.hpi", + "matrix-project.hpi", + "maven-plugin.hpi", + "oss-symbols-api.hpi", + "plugin-util-api.hpi", + "scm-api.hpi", + "script-security.hpi", + "snakeyaml-api.hpi", + "ssh-credentials.hpi", + "structs.hpi", + "variant.hpi", + "workflow-api.hpi", + "workflow-step-api.hpi", + "workflow-support.hpi" + }) + public void maven_build_jar_with_explicit_spotbugs_failure() throws Exception { + loadMavenJarProjectInGitRepo(this.gitRepoRule); + + // @formatter:off + String pipelineScript = "node() {\n" + + " git($/" + gitRepoRule.toString() + "/$)\n" + + " withMaven(options: [spotbugsPublisher()], publisherStrategy: 'EXPLICIT') {\n" + + " if (isUnix()) {\n" + + " sh 'mvn package verify'\n" + + " } else {\n" + + " bat 'mvn package verify'\n" + + " }\n" + + " }\n" + + "}"; + // @formatter:on + + WorkflowJob pipeline = jenkinsRule.createProject(WorkflowJob.class, "jar-with-spotbugs-explicit"); + pipeline.setDefinition(new CpsFlowDefinition(pipelineScript, true)); + WorkflowRun build = jenkinsRule.assertBuildStatus(Result.FAILURE, pipeline.scheduleBuild2(0)); + jenkinsRule.assertLogContains( + "The spotbugsPublisher is deprecated as is the findbugs plugin and you should not use it", build); + } + + @Test + public void maven_build_jar_without_spotbugs_success() throws Exception { + loadMavenJarProjectInGitRepo(this.gitRepoRule); + + // @formatter:off + String pipelineScript = "node() {\n" + + " git($/" + gitRepoRule.toString() + "/$)\n" + + " withMaven() {\n" + + " if (isUnix()) {\n" + + " sh 'mvn package verify'\n" + + " } else {\n" + + " bat 'mvn package verify'\n" + + " }\n" + + " }\n" + + "}"; + // @formatter:on + + WorkflowJob pipeline = jenkinsRule.createProject(WorkflowJob.class, "jar-without-spotbugs"); + pipeline.setDefinition(new CpsFlowDefinition(pipelineScript, true)); + WorkflowRun build = jenkinsRule.assertBuildStatus(Result.SUCCESS, pipeline.scheduleBuild2(0)); + jenkinsRule.assertLogNotContains( + "[withMaven] SpotBugs Publisher is no longer implicitly used with `withMaven` step.", build); + } +} diff --git a/pipeline-maven/src/test/java/org/jenkinsci/plugins/pipeline/maven/publishers/TasksScannerPublisherTest.java b/pipeline-maven/src/test/java/org/jenkinsci/plugins/pipeline/maven/publishers/TasksScannerPublisherTest.java new file mode 100644 index 000000000..35848e6e0 --- /dev/null +++ b/pipeline-maven/src/test/java/org/jenkinsci/plugins/pipeline/maven/publishers/TasksScannerPublisherTest.java @@ -0,0 +1,166 @@ +package org.jenkinsci.plugins.pipeline.maven.publishers; + +import hudson.model.Result; +import org.jenkinsci.plugins.pipeline.maven.AbstractIntegrationTest; +import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition; +import org.jenkinsci.plugins.workflow.job.WorkflowJob; +import org.jenkinsci.plugins.workflow.job.WorkflowRun; +import org.junit.jupiter.api.Test; +import org.jvnet.hudson.test.recipes.WithPlugin; + +public class TasksScannerPublisherTest extends AbstractIntegrationTest { + + @Test + @WithPlugin({ + "tasks.jpi", + "analysis-core.jpi", + "antisamy-markup-formatter.hpi", + "apache-httpcomponents-client-4-api.hpi", + "asm-api.hpi", + "bootstrap5-api.hpi", + "caffeine-api.hpi", + "checks-api.hpi", + "commons-lang3-api.hpi", + "commons-text-api.hpi", + "credentials.hpi", + "display-url-api.hpi", + "durable-task.hpi", + "echarts-api.hpi", + "font-awesome-api.hpi", + "ionicons-api.hpi", + "jackson2-api.hpi", + "jakarta-activation-api.hpi", + "jakarta-mail-api.hpi", + "javadoc.hpi", + "jquery3-api.hpi", + "jsch.hpi", + "json-api.hpi", + "jsoup.hpi", + "junit.hpi", + "mailer.hpi", + "matrix-project.hpi", + "maven-plugin.hpi", + "oss-symbols-api.hpi", + "plugin-util-api.hpi", + "scm-api.hpi", + "script-security.hpi", + "snakeyaml-api.hpi", + "ssh-credentials.hpi", + "structs.hpi", + "variant.hpi", + "workflow-api.hpi", + "workflow-step-api.hpi", + "workflow-support.hpi" + }) + public void maven_build_jar_with_implicit_tasks_success() throws Exception { + loadMavenJarProjectInGitRepo(this.gitRepoRule); + + // @formatter:off + String pipelineScript = "node() {\n" + + " git($/" + gitRepoRule.toString() + "/$)\n" + + " withMaven() {\n" + + " if (isUnix()) {\n" + + " sh 'mvn package verify'\n" + + " } else {\n" + + " bat 'mvn package verify'\n" + + " }\n" + + " }\n" + + "}"; + // @formatter:on + + WorkflowJob pipeline = jenkinsRule.createProject(WorkflowJob.class, "jar-with-tasks"); + pipeline.setDefinition(new CpsFlowDefinition(pipelineScript, true)); + WorkflowRun build = jenkinsRule.assertBuildStatus(Result.SUCCESS, pipeline.scheduleBuild2(0)); + jenkinsRule.assertLogContains( + "[withMaven] Open Task Scanner Publisher is no longer implicitly used with `withMaven` step.", build); + } + + @Test + @WithPlugin({ + "tasks.jpi", + "analysis-core.jpi", + "antisamy-markup-formatter.hpi", + "apache-httpcomponents-client-4-api.hpi", + "asm-api.hpi", + "bootstrap5-api.hpi", + "caffeine-api.hpi", + "checks-api.hpi", + "commons-lang3-api.hpi", + "commons-text-api.hpi", + "credentials.hpi", + "display-url-api.hpi", + "durable-task.hpi", + "echarts-api.hpi", + "font-awesome-api.hpi", + "ionicons-api.hpi", + "jackson2-api.hpi", + "jakarta-activation-api.hpi", + "jakarta-mail-api.hpi", + "javadoc.hpi", + "jquery3-api.hpi", + "jsch.hpi", + "json-api.hpi", + "jsoup.hpi", + "junit.hpi", + "mailer.hpi", + "matrix-project.hpi", + "maven-plugin.hpi", + "oss-symbols-api.hpi", + "plugin-util-api.hpi", + "scm-api.hpi", + "script-security.hpi", + "snakeyaml-api.hpi", + "ssh-credentials.hpi", + "structs.hpi", + "variant.hpi", + "workflow-api.hpi", + "workflow-step-api.hpi", + "workflow-support.hpi" + }) + public void maven_build_jar_with_explicit_tasks_failure() throws Exception { + loadMavenJarProjectInGitRepo(this.gitRepoRule); + + // @formatter:off + String pipelineScript = "node() {\n" + + " git($/" + gitRepoRule.toString() + "/$)\n" + + " withMaven(options: [openTasksPublisher()], publisherStrategy: 'EXPLICIT') {\n" + + " if (isUnix()) {\n" + + " sh 'mvn package verify'\n" + + " } else {\n" + + " bat 'mvn package verify'\n" + + " }\n" + + " }\n" + + "}"; + // @formatter:on + + WorkflowJob pipeline = jenkinsRule.createProject(WorkflowJob.class, "jar-with-tasks-explicit"); + pipeline.setDefinition(new CpsFlowDefinition(pipelineScript, true)); + WorkflowRun build = jenkinsRule.assertBuildStatus(Result.FAILURE, pipeline.scheduleBuild2(0)); + jenkinsRule.assertLogContains( + "The openTasksPublisher is deprecated as is the tasks plugin and you should not use it", build); + } + + @Test + public void maven_build_jar_without_tasks_success() throws Exception { + loadMavenJarProjectInGitRepo(this.gitRepoRule); + + // @formatter:off + String pipelineScript = "node() {\n" + + " git($/" + gitRepoRule.toString() + "/$)\n" + + " withMaven() {\n" + + " if (isUnix()) {\n" + + " sh 'mvn package verify'\n" + + " } else {\n" + + " bat 'mvn package verify'\n" + + " }\n" + + " }\n" + + "}"; + // @formatter:on + + WorkflowJob pipeline = jenkinsRule.createProject(WorkflowJob.class, "jar-without-tasks"); + pipeline.setDefinition(new CpsFlowDefinition(pipelineScript, true)); + WorkflowRun build = jenkinsRule.assertBuildStatus(Result.SUCCESS, pipeline.scheduleBuild2(0)); + jenkinsRule.assertLogNotContains( + "[withMaven] Open Task Scanner Publisher is no longer implicitly used with `withMaven` step.", build); + } +} diff --git a/pipeline-maven/src/test/java/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisherTest.java b/pipeline-maven/src/test/java/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisherTest.java new file mode 100644 index 000000000..2a8d91d80 --- /dev/null +++ b/pipeline-maven/src/test/java/org/jenkinsci/plugins/pipeline/maven/publishers/WarningsPublisherTest.java @@ -0,0 +1,286 @@ +package org.jenkinsci.plugins.pipeline.maven.publishers; + +import static org.assertj.core.api.Assertions.assertThat; + +import hudson.model.JDK; +import hudson.model.Result; +import hudson.tools.ToolLocationNodeProperty; +import io.jenkins.plugins.analysis.core.model.ResultAction; +import java.util.List; +import java.util.Objects; +import org.jenkinsci.plugins.pipeline.maven.AbstractIntegrationTest; +import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition; +import org.jenkinsci.plugins.workflow.job.WorkflowJob; +import org.jenkinsci.plugins.workflow.job.WorkflowRun; +import org.junit.jupiter.api.Test; +import org.testcontainers.containers.GenericContainer; +import org.testcontainers.junit.jupiter.Testcontainers; + +@Testcontainers(disabledWithoutDocker = true) +public class WarningsPublisherTest extends AbstractIntegrationTest { + + @Test + public void maven_build_jar_with_maven_succeeds() throws Exception { + loadMavenJarProjectInGitRepo(this.gitRepoRule); + + // @formatter:off + String pipelineScript = "node() {\n" + + " git($/" + gitRepoRule.toString() + "/$)\n" + + " withMaven() {\n" + + " if (isUnix()) {\n" + + " sh 'mvn package verify'\n" + + " } else {\n" + + " bat 'mvn package verify'\n" + + " }\n" + + " }\n" + + "}"; + // @formatter:on + + WorkflowJob pipeline = jenkinsRule.createProject(WorkflowJob.class, "maven_console"); + pipeline.setDefinition(new CpsFlowDefinition(pipelineScript, true)); + WorkflowRun build = jenkinsRule.assertBuildStatus(Result.SUCCESS, pipeline.scheduleBuild2(0)); + + jenkinsRule.assertLogContains("[withMaven] warningsPublisher - Processing Maven console warnings", build); + List resultActions = build.getActions(ResultAction.class); + assertThat(resultActions).hasSize(4); + ResultAction resultAction = resultActions.get(0); + assertThat(resultAction.getProjectActions()).hasSize(1); + assertThat(resultAction.getQualityGateResult()).isNotNull(); + assertThat(resultAction.getResult().getTotalSize()).isEqualTo(2); + } + + @Test + public void maven_build_jar_with_java_javadoc_succeeds() throws Exception { + loadMavenJarProjectInGitRepo(this.gitRepoRule); + + // @formatter:off + String pipelineScript = "node() {\n" + + " git($/" + gitRepoRule.toString() + "/$)\n" + + " withMaven() {\n" + + " if (isUnix()) {\n" + + " sh 'mvn package verify'\n" + + " } else {\n" + + " bat 'mvn package verify'\n" + + " }\n" + + " }\n" + + "}"; + // @formatter:on + + WorkflowJob pipeline = jenkinsRule.createProject(WorkflowJob.class, "java_javadoc"); + pipeline.setDefinition(new CpsFlowDefinition(pipelineScript, true)); + WorkflowRun build = jenkinsRule.assertBuildStatus(Result.SUCCESS, pipeline.scheduleBuild2(0)); + + jenkinsRule.assertLogContains("[withMaven] warningsPublisher - Processing Java and JavaDoc warnings", build); + List resultActions = build.getActions(ResultAction.class); + assertThat(resultActions).hasSize(4); + ResultAction resultAction = resultActions.get(1); + assertThat(resultAction.getProjectActions()).hasSize(1); + assertThat(resultAction.getQualityGateResult()).isNotNull(); + assertThat(resultAction.getResult().getTotalSize()).isEqualTo(0); + resultAction = resultActions.get(2); + assertThat(resultAction.getProjectActions()).hasSize(1); + assertThat(resultAction.getQualityGateResult()).isNotNull(); + assertThat(resultAction.getResult().getTotalSize()).isEqualTo(0); + } + + @Test + public void maven_build_jar_with_tasks_succeeds() throws Exception { + loadMavenJarProjectInGitRepo(this.gitRepoRule); + + // @formatter:off + String pipelineScript = "node() {\n" + + " git($/" + gitRepoRule.toString() + "/$)\n" + + " withMaven() {\n" + + " if (isUnix()) {\n" + + " sh 'mvn package verify'\n" + + " } else {\n" + + " bat 'mvn package verify'\n" + + " }\n" + + " }\n" + + "}"; + // @formatter:on + + WorkflowJob pipeline = jenkinsRule.createProject(WorkflowJob.class, "tasks"); + pipeline.setDefinition(new CpsFlowDefinition(pipelineScript, true)); + WorkflowRun build = jenkinsRule.assertBuildStatus(Result.SUCCESS, pipeline.scheduleBuild2(0)); + + jenkinsRule.assertLogContains("[withMaven] warningsPublisher - Processing Open tasks warnings", build); + jenkinsRule.assertLogContains("Scanning all 3 files for open tasks", build); + List resultActions = build.getActions(ResultAction.class); + assertThat(resultActions).hasSize(4); + ResultAction resultAction = resultActions.get(3); + assertThat(resultAction.getProjectActions()).hasSize(1); + assertThat(resultAction.getQualityGateResult()).isNotNull(); + assertThat(resultAction.getResult().getTotalHighPrioritySize()).isEqualTo(0); + assertThat(resultAction.getResult().getTotalNormalPrioritySize()).isEqualTo(1); + } + + @Test + public void maven_build_jar_with_spotbugs_succeeds() throws Exception { + loadMavenJarProjectInGitRepo(this.gitRepoRule); + + // @formatter:off + String pipelineScript = "node() {\n" + + " git($/" + gitRepoRule.toString() + "/$)\n" + + " withMaven() {\n" + + " if (isUnix()) {\n" + + " sh 'mvn package verify com.github.spotbugs:spotbugs-maven-plugin:check'\n" + + " } else {\n" + + " bat 'mvn package verify com.github.spotbugs:spotbugs-maven-plugin:check'\n" + + " }\n" + + " }\n" + + "}"; + // @formatter:on + + WorkflowJob pipeline = jenkinsRule.createProject(WorkflowJob.class, "spotbugs"); + pipeline.setDefinition(new CpsFlowDefinition(pipelineScript, true)); + WorkflowRun build = jenkinsRule.assertBuildStatus(Result.SUCCESS, pipeline.scheduleBuild2(0)); + + jenkinsRule.assertLogContains("[withMaven] warningsPublisher - Processing spotbugs warnings", build); + jenkinsRule.assertLogContains("Successfully processed file 'target/spotbugsXml.xml'", build); + List resultActions = build.getActions(ResultAction.class); + assertThat(resultActions).hasSize(5); + ResultAction resultAction = resultActions.get(4); + assertThat(resultAction.getProjectActions()).hasSize(1); + assertThat(resultAction.getQualityGateResult()).isNotNull(); + assertThat(resultAction.getResult().getTotalSize()).isEqualTo(0); + } + + @Test + public void maven_build_jar_with_findbugs_succeeds() throws Exception { + String jdkName = "jdk8"; + String jdkPath = "/opt/java/jdk8"; + + try (GenericContainer javasContainerRule = createContainer("javas")) { + javasContainerRule.start(); + + loadMavenJarProjectInGitRepo(this.gitRepoRule); + + String containerPath = exposeGitRepositoryIntoAgent(javasContainerRule); + registerAgentForContainer(javasContainerRule); + ToolLocationNodeProperty.ToolLocation toolLocation = + new ToolLocationNodeProperty.ToolLocation(new JDK.DescriptorImpl(), jdkName, jdkPath); + ToolLocationNodeProperty toolLocationNodeProperty = new ToolLocationNodeProperty(toolLocation); + Objects.requireNonNull(jenkinsRule.jenkins.getNode(AGENT_NAME)) + .getNodeProperties() + .add(toolLocationNodeProperty); + + jenkinsRule.jenkins.getJDKs().add(new JDK(jdkName, jdkPath)); + + // @formatter:off + String pipelineScript = "node('" + AGENT_NAME + "') {\n" + + " git('" + containerPath + "')\n" + + " withMaven(jdk: '" + jdkName + "') {\n" + + " sh 'mvn package verify org.codehaus.mojo:findbugs-maven-plugin:check'\n" + + " }\n" + + "}"; + // @formatter:on + + WorkflowJob pipeline = jenkinsRule.createProject(WorkflowJob.class, "findbugs"); + pipeline.setDefinition(new CpsFlowDefinition(pipelineScript, true)); + WorkflowRun build = jenkinsRule.assertBuildStatus(Result.SUCCESS, pipeline.scheduleBuild2(0)); + + jenkinsRule.assertLogContains("[withMaven] warningsPublisher - Processing findbugs warnings", build); + jenkinsRule.assertLogContains("Successfully processed file 'target/findbugsXml.xml'", build); + List resultActions = build.getActions(ResultAction.class); + assertThat(resultActions).hasSize(5); + ResultAction resultAction = resultActions.get(4); + assertThat(resultAction.getProjectActions()).hasSize(1); + assertThat(resultAction.getQualityGateResult()).isNotNull(); + assertThat(resultAction.getResult().getTotalSize()).isEqualTo(0); + } + } + + @Test + public void maven_build_jar_with_pmd_succeeds() throws Exception { + loadMavenJarProjectInGitRepo(this.gitRepoRule); + + // @formatter:off + String pipelineScript = "node() {\n" + + " git($/" + gitRepoRule.toString() + "/$)\n" + + " withMaven() {\n" + + " if (isUnix()) {\n" + + " sh 'mvn package verify pmd:pmd'\n" + + " } else {\n" + + " bat 'mvn package verify pmd:pmd'\n" + + " }\n" + + " }\n" + + "}"; + // @formatter:on + + WorkflowJob pipeline = jenkinsRule.createProject(WorkflowJob.class, "pmd"); + pipeline.setDefinition(new CpsFlowDefinition(pipelineScript, true)); + WorkflowRun build = jenkinsRule.assertBuildStatus(Result.SUCCESS, pipeline.scheduleBuild2(0)); + + jenkinsRule.assertLogContains("[withMaven] warningsPublisher - Processing pmd warnings", build); + jenkinsRule.assertLogContains("Successfully processed file 'target/pmd.xml'", build); + List resultActions = build.getActions(ResultAction.class); + assertThat(resultActions).hasSize(5); + ResultAction resultAction = resultActions.get(4); + assertThat(resultAction.getProjectActions()).hasSize(1); + assertThat(resultAction.getQualityGateResult()).isNotNull(); + assertThat(resultAction.getResult().getTotalSize()).isEqualTo(0); + } + + @Test + public void maven_build_jar_with_cpd_succeeds() throws Exception { + loadMavenJarProjectInGitRepo(this.gitRepoRule); + + // @formatter:off + String pipelineScript = "node() {\n" + + " git($/" + gitRepoRule.toString() + "/$)\n" + + " withMaven() {\n" + + " if (isUnix()) {\n" + + " sh 'mvn package verify pmd:cpd'\n" + + " } else {\n" + + " bat 'mvn package verify pmd:cpd'\n" + + " }\n" + + " }\n" + + "}"; + // @formatter:on + + WorkflowJob pipeline = jenkinsRule.createProject(WorkflowJob.class, "cpd"); + pipeline.setDefinition(new CpsFlowDefinition(pipelineScript, true)); + WorkflowRun build = jenkinsRule.assertBuildStatus(Result.SUCCESS, pipeline.scheduleBuild2(0)); + + jenkinsRule.assertLogContains("[withMaven] warningsPublisher - Processing cpd warnings", build); + jenkinsRule.assertLogContains("Successfully processed file 'target/cpd.xml'", build); + List resultActions = build.getActions(ResultAction.class); + assertThat(resultActions).hasSize(5); + ResultAction resultAction = resultActions.get(4); + assertThat(resultAction.getProjectActions()).hasSize(1); + assertThat(resultAction.getQualityGateResult()).isNotNull(); + assertThat(resultAction.getResult().getTotalSize()).isEqualTo(0); + } + + @Test + public void maven_build_jar_with_checkstyle_succeeds() throws Exception { + loadMavenJarProjectInGitRepo(this.gitRepoRule); + + // @formatter:off + String pipelineScript = "node() {\n" + + " git($/" + gitRepoRule.toString() + "/$)\n" + + " withMaven() {\n" + + " if (isUnix()) {\n" + + " sh 'mvn package verify checkstyle:checkstyle'\n" + + " } else {\n" + + " bat 'mvn package verify checkstyle:checkstyle'\n" + + " }\n" + + " }\n" + + "}"; + // @formatter:on + + WorkflowJob pipeline = jenkinsRule.createProject(WorkflowJob.class, "checkstyle"); + pipeline.setDefinition(new CpsFlowDefinition(pipelineScript, true)); + WorkflowRun build = jenkinsRule.assertBuildStatus(Result.SUCCESS, pipeline.scheduleBuild2(0)); + + jenkinsRule.assertLogContains("[withMaven] warningsPublisher - Processing checkstyle warnings", build); + jenkinsRule.assertLogContains("Successfully processed file 'target/checkstyle-result.xml'", build); + List resultActions = build.getActions(ResultAction.class); + assertThat(resultActions).hasSize(5); + ResultAction resultAction = resultActions.get(4); + assertThat(resultAction.getProjectActions()).hasSize(1); + assertThat(resultAction.getQualityGateResult()).isNotNull(); + assertThat(resultAction.getResult().getTotalSize()).isEqualTo(5); + } +} diff --git a/pipeline-maven/src/test/resources/org/jenkinsci/plugins/pipeline/maven/configuration-as-code_publishers.yml b/pipeline-maven/src/test/resources/org/jenkinsci/plugins/pipeline/maven/configuration-as-code_publishers.yml index 346d48e24..e7676c51b 100644 --- a/pipeline-maven/src/test/resources/org/jenkinsci/plugins/pipeline/maven/configuration-as-code_publishers.yml +++ b/pipeline-maven/src/test/resources/org/jenkinsci/plugins/pipeline/maven/configuration-as-code_publishers.yml @@ -16,11 +16,6 @@ tool: includeReleaseVersions: true includeScopeCompile: false includeScopeTest: true - - findbugsPublisher: - disabled: true - healthy: "5" - thresholdLimit: "high" - unHealthy: "15" - artifactsPublisher: disabled: true - invokerPublisher: @@ -34,18 +29,6 @@ tool: keepLongStdio: true - mavenLinkerPublisher: disabled: true - - openTasksPublisher: - asRegexp: true - disabled: true - excludePattern: "**/*.xml" - healthy: "5" - highPriorityTaskIdentifiers: "task1,task2" - ignoreCase: true - lowPriorityTaskIdentifiers: "task4" - normalPriorityTaskIdentifiers: "task3" - pattern: "**/*.java" - thresholdLimit: "normal" - unHealthy: "15" - pipelineGraphPublisher: disabled: true ignoreUpstreamTriggers: true @@ -53,8 +36,17 @@ tool: includeScopeTest: true lifecycleThreshold: "install" skipDownstreamTriggers: true - - spotbugsPublisher: - disabled: true - healthy: "5" - thresholdLimit: "high" - unHealthy: "15" + - warningsPublisher: + disabled: true + enabledForFailure: false + highPriorityTaskIdentifiers: "FIX" + javaIgnorePatterns: "**/*Test.java" + normalPriorityTaskIdentifiers: "TO-DO" + qualityGateCriticality: "ERROR" + qualityGateThreshold: 10 + qualityGateType: "DELTA" + skipBlames: false + sourceCodeEncoding: "ISO-8859-15" + tasksExcludePattern: "**/target/*.*" + tasksIncludePattern: "**/*.*" + trendChartType: "NONE" diff --git a/pipeline-maven/src/test/resources/org/jenkinsci/plugins/pipeline/maven/expected_output_publishers.yml b/pipeline-maven/src/test/resources/org/jenkinsci/plugins/pipeline/maven/expected_output_publishers.yml index 29d3f74da..763641fc6 100644 --- a/pipeline-maven/src/test/resources/org/jenkinsci/plugins/pipeline/maven/expected_output_publishers.yml +++ b/pipeline-maven/src/test/resources/org/jenkinsci/plugins/pipeline/maven/expected_output_publishers.yml @@ -12,11 +12,6 @@ publisherOptions: includeReleaseVersions: true includeScopeCompile: false includeScopeTest: true -- findbugsPublisher: - disabled: true - healthy: "5" - thresholdLimit: "high" - unHealthy: "15" - artifactsPublisher: disabled: true - invokerPublisher: @@ -30,18 +25,6 @@ publisherOptions: keepLongStdio: true - mavenLinkerPublisher: disabled: true -- openTasksPublisher: - asRegexp: true - disabled: true - excludePattern: "**/*.xml" - healthy: "5" - highPriorityTaskIdentifiers: "task1,task2" - ignoreCase: true - lowPriorityTaskIdentifiers: "task4" - normalPriorityTaskIdentifiers: "task3" - pattern: "**/*.java" - thresholdLimit: "normal" - unHealthy: "15" - pipelineGraphPublisher: disabled: true ignoreUpstreamTriggers: true @@ -49,11 +32,20 @@ publisherOptions: includeScopeTest: true lifecycleThreshold: "install" skipDownstreamTriggers: true -- spotbugsPublisher: - disabled: true - healthy: "5" - thresholdLimit: "high" - unHealthy: "15" +- warningsPublisher: + disabled: true + enabledForFailure: false + highPriorityTaskIdentifiers: "FIX" + javaIgnorePatterns: "**/*Test.java" + normalPriorityTaskIdentifiers: "TO-DO" + qualityGateCriticality: ERROR + qualityGateThreshold: 10 + qualityGateType: DELTA + skipBlames: false + sourceCodeEncoding: "ISO-8859-15" + tasksExcludePattern: "**/target/*.*" + tasksIncludePattern: "**/*.*" + trendChartType: NONE triggerDownstreamUponResultAborted: false triggerDownstreamUponResultFailure: false triggerDownstreamUponResultNotBuilt: false diff --git a/pom.xml b/pom.xml index 31c5575e8..eba5f546b 100644 --- a/pom.xml +++ b/pom.xml @@ -97,10 +97,8 @@ 2.4.0 3.30.2-GA 6133.v358d9a_47674f - 5.0.0 0.15.1 2.5 - 4.53 5165.vdfd66a_57c648 2.492