Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 20 additions & 30 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
Expand Down Expand Up @@ -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
}
}
}
Expand Down Expand Up @@ -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.
+
Expand Down Expand Up @@ -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.

Expand All @@ -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.
Expand Down Expand Up @@ -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`
Expand All @@ -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]
Expand Down
3 changes: 1 addition & 2 deletions pipeline-maven-ui-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<name>UI Tests of Pipeline Maven Integration Plugin</name>

<properties>
<argLine>-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</argLine>
<argLine>-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</argLine>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should not need any argLine at all.
If you need to change a timeout globaly pass jenkins.test.timeout as a SystemProperty to surefire.
(arglines are set by the parent pom and can change / add over time if changes are needed.)

Surefire shouldn't need 1GB of RAM for example - The UI tests are not even using JenkinsRule type tests but the OSS ATH framework - so timeout here should also be immaterial!?

<browser>firefox-container</browser>
</properties>

Expand Down Expand Up @@ -112,7 +112,6 @@
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand All @@ -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");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would have this page should be generic for all publishers and specific publisher functionality / options should be in a sepearate page area for that Publisher. (e.g. see Credentials -> https://github.com/jenkinsci/acceptance-test-harness/blob/master/src/main/java/org/jenkinsci/test/acceptance/plugins/credentials/StringCredentials.java)

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);
}
Expand Down Expand Up @@ -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;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -50,7 +53,8 @@
.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);
Expand Down Expand Up @@ -645,6 +649,70 @@
}""");
}

@Test
public void defaultWarningsPublisherTest() throws InterruptedException {
WithMavenSnippetGenerator snippetGenerator = createSnippetGenerator();

snippetGenerator.selectWithMaven().addPublisher("Warnings Publisher");

assertThat(snippetGenerator.generateScript())
.isEqualTo("""
withMaven(options: [warningsPublisher()], traceability: true) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this would appear incorrect.
you have used the defaults but with a specific publisher and yet traceability: true is present. if this is a default it should not have been generated by the snippet generator.

// 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")

Check warning on line 678 in pipeline-maven-ui-tests/src/test/java/org/jenkinsci/plugins/maven/GlobalSnippetGeneratorUiTest.java

View check run for this annotation

ci.jenkins.io / Open Tasks Scanner

FIXME

HIGH: ")
.setNormalPriorityTaskIdentifiers("TODO")

Check warning on line 679 in pipeline-maven-ui-tests/src/test/java/org/jenkinsci/plugins/maven/GlobalSnippetGeneratorUiTest.java

View check run for this annotation

ci.jenkins.io / Open Tasks Scanner

TODO

NORMAL: ")
.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();
Expand Down
Loading
Loading