Jenkins pipeline - 'apigeelint' is not recognized as an internal or external command

I am trying to use apigeelint for static code analysis in Jenkins

Inside the declarative pipeline, i have the below stage

stage('Policy-Code Analysis') {
           steps {
                    bat "apigeelint -s C:/apiproxy/ -f json.js"
           }
}

Please suggest. Below is the stacktrace-

'apigeelint' is not recognized as an internal or external command

 

0 4 425
4 REPLIES 4

did you install apigeelint? with -g derective?

 

npm install -g apigeelint

yes. Outside Jenkins, apigeelint works as usual.

well this means that in runtime environment of jenkins theres no path or other things configured - so your jenkins does not see apigeelint. maybe it is not avail for user that runs the jenkins process

Inside the 'Global Tool Configuration' in Jenkins, I need to add the node js installation. In my case it is - C:\Users\{username}\AppData\Roaming\npm

and then in the declarative pipeline, i need to put the below entry

tools {
    nodejs 'NodeJS'
}

 

where nodejs is the name configured in 'Global Tool Configuration'.

Then it works.

 

@Denis_KALITVI If without configuring the node js installation directory in jenkins, the commands npm -v and node -v works, why doesn't it works for apigeelint? Any suggestions.