Jenkins reported an error when running the docker permission in the shell script

Errors are reported as follows

Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.39/containers/arduino-cli/json: dial unix /var/run/docker.sock: connect: permission denied
Build step 'Execute shell' marked build as failure
Finished: FAILURE

Solution:

sudo gpasswd -a jenkins docker
sudo usermod -a G docker jenkins
chmod 777 /var/run/docker.sock

solve the problem

Read More: