I have a command which requires root in JenkinsFile.But when i run it on my localhost it gives error that "sudo not found".The JenkinsFile is in the source code.
stage('Install packages') {
sh("docker run --rm -v `pwd`:/app -w /app node yarn install")
sh("sudo chown -R jenkins: ./node_modules")
}
I have already tried this. How to run a script as root in Jenkins? The temp sh script is created on each build. And the error is
/var/jenkins_home/workspace/boilerplate_master-2ESKZDF4PBIXGKODFFKIVAND5RN5VWF6QLEGRZ44LZGESCULVC4Q@tmp/durable-14d87eaa/script.sh: line 1: sudo: not found