'sudo: command not found jenkins

I am using bash script in Jenkins pipeline that connects to another machine and perform sudo command there:

script.sh '''
ssh -o StrictHostKeyChecking=no -i ${DEPLOYMENT_KEY} deployment@${MACHINE_IP} sudo rm -rf /tmp/${FOLDER} | true
'''

the job failed with this error message: sudo: command not found.

how can I debug the issue, I can perform a sudo command in the machine, is there any configuration that I need to check in the machine? Thanks!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source