In my project am using circleCI with codecov for a Springboot maven project.
Below is relevant part of the .circleci/config.yml
# run tests! and gen code coverage
- run: mvn integration-test cobertura:cobertura
- store_test_results:
path: target/surfire-reports
- run:
name: Send to CodeCov
command: bash <(curl -s https://codecov.io/bash)enter code here
And the maven plug-in is:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<configuration>
<formats>
<format>html</format>
<format>xml</format>
</formats>
<check/>
</configuration>
</plugin>
And am using the default codecov.yml which can be found here.
The circleci build is successful and I do get a codecov report generated BUT the code coverage is only for files within the bootsrap package of the project com.x.y.bootstrap.
Below is an image from codecov site for the repository.
What am looking for is full code coverage of the entire project.
I believe the problem was due to the cobertura-maven-plugin not picking-up the correct source class path; hence generating the report with invalid data. I've updated the project to use jacoco-maven-plugin and simply ran the tests with:
run: mvn integration-test
The POM file change was as follows:
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.2</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
Everything worth after that.
Related
Below are my Jenkins setup:
Created Freestyle project
In Build section added :- Invoke top-level Maven targets In
In Post-Build Actions added:- Cucumber reports
However the same is working fine when I am executing from maven. here is the pom.xml setting related to cucumber reports.
<plugin>
<groupId>net.masterthought</groupId>
<artifactId>maven-cucumber-reporting</artifactId>
<version>5.4.0</version>
<executions>
<execution>
<id>execution</id>
<phase>verify</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<projectName>Sample</projectName>
<skip>false</skip>
<outputDirectory>${project.build.directory}/cucumber-reports</outputDirectory>
<inputDirectory>${project.build.directory}/cucumber-reports</inputDirectory>
<buildNumber>2</buildNumber>
<jsonFiles>
<param>**/*.json</param>
</jsonFiles>
<classificationDirectory>${project.build.directory}/cucumber-reports</classificationDirectory>
<classificationFiles>
<param>*.properties</param>
</classificationFiles>
<checkBuildResult>false</checkBuildResult>
<setSkippedAsNotFailing>true</setSkippedAsNotFailing>
<treatPendingAsFailed>false</treatPendingAsFailed>
<treatUndefinedAsFailed>false</treatUndefinedAsFailed>
</configuration>
</execution>
</executions>
</plugin>
Please let ne know what I am missing..
Unfortunately, cucumber-reports-plugin does not have a setting for its own notFailingStatuses parameter(aka setSkippedAsNotFailing in pom) from cucumber-reporting library.
I have forked the plugin and made some changes to enable that setting. You can check it out here and build a custom plugin yourself.
I am trying to integrate maven dockerfile plugin with my project. I have multiple modules under my maven project. I have modified the pom.xml for the module I want to build and tag images as below. Running mvn dockerfile:build command builds a creates a docker-info.jar under the target folder. I am not sure where the images are being built and when I try to run the mvn dockerfile:tag command I see the below error.
Failed to execute goal com.spotify:dockerfile-maven-plugin:1.4.4:tag
(default-cli) on project drs-web: The parameters 'repository' for goal
com.spotify:dockerfile-maven-plugin:1.4.4:tag are missing or invalid
Pom.xml:
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<version>${docker.maven.plugin.version}</version>
<executions>
<execution>
<id>build</id>
<goals>
<goal>build</goal>
</goals>
<configuration>
<buildArgs>
<WAR_FILE>${project.build.finalName}.war</WAR_FILE>
</buildArgs>
</configuration>
</execution>
<execution>
<id>tag</id>
<goals>
<goal>tag</goal>
</goals>
<configuration>
<repository>XXX/XXX-api</repository>
<tag>${project.version}</tag>
</configuration>
</execution>
</executions>
</plugin>
Dockerfile:
FROM tomcat:9.0.10-jre8-slim
ENV CATALINA_HOME /usr/local/tomcat
MAINTAINER XXX
EXPOSE 8080
ADD target/${WAR_FILE} ${CATALINA_HOME}/webapps/XXX-api.war
To fix the error you should use the same parameters in two sections of your pom.xml. You didn't define the repository's name for the build goal:
<configuration>
<repository>XXX/XXX-api</repository>
</configuration>
The fact that docker-info.jar was created in your Target directory most likely means that the creation of the docker image completed successfully.
The image should be put to your Docker registry with the name "XXX/XXX-api", and you can check it from a console with the command:
docker image ls
P.S. You can avoid generation of docker-info.jar by adding the following parameter to the configuration section of dockerfile-maven-plugin:
<configuration>
<skipDockerInfo>true</skipDockerInfo>
</configuration>
I am using maven-soapui-extension-plugin:test-multi to run tests splitted in multiple soapUI projects.
I see that a lot of TEST-*.xml are generated in target/surefire-reports but I don't see them on the jenkins build page like I do with other projects containing regular junit tests. It seems that jenkins does not detect those reports.
My plugin is configured as such:
<plugin>
<groupId>com.github.redfish4ktc.soapui</groupId>
<artifactId>maven-soapui-extension-plugin</artifactId>
<version>4.6.4.2</version>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>test-multi</goal>
</goals>
<configuration>
<projectFiles>
<scan>
<baseDirectory>${soapui.folder}</baseDirectory>
<includes>
<include>**/*-soapui-project.xml</include>
</includes>
</scan>
</projectFiles>
<host>${soapui.endpoint}</host>
<outputFolder>${basedir}/target/surefire-reports</outputFolder>
<junitReport>true</junitReport>
<exportAll>true</exportAll>
<testFailIgnore>true</testFailIgnore>
<useOutputFolderPerProject>false</useOutputFolderPerProject>
</configuration>
</execution>
</executions>
</plugin>
Do I need something else in my configuration or in jenkins?
It seems to be a problem with Jenkins which does not publish surefire reports generated outside the surefire-plugin for maven (non-freestyle) projects.
I would like to find out the values of all Maven properties as they apply to some Maven project.
mvn help:system lists OS environment variables and JVM system properties, but no Maven properties.
mvn help:evaluate only works in an interactive mode, that means I have to type a single Maven property, (e.g. ${project.build.outputDirectory}) to get the value of that property.
I'm looking for a way get a full list of all Maven properties and their values.
As a workaround, add this to the <plugins> ... </plugins> section inside your project's pom.xml:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<echoproperties />
</tasks>
</configuration>
</execution>
</executions>
</plugin>
Now execute mvn validate.
On the console, prefixed with [echoproperties], there will be the full list of system properties, including those set by Maven such as project.build.outputDirectory, basedir, and settings.localRepository.
the maven-help-plugin does what you want, just call it with -Dexpression=project.properties this will print the properties tag of the effective pom.
mvn help:evaluate -Dexpression=project.properties
Bonus Points when you just want the properties output and not the maven output
mvn help:evaluate -Dexpression=project.properties -q -DforceStdout
or with the explicit version because -DforceStdout works since version 3.1.0
mvn org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate -Dexpression=project.properties -q -DforceStdout
Not sure if helps, but I found this when trying to do the same thing:
mvn com.github.ekryd.echo-maven-plugin:echo-maven-plugin:echo -Decho.message='${project.build.testOutputDirectory}'
From here.
Adding the following to ${user.home}/.m2/settings.xml:
<pluginGroups>
<pluginGroup>com.github.ekryd.echo-maven-plugin</pluginGroup>
</pluginGroups>
the command can be shortened to:
mvn echo:echo -Decho.message='${project.build.testOutputDirectory}'
I don't know how to get them "officially", but here is a workaround. Add maven-antrun-plugin to your project and run mvn test -X. The plugin will show all properties passed to it from Maven. The list looks complete to me.
Actually project.build.outputDirectory is there but you need to execute in 'compile' phase, and NOT in 'validate'. I guess what properties are available also depends on the current phase for the executing goal of a particular plug-in, in this case 'maven-antrun-plugin'.
<!-- Ant Run Plugin for debugging pom.xml and calling ant tasks -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>${ant.plugin.version}</version>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<echoproperties/>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
Had the same issue. Changed the timeout and maxheap in findbugs configuration through maven.
The below fixed it for me :
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>3.0.2</version>
<configuration>
<maxHeap>2048</maxHeap>
<timeout>1800000</timeout>
</configuration>
</plugin>
Currently I am debugging the signing of an Android app. And this would be a lot easier if I could just execute this one and only plugin:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jarsigner-plugin</artifactId>
<executions>
<execution>
<id>signing</id>
<goals>
<goal>sign</goal>
</goals>
<phase>package</phase>
But no matter what I try all I get is:
[ERROR] Could not find goal 'signing' in plugin org.apache.maven.plugins:maven-jarsigner-plugin:1.2 among available goals verify, sign, help -> [Help 1]
org.apache.maven.plugin.MojoNotFoundException: Could not find goal 'signing' in plugin org.apache.maven.plugins:maven-jarsigner-plugin:1.2 among available goals verify,
sign, help
or
org.apache.maven.lifecycle.LifecyclePhaseNotFoundException: Unknown lifecycle phase "sign". You must specify a valid lifecycle phase or a goal in the format <plugin-pre
fix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources
, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-co
mpile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, p
ost-clean, pre-site, site, post-site, site-deploy.
or some other error.
You can run just the sign goal with this command:
mvn jarsigner:sign
I have this plugin configured is my pom like this:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jarsigner-plugin</artifactId>
<version>1.2</version>
<executions>
<execution>
<id>signer</id>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
<configuration>
<archive>target/${project.artifactId}-${project.version}.jar</archive>
<keystore>src/main/signer/.keystore</keystore>
<alias>MyCert</alias>
<storepass>password</storepass>
<keypass>password</keypass>
</configuration>
</plugin>
Because I have <archive> pointing to an artifact in my target directory I have to run a mvn clean install first, and from then on I can just execute mvn jarsigner:sign if I want to run the maven-jarsigner-plugin again to sign the jar. (I don't normally run only this plugin/goal as I just do a full "mvn clean install" all the time, but it does work.)