jenkinsci / fortify-plugin

Fortify Jenkins plugin
https://plugins.jenkins.io/fortify
Other
23 stars 31 forks source link

Can't find the mvn path in docker slave #42

Closed ksg97031 closed 2 years ago

ksg97031 commented 3 years ago

Version: Fortify Jenkins plugin v 20.2.34

I'm already setting the PATH and MAVEN_HOME environment correctly in all of my systems. Jenkins master and slave can find the mvn binary with 'sh' command. But the fortify-plugin can't find mvn binary.

Command sh

[Pipeline] sh
+ env
....
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/root/bin:/usr/share/maven/bin
MAVEN_HOME=/usr/share/maven
....

[Pipeline] sh
+ mvn -v
Apache Maven 3.6.0
Maven home: /usr/share/maven
Java version: 13, vendor: Oracle Corporation, runtime: /mnt/toolkit/jdk/jdk-13
Default locale: en_US, platform encoding: ANSI_X3.4-1968
OS name: "linux", version: "4.15.0-122-generic", arch: "amd64", family: "unix"

Command fortifyTranslate

[Pipeline] fortifyTranslate
Running FortifyTranslate step
Fortify Jenkins plugin v 20.2.34
Launching Fortify SCA translate command
Found executable: /home/Fortify/Fortify_SCA_and_Apps_20.1.2/bin/sourceanalyzer
Running Maven 3 translation
[Pipeline]
java.io.FileNotFoundException: ERROR: executable not found: mvn; make sure that either MAVEN_HOME environment variable is set or mvn is on the PATH or in workspace
    at com.fortify.plugin.jenkins.steps.FortifyStep.findExecutablePath(FortifyStep.java:112)
    at com.fortify.plugin.jenkins.steps.FortifyStep.getExecutable(FortifyStep.java:101)
    at com.fortify.plugin.jenkins.steps.FortifySCAStep.getExecutableForEnvVar(FortifySCAStep.java:108)
    at com.fortify.plugin.jenkins.steps.FortifySCAStep.getMavenExecutable(FortifySCAStep.java:97)
    at com.fortify.plugin.jenkins.steps.FortifyTranslate.perform(FortifyTranslate.java:357)
    at com.fortify.plugin.jenkins.steps.FortifyTranslate$Execution.run(FortifyTranslate.java:469)
    at com.fortify.plugin.jenkins.steps.FortifyTranslate$Execution.run(FortifyTranslate.java:455)
    at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)

This is my pipeline source.

# k8s
podTemplate(
    containers: [
        ...
    ],
) {
    node(POD_LABEL) {
        container('agent') {
            stage('Fortify Translation (Maven)') {
                sh 'ls /usr/share/maven/'
                sh 'env'
                sh 'mvn -v'

                fortifyTranslate addJVMOptions: '', buildID: "testApp",
                    projectScanType: fortifyMaven3(mavenOptions: mavenTasks)
            }
        }
    }
}
necipakca commented 2 years ago

Same issue still exist. Any progress ?

Running FortifyTranslate step Fortify Jenkins plugin v 21.2.37 Launching Fortify SCA translate command Found executable: /opt/fortify/bin/sourceanalyzer Running Maven 3 translation [Pipeline] } [Pipeline] // container [Pipeline] } [Pipeline] // stage [Pipeline] } [Pipeline] // node [Pipeline] } [Pipeline] // podTemplate [Pipeline] End of Pipeline java.io.FileNotFoundException: ERROR: executable not found: mvn; make sure that either MAVEN_HOME environment variable is set or mvn is on the PATH or in workspace at com.fortify.plugin.jenkins.steps.FortifyStep.findExecutablePath(FortifyStep.java:112) at com.fortify.plugin.jenkins.steps.FortifyStep.getExecutable(FortifyStep.java:101) at com.fortify.plugin.jenkins.steps.FortifySCAStep.getExecutableForEnvVar(FortifySCAStep.java:139) at com.fortify.plugin.jenkins.steps.FortifySCAStep.getMavenExecutable(FortifySCAStep.java:124) at com.fortify.plugin.jenkins.steps.FortifyTranslate.perform(FortifyTranslate.java:368) at com.fortify.plugin.jenkins.steps.FortifyTranslate$Execution.run(FortifyTranslate.java:485) at com.fortify.plugin.jenkins.steps.FortifyTranslate$Execution.run(FortifyTranslate.java:466) at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47) at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) at java.base/java.util.concurrent.FutureTask.run(Unknown Source) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.base/java.lang.Thread.run(Unknown Source) Finished: FAILURE

akaryakina commented 2 years ago

This might be the same bug as https://github.com/jenkinsci/fortify-plugin/issues/49. We've just fixed it and are going to release in 22.1.38 version of the plugin. Could you please test it again with that version (you can try out the fortify.hpi dev build from https://ci.jenkins.io/job/Plugins/job/fortify-plugin/job/master/ if you don't want to wait for the official release)

akaryakina commented 2 years ago

Closing for now. Please, reopen if you experience the issue with 22.1.38.