0

I have a playground pipeline and I am trying to start using cppcheck, but when I execute the command in the cmd (I am running windows 10) it works fine, but if executing the command inside the pipeline, it returns 'cppcheck' is not recognized as an internal or external command I have installed the plugin and restarted Jenkins... what am I missing then? . This is the sample pipeline:

pipeline {
    agent any    
    stages {
        stage('Static Analysis') {
            steps {
                script{
                    env.FAILED_STAGE=env.STAGE_NAME
                    bat'cppcheck "D:/Source/Game"'
                }
            }
        }
    }
}

however the exactly same command, copied and pasted into the cmd, works just fine, analyze the folder and gives me the cppcheck.xml file.

Also if running the pipeline like this it seems to work just fine:

        stage('Static Analysis') {
            steps {
                script{
                    bat'call  "C:\\Program Files\\Cppcheck\\cppcheck.exe" D:\\Source\\Game  --xml --xml-version=2 . 2> cppcheck.xml'
                }
            }
        }
Jesus Fernandez
  • 500
  • 1
  • 7
  • 20
  • To get some more info about what is happening you could add ```--verbose``` to the ```cppcheck``` command. – Kaj Hejer Mar 30 '21 at 17:31
  • 1
    it seems that running it like this works: bat'call "C:\\Program Files\\Cppcheck\\cppcheck.exe" D:\\Source\\Game --xml --xml-version=2 . 2> cppcheck.xml' – Jesus Fernandez Mar 31 '21 at 09:36
  • Does this answer your question? [how to publish cppcheck results on jenkins pipeline?](https://stackoverflow.com/questions/66799554/how-to-publish-cppcheck-results-on-jenkins-pipeline) – arved Apr 14 '21 at 09:22
  • it actually was some issue with the `PATH` – Jesus Fernandez Apr 14 '21 at 16:05

0 Answers0