Big news! The community will be moving to a new platform April 21. Read more.
Big news! The community will be moving to a new platform April 21. Read more.
Cadet 2nd Class
Cadet 2nd Class
1017 views

"Executable not found: mvn" in fortifyTranslate, fortifyMaven3 declarative Jenkinsfile

How can I ensure maven is found in the PATH?

Maven is configured in the global tool config in Jenkins and is found in another step of the job.

It's in the PATH:

sh ' env | sort'

...

PATH=/opt/jenkins/tools/hudson.tasks.Maven_MavenInstallation/maven/bin:/opt/jenkins/tools/hudson.tasks.Maven_MavenInstallation/maven/bin:/usr/local/bin:/usr/bin

...

I am using a declarative Jenkinsfile.

The execution:

```
Running FortifyTranslate step
Fortify Jenkins plugin v 19.1.29
Launching Fortify SCA translate command
found executable: /x/cloudbees/Fortify_SCA_and_Apps_19.1.0/bin/sourceanalyzer
Running Maven 3 translation
executable not found: mvn
home: null
path: null
workspace: /opt/jenkins/workspace
$ /x/cloudbees/Fortify_SCA_and_Apps_19.1.0/bin/sourceanalyzer -Dcom.fortify.sca.ProjectRoot=/opt/jenkins/workspace/.fortify -b xx -Xmx4800M -logfile sca.log mvn -Dfortify.sca.exclude=src\test\java\** package -Dmaven.test.skip=true
SCA translation returned exitcode=0

Relevant bits of the Jenkinsfile:

pipeline {
 
  environment {..
  }
  agent {
    label 'master01-agents'
  }
  options {
...
  }
  tools {
    maven 'maven'
  }
  stages {
...
        stage('Fortify static security analysis') {
          options {
            timeout(time: 20, unit: 'MINUTES'
          }
          steps {
            echo 'Execute fortifyClean plugin'
            fortifyClean (
              buildID: "${BUILD_TAG}"logFile: 'sca.log'
            )
            echo 'Execute fortifyTranslate plugin'
            sh 'env | sort'
            fortifyTranslate ( 
              buildID: "${BUILD_TAG}"
              excludeList: '"src\\test\\java\\**"'
              logFile: 'sca.log'maxHeap: '4800'
              projectScanType: fortifyMaven3(mavenOptions: 'package -DskipTests -Dmaven.test.skip=true')
            )
            echo 'Execute fortifyScan plugin'
            fortifyScan (
              buildID: "${BUILD_TAG}"resultsFile: "${env.BUILD_TAG}.fpr",
              logFile: 'sca.log'
            )
            echo 'Execute fortifyUpload plugin'
            fortifyUpload (
              appName: 'AMT'appVersion: '1.0',
              resultsFile: "${BUILD_TAG}.fpr"
            )
          }
        }

 

0 Likes
1 Reply
Captain Captain
Captain

@adrianblakey  I had similar issue during my pipeline and I was able to resolve to specify the maven tool config in "Manage Jenkins ->  Configure System" page under global properties

clipboard_image_0.png

Then, check "Tool Locations" and select the Maven installation from the dropdown similarly

clipboard_image_1.png

After these, my jenkins was able to detect the Maven

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.