Among Us - Yellow Crewmate [Jenkins] sudo: no tty present and no askpass program specified

Trouble Shooting

[Jenkins] sudo: no tty present and no askpass program specified

감쟈! 2021. 8. 19. 10:06

Jenkins 파이프라인 작성하던 중 Build 과정에서 아래와 같이  Permission denied가 뜨면서 실패한다.

/var/run/docker.sock의 권한문제로 보인다.

# [Build] Permission denied


$ docker build . -t test/test:latest

Got permission denied while trying to connect to the Docker daemon socket at 
unix:///var/run/docker.sock: Post "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/build?buildargs=%7B%7D&cachefrom=%5B%5D&cgroupparent=&cpuperiod=0&cpuquota=0&cpusetcpus=&cpusetmems=&cpushares=0&dockerfile=Dockerfile&labels=%7B%7D&memory=0&memswap=0&networkmode=default&rm=1&shmsize=0&t=sgy12303%2Ftest%3Alatest&target=&ulimits=null&version=1": dial unix /var/run/docker.sock: connect: permission denied

script returned exit code 1

 

그래서 Jenkins에게 /var/run/docker.sock에 대한 권한을 주고자 하는데 sudo를 사용 시

sudo: no tty present and no askpass program specified 라는 오류가 뜨면서 또 실패한다.

이 오류는 sudo 명령어 실행 시 패스워드를 입력받아야 하기 때문에 나는 오류인데, Jenkins 계정에서 sudo 명령어를 사용해도 패스워드를 묻지 않도록 설정해주어야 한다.

 

$ sudo chmod 666 /var/run/docker.sock

We trust you have received the usual lecture from the local System

Administrator. It usually boils down to these three things:


    #1) Respect the privacy of others.

    #2) Think before you type.

    #3) With great power comes great responsibility.


sudo: no tty present and no askpass program specified

script returned exit code 1

 

다음과 같이 /etc/sudoers 파일에서 아래의 구문 밑에 jenkins ALL=(ALL) NOPASSWD: ALL 이라는 문장을 추가해주자.

 

# /etc/sudoers 파일 수정

$ sudo vi /etc/sudoers

## Allows members of the users group to shutdown this system
# %users  localhost=/sbin/shutdown -h now
jenkins ALL=(ALL) NOPASSWD: ALL