2017-08-17 6 views
0

Ich habe die folgende pom.xml-Datei geschrieben, die einen Checkstyle-Report/Tend-Graph erstellen und den Build-Preozess abbrechen soll, wenn es einige Checkstyle-Warnungen gibt.Jenkins/Maven checkstyle: Einchecken pom.xml funktioniert nicht

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 

    <groupId>test</groupId> 
    <artifactId>test</artifactId> 
    <version>0.0.1-SNAPSHOT</version> 
    <packaging>jar</packaging> 

    <name>test</name> 
    <url>http://maven.apache.org</url> 

    <properties> 
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
    </properties> 

    <dependencies> 
    <dependency> 
     <groupId>junit</groupId> 
     <artifactId>junit</artifactId> 
     <version>3.8.1</version> 
     <scope>test</scope> 
    </dependency> 
    </dependencies> 
    <reporting> 
    <plugins> 
     <plugin> 
     <groupId>org.apache.maven.plugins</groupId> 
     <artifactId>maven-checkstyle-plugin</artifactId> 
     <version>2.8</version> 
     <reportSets> 
      <reportSet> 
       <reports> 
       <report>checkstyle</report> 
       </reports> 
      </reportSet> 
      </reportSets> 
      <configuration> 
      <configLocation>https://dustplanet.de/checkstyle.xml</configLocation> 
     </configuration> 
     </plugin> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-project-info-reports-plugin</artifactId> 
      <version>2.7</version> 
     </plugin> 
    </plugins> 
    </reporting> 
    <build> 
    <pluginManagement> 
     <plugins> 
     <plugin> 
      <groupId>org.apache.maven.plugin</groupId> 
      <artifactId>maven-checkstyle-plugin</artifactId> 
      <version>2.17</version> 
      <executions> 
      <execution> 
       <phase>validate</phase> 
       <goals> 
        <goal>check</goal> 
       </goals> 
       <configuration> 
        <consoleOutput>true</consoleOutput> 
        <failsOnError>true</failsOnError> 
        <failOnViolation>true</failOnViolation> 
       </configuration> 
      </execution> 
     </executions> 
     </plugin> 
     </plugins> 
     </pluginManagement> 
     <plugins> 
     <plugin> 
     <groupId>org.apache.maven.plugins</groupId> 
     <artifactId>maven-checkstyle-plugin</artifactId> 
     <version>2.17</version> 
     </plugin> 
    </plugins> 
    </build> 

</project> 

Das Problem ist, wenn ich das Maven-Projekt mit jenkins und dieses Maven Ziele bauen clean install das Projekt gebaut wird, aber das Plugin nicht check ausgeführt gerät. Also habe ich clean install site verwendet. Mit site wurden ein Bericht und ein Tend-Diagramm erstellt, aber der Build-Prozess wird nicht gestoppt. Danach habe ich clean install site checkstyle:check -Dcheckstyle.config.location="https://dustplanet.de/checkstyle.xml" verwendet, so dass mein Build-Prozess fehlgeschlagen ist, aber das Analyseergebnis sowie das Diagramm tend zeigen keinen Checkstyle-Fehler, obwohl ein Bericht im Zielverzeichnis und das Kontrollkästchen für die Analyse erstellt wurde Die Konfiguration des Jobs ist aktiviert. Dies ist die Konsole Ausgang des letzten Build:

