Coverity Command Examples

The following page describes examples of Coverity commands:

Maven

cov-build --dir ${WORKSPACE}/idir mvn clean package
cov-analyze --dir ${WORKSPACE}/idir
cov-commit-defects --dir ${WORKSPACE}/idir --host ${COVERITY_HOST} --port ${COVERITY_PORT} --stream ${COV_STREAM}

Gradle

cov-build --dir ${WORKSPACE}/idir ./gradlew clean build --no-daemon 
cov-analyze --dir ${WORKSPACE}/idir
cov-commit-defects --dir ${WORKSPACE}/idir --host ${COVERITY_HOST} --port ${COVERITY_PORT} --stream ${COV_STREAM}

Gradle Troubleshooting

  • You must stop all Gradle daemon processes and use --no-daemon in order for the cov-build to work properly, refer to Coverity Gradle Daemon

  • If cov-build logs "Emitted 0 Java compilation united (0%) successfully and in the build-log.txt you see "--sourcepath assigned the value '--bootclasspath' leaving --bootclasspath unspecified" , refer to Sourcepath Assigned Leaving Bootclasspath Unspecified

    • You can create an init.gradle file with the following contents 

      allprojects { tasks.withType(JavaCompile) { if (project.hasProperty("forCoverity")) { options.sourcepath = files('/this/directory/must/not/exists') } } }



    • and add this to the end of the cov-build command

      --init-script init.gradle -PforCoverity



Delta analysis

cov-run-desktop --dir ${WORKSPACE}/idir  --host ${COVERITY_HOST} --stream ${COV_STREAM} ${CHANGE_SET}

Command Variables

Variable

Description

Variable

Description

Jenkins environment variables

refer to Jenkins Set Environment Variables

COVERITY_HOST

The Coverity server host name configured in the global configuration

COVERITY_PORT

The Coverity server port configured in the global configuration

COV_STREAM

The Coverity stream configured in the Job configuration.

CHANGE_SET

The files that have changed since the last build.





©2023 Synopsys, Inc. All Rights Reserved