how can I run cppcheck in Jenkins?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

how can I run cppcheck in Jenkins?

jesus fernandez
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/04691194-8864-411b-bd34-2ed8e20ab9fan%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: how can I run cppcheck in Jenkins?

Jérôme Godbout

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

 

 

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:

 

 

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 
[hidden email]

signature_16446078

dimonoff.com

1015 Avenue Wilfrid-Pelletier, 

Québec, QC G1W 0C4, 4e étage

 

 

From: [hidden email] <[hidden email]> on behalf of jesus fernandez <[hidden email]>
Date: Wednesday, March 31, 2021 at 5:44 AM
To: Jenkins Users <[hidden email]>
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/04691194-8864-411b-bd34-2ed8e20ab9fan%40googlegroups.com.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/QB1PR01MB38446DEF9A0D704E0F44BEEFCD7C9%40QB1PR01MB3844.CANPRD01.PROD.OUTLOOK.COM.
Reply | Threaded
Open this post in threaded view
|

Re: how can I run cppcheck in Jenkins?

jesus fernandez
Thanks for answering,

I tried what you suggested but adding it as a env variable to the node variables does not work either. Regarding adding it to the jenkins user path I am not sure what you mean, I am not sure how to do that in windows 10, I start jenkins just by executing the .war file

El miércoles, 31 de marzo de 2021 a las 15:35:37 UTC+2, Jérôme Godbout escribió:

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

 

 

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:

 

 

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: <a href="tel:(418)%20682-3636" value="+14186823636" target="_blank" rel="nofollow">(418) 682-3636 ext.: 114  

C: <a href="tel:(581)%20777-0050" value="+15817770050" target="_blank" rel="nofollow">(581) 777-0050 
[hidden email]

signature_16446078

dimonoff.com

1015 Avenue Wilfrid-Pelletier, 

Québec, QC G1W 0C4, 4e étage

 

 

From: [hidden email] <[hidden email]> on behalf of jesus fernandez <[hidden email]>
Date: Wednesday, March 31, 2021 at 5:44 AM
To: Jenkins Users <[hidden email]>
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/04691194-8864-411b-bd34-2ed8e20ab9fan%40googlegroups.com.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/071dc060-c260-4885-9d15-f96043d15964n%40googlegroups.com.