Started by timer 
[EnvInject] - Loading node environment variables. 
Building in workspace /var/lib/jenkins/workspace/MavenProject2 
> git rev-parse --is-inside-work-tree # timeout=10 
Fetching changes from the remote Git repository 
> git config remote.origin.url [email protected]:SysKit/SYSKIT.git # timeout=10 
Fetching upstream changes from [email protected]:SysKit/SYSKIT.git 
> git --version # timeout=10 
using GIT_SSH to set credentials 
> git fetch --tags --progress [email protected]:SysKit/SYSKIT.git +refs/heads/*:refs/remotes/origin/* +refs/merge-requests/*/head:refs/remotes/origin/merge-requests/* 
> git rev-parse origin/master^{commit} # timeout=10 
Checking out Revision 11d0f4105661346b7577fa223fe0f4063572fb99 (origin/master) 
Commit message: "test" 
> git config core.sparsecheckout # timeout=10 
> git checkout -f 11d0f4105661346b7577fa223fe0f4063572fb99 
> git rev-list 11d0f4105661346b7577fa223fe0f4063572fb99 # timeout=10 
Parsing POMs 
Established TCP socket on 35703 
[test] $ java -cp /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven33-agent-1.11.jar:/opt/maven/boot/plexus-classworlds-2.5.2.jar:/opt/maven/conf/logging jenkins.maven3.agent.Maven33Main /opt/maven /var/cache/jenkins/war/WEB-INF/lib/remoting-3.7.jar /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven33-interceptor-1.11.jar /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-commons-1.11.jar 35703 
<===[JENKINS REMOTING CAPACITY]===>channel started 
Executing Maven: -B -f /var/lib/jenkins/workspace/MavenProject2/test/pom.xml site clean install checkstyle:check -Dcheckstyle.config.location=https://dustplanet.de/checkstyle.xml 
[INFO] Scanning for projects... 
[INFO]                   
[INFO] ------------------------------------------------------------------------ 
[INFO] Building test 0.0.1-SNAPSHOT 
[INFO] ------------------------------------------------------------------------ 
[INFO] 
[INFO] --- maven-site-plugin:3.3:site (default-site) @ test --- 
[INFO] configuring report plugin org.apache.maven.plugins:maven-checkstyle-plugin:2.8 
[INFO] configuring report plugin org.apache.maven.plugins:maven-project-info-reports-plugin:2.7 
[INFO] Relativizing decoration links with respect to project URL: http://maven.apache.org 
[INFO] Rendering site with org.apache.maven.skins:maven-default-skin:jar:1.0 skin. 
[INFO] Generating "Checkstyle" report --- maven-checkstyle-plugin:2.8 
[INFO] 
[INFO] There are 1 checkstyle errors. 
[WARNING] Unable to locate Source XRef to link to - DISABLED 
[INFO] Generating "About" report --- maven-project-info-reports-plugin:2.7 
[INFO] Generating "Plugin Management" report --- maven-project-info-reports-plugin:2.7 
[INFO] Generating "Distribution Management" report --- maven-project-info-reports-plugin:2.7 
[INFO] Generating "Dependency Information" report --- maven-project-info-reports-plugin:2.7 
[INFO] Generating "Source Repository" report --- maven-project-info-reports-plugin:2.7 
[INFO] Generating "Mailing Lists" report --- maven-project-info-reports-plugin:2.7 
[INFO] Generating "Issue Tracking" report --- maven-project-info-reports-plugin:2.7 
[INFO] Generating "Continuous Integration" report --- maven-project-info-reports-plugin:2.7 
[INFO] Generating "Project Plugins" report --- maven-project-info-reports-plugin:2.7 
[INFO] Generating "Project License" report --- maven-project-info-reports-plugin:2.7 
[INFO] Generating "Project Team" report --- maven-project-info-reports-plugin:2.7 
[INFO] Generating "Project Summary" report --- maven-project-info-reports-plugin:2.7 
[INFO] Generating "Dependencies" report --- maven-project-info-reports-plugin:2.7 
[CHECKSTYLE] Parsing file /var/lib/jenkins/workspace/MavenProject2/test/target/checkstyle-result.xml 
[CHECKSTYLE] Successfully parsed file /var/lib/jenkins/workspace/MavenProject2/test/target/checkstyle-result.xml of module test with 1 unique warning and 0 duplicates. 
[CHECKSTYLE] Computing warning deltas based on reference build #226 
[JENKINS] Archiving site from /var/lib/jenkins/workspace/MavenProject2/test/target/site to /var/lib/jenkins/jobs/MavenProject2/site 
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ test --- 
[INFO] Deleting /var/lib/jenkins/workspace/MavenProject2/test/target 
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ test --- 
[INFO] Using 'UTF-8' encoding to copy filtered resources. 
[INFO] skip non existing resourceDirectory /var/lib/jenkins/workspace/MavenProject2/test/src/main/resources 
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ test --- 
[INFO] Changes detected - recompiling the module! 
[INFO] Compiling 1 source file to /var/lib/jenkins/workspace/MavenProject2/test/target/classes 
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ test --- 
[INFO] Using 'UTF-8' encoding to copy filtered resources. 
[INFO] skip non existing resourceDirectory /var/lib/jenkins/workspace/MavenProject2/test/src/test/resources 
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ test --- 
[INFO] Changes detected - recompiling the module! 
[INFO] Compiling 1 source file to /var/lib/jenkins/workspace/MavenProject2/test/target/test-classes 
[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ test --- 
[INFO] Surefire report directory: /var/lib/jenkins/workspace/MavenProject2/test/target/surefire-reports 

------------------------------------------------------- 
T E S T S 
------------------------------------------------------- 
Running test.test.AppTest 
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.052 sec 

Results : 

Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 

[JENKINS] Recording test results 
[INFO] 
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ test --- 
[INFO] Building jar: /var/lib/jenkins/workspace/MavenProject2/test/target/test-0.0.1-SNAPSHOT.jar 
[INFO] 
[INFO] --- maven-install-plugin:2.4:install (default-install) @ test --- 
[INFO] Installing /var/lib/jenkins/workspace/MavenProject2/test/target/test-0.0.1-SNAPSHOT.jar to /var/lib/jenkins/.m2/repository/test/test/0.0.1-SNAPSHOT/test-0.0.1-SNAPSHOT.jar 
[INFO] Installing /var/lib/jenkins/workspace/MavenProject2/test/pom.xml to /var/lib/jenkins/.m2/repository/test/test/0.0.1-SNAPSHOT/test-0.0.1-SNAPSHOT.pom 
[INFO] 
[INFO] --- maven-checkstyle-plugin:2.17:check (default-cli) @ test --- 
[INFO] There is 1 error reported by Checkstyle 6.11.2 with https://dustplanet.de/checkstyle.xml ruleset. 
[ERROR] src/main/java/test/test/App.java:[11,43] (whitespace) WhitespaceAround: '{' is not preceded with whitespace. 
[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD FAILURE 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 36.200 s 
[INFO] Finished at: 2017-08-17T17:47:53+02:00 
[INFO] Final Memory: 44M/106M 
[INFO] ------------------------------------------------------------------------ 
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin:2.17:check (default-cli) on project test: You have 1 Checkstyle violation. -> [Help 1] 
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. 
[ERROR] Re-run Maven using the -X switch to enable full debug logging. 
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles: 
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException 
[JENKINS] Archiving /var/lib/jenkins/workspace/MavenProject2/test/pom.xml to test/test/0.0.1-SNAPSHOT/test-0.0.1-SNAPSHOT.pom 
[JENKINS] Archiving /var/lib/jenkins/workspace/MavenProject2/test/target/test-0.0.1-SNAPSHOT.jar to test/test/0.0.1-SNAPSHOT/test-0.0.1-SNAPSHOT.jar 
Not sending mail to unregistered user [email protected] 
An attempt to send an e-mail to empty list of recipients, ignored. 
channel stopped 
[ANALYSIS-COLLECTOR] Computing warning deltas based on reference build #226 
Not sending mail to unregistered user [email protected] 
An attempt to send an e-mail to empty list of recipients, ignored. 
Finished: FAILURE 

Hat jemand eine Ahnung, was ich falsch gemacht habe?

EDIT 1 Ok ich jetzt weiß, dass das Plugin Check in der Build-Sequenz nicht richtig funktioniert becouse ich jetzt diese Warnungen erhalten. richtig

[INFO] Scanning for projects... 
[WARNING] The POM for org.apache.maven.plugin:maven-checkstyle-plugin:jar:2.17 is missing, no dependency information available 
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugin:maven-checkstyle-plugin:2.17: Plugin org.apache.maven.plugin:maven-checkstyle-plugin:2.17 or one of its dependencies could not be resolved: Failure to find org.apache.maven.plugin:maven-checkstyle-plugin:jar:2.17 in https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced 
[INFO]                   
[INFO] ------------------------------------------------------------------------ 
[INFO] Building test 0.0.1-SNAPSHOT 
[INFO] ------------------------------------------------------------------------ 
[WARNING] The POM for org.apache.maven.plugin:maven-checkstyle-plugin:jar:2.17 is missing, no dependency information available 
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugin:maven-checkstyle-plugin:2.17: Plugin org.apache.maven.plugin:maven-checkstyle-plugin:2.17 or one of its dependencies could not be resolved: Failure to find org.apache.maven.plugin:maven-checkstyle-plugin:jar:2.17 in https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced 

Sie nur dann auftreten, wenn ich das check Plugin in der Build-Reihenfolge setzen, funktioniert das Plugin check im Bericht Reihenfolge. Wie kann ich diese Warnungen lösen?

EDIT 2

ok das Problem war, dass ich in <groupId>org.apache.maven.plugin</groupId> ein "s" nach Plugin vergessen. Das Plugin wird immer noch nicht ausgeführt, aber ich markiere den Build jetzt als instabil oder als Fehler über das Checkstyle-Plugin in Jenkins. Ich hätte dies wahrscheinlich auf die erste Weise doch ty für Hilfe tun sollen.

+0

Ich bin mir nicht sicher, was Sie möchten erreichen, aber Ihr Build-Prozess bricht, weil Sie einen Checkstyle-Fehler haben: '[FEHLER] src/main/java/test/test/App.java: [11,43] (Leerzeichen) WhitespaceAround: '{' ist nicht vor mit Leerzeichen .... '..? – khmarbaise

+0

Ich möchte erreichen, dass der Build-Prozess fehlschlägt, wenn ein Checkstile-Fehler auftritt, aber auch, dass mein Checkstyle-Diagramm sowie der Analysebericht von Jenkins korrekt aktualisiert werden. Im Moment konnte ich nur erreichen, dass entweder der Build-Prozess bricht oder das Tend-Diagramm korrekt aktualisiert wird, aber nicht beide zusammen. Entschuldigung, wenn es schwer ist, mich zu verstehen, ich bin neu zu jenkins und maven, und mein Englisch ist nicht das beste auch. – seb2704

Antwort

1

müssen Sie maven-checkstyle-plugin Reporting-Plugin in Ihrem pom.xml hinzuzufügen, können Sie unter Plugin verwenden:

<project> 
    ... 
    <reporting> 
     <plugins> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-checkstyle-plugin</artifactId> 
      <version>2.17</version> 
      <reportSets> 
      <reportSet> 
       <reports> 
       <report>checkstyle</report> 
       </reports> 
      </reportSet> 
      </reportSets> 
     </plugin> 
     </plugins> 
    </reporting> 
    ... 
</project> 

für mehr Sie folgenden Link beziehen:

https://maven.apache.org/plugins/maven-checkstyle-plugin/usage.html

+0

Mhm ich habe das schon in der pom.xml oben getan. Das Problem ist nicht, dass der Bericht nicht erstellt wird, das Problem ist, dass der Analysebericht und Graph Trend von Jenkins nicht den richtigen Weg aktualisiert werden, wenn der Build-Prozess bricht und es scheint wie das Checkstyle-Plugin im Abschnitt funktioniert nicht richtig. – seb2704

Verwandte Themen