Jenkins run as his own user by default, check node user or login user you are using. The cppcheck must be into that user env PATH variable.
I work round this to avoid spamming the PATH variable on the machine by doing env config into Jenkins, and I use that env variable to give a full path on each node. https://<MyJenkinsHost>/computer/<MyNodeName>/configure<https://%3cMyJenkinsHost%3e/computer/%3cMyNodeName%3e/configure> [cid:image001.png@01D72611.2A85F2C0] Then each node can install or put his binary into a custom path depends on the node. I use the node label to declare his capacity: [cid:image002.png@01D72611.2A85F2C0] That way I run into a node that provide DOXYGEN for example, I then need to resolve the doxygen path with the env variable or if the variable is not present I assume the tool is inside the node current PATH var already (save some time for tool that are install system wide). Jérôme Godbout, B. Ing. Software / Firmware Team Lead O: (418) 682-3636 ext.: 114 C: (581) 777-0050 godbo...@dimonoff.com<mailto:godbo...@dimonoff.com> [signature_16446078]<https://www.dimonoff.com/> dimonoff.com<https://www.dimonoff.com/> 1015 Avenue Wilfrid-Pelletier, Québec, QC G1W 0C4, 4e étage From: jenkinsci-users@googlegroups.com <jenkinsci-users@googlegroups.com> on behalf of jesus fernandez <jesusfernandez0...@gmail.com> Date: Wednesday, March 31, 2021 at 5:44 AM To: Jenkins Users <jenkinsci-users@googlegroups.com> Subject: how can I run cppcheck in Jenkins? 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' } } } ``` -- You received this message because you are subscribed to the Google Groups "Jenkins Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscr...@googlegroups.com<mailto:jenkinsci-users+unsubscr...@googlegroups.com>. To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/04691194-8864-411b-bd34-2ed8e20ab9fan%40googlegroups.com<https://groups.google.com/d/msgid/jenkinsci-users/04691194-8864-411b-bd34-2ed8e20ab9fan%40googlegroups.com?utm_medium=email&utm_source=footer>. -- You received this message because you are subscribed to the Google Groups "Jenkins Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/QB1PR01MB38446DEF9A0D704E0F44BEEFCD7C9%40QB1PR01MB3844.CANPRD01.PROD.OUTLOOK.COM.