0

I would like to do the static analysis only of my project files, because the third-party library is usually dockerized and stable, it is not necessary to perform the static analysis every time of something immutable, but I am having some problems when I run through jenkins to do the integration continues. To build my IoT project I use the official docker image from espressif and as a result I have a build folder with compile_commands.json inside it

I access the machine where jenkins is installed via ssh and I can run the command below:

cppcheck --project=$PWD/ESPComm/build/compile_commands.json -i /opt/esp/ --inline-suppr --enable=all --suppress=missingInclude --suppress=unmatchedSuppression --suppressions-list=.suppressions --inconclusive --std=c11 --xml --xml-version=2 --std=c11 2> cppcheck.xml

I have already opened the cppcheck.xml file that was generated and, as expected, the /opt/esp libraries were ignored (when I do not pass the -i /opt/esp/ argument, an analysis of about 855 espressif library items), the static analysis was basically done only on my project files (28 items)

However when I run the command in jenkins pipeline:

It is worth mentioning that a stage before this one I build with another image, the official image of espressif, but always taking care that the path is based on the environment variable $workspace

stage('Load docker image with tools for Static Analysis') {
            agent {
                docker {
                    image 'mytools/tools-cde-image:0.1'
                    reuseNode true
                }
            }
            stages{
                stage('Static Analysis') {
                    steps {
                        sh '''
                            pwd
                            ls -a
                            '''
                        sh 'sloccount --wide --details $WORKSPACE/ESPComm/build > sloccount.sc'
                        sloccountPublish encoding: '', pattern: 'sloccount.sc'
                        sh 'cppcheck --project=$PWD/ESPComm/build/compile_commands.json -i /opt/esp/ --inline-suppr --enable=all --suppress=missingInclude --suppress=unmatchedSuppression --suppressions-list=.suppressions --inconclusive --std=c11 --xml --xml-version=2 --std=c11 2> cppcheck.xml'
                    }
                }
            }
}

I have this error output in the log:

+ cppcheck --project=/var/lib/jenkins/workspace/iot-proj-TEST/ESPComm/build/compile_commands.json -i/opt/esp/ --inline-suppr --enable=all --suppress=missingInclude --suppress=unmatchedSuppression --suppressions-list=.suppressions --inconclusive --std=c11 --xml --xml-version=2 --std=c11
cppcheck: error: '/opt/esp/idf/components/xtensa/debug_helpers.c' from compilation database does not exist
cppcheck: error: failed to load project '/var/lib/jenkins/workspace/iot-proj-TEST/ESPComm/build/compile_commands.json'. An error occurred.

I opened the compile_commands.json file to check and pulled out some samples:

1 - "file": "/var/lib/jenkins/workspace/iot-proj/ESPComm/build/project_elf_src.c"
2 - "file": "/opt/esp/idf/components/xtensa/debug_helpers.c" >> IN THIS FILE THAT ALREADY APPEARS THE PROBLEM THAT THE FILE DOES NOT EXIST
857 - "file": "/opt/esp/idf/components/wifi_provisioning/proto-c/wifi_constants.pb-c.c"
858 - "file": "/var/lib/jenkins/workspace/iot-proj/ESPComm/main/alarm_table.c"

0 Answers0