본문 바로가기
IT/개발환경

Ubuntu에서 커맨드로는 괜찮은데 Jenkins에서만 systemctl 명령을 실행하지 못할 때

by rapker 2024. 2. 16.
반응형

젠킨스에서 서비스를 중지, 재시작 하는 명령을 실행시키면 아래와 같은 오류가 발생합니다.

a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper

반응형

 

 

 

젠킨스에서 특정 서비스를 실행하는것에는 방화벽에 의한 포트 문제등 다른 이유야 많겠지만 위 현상은

그냥 특정 유저가 특정 명령어를 실행할 때 sudo 의 비밀번호를 묻지 않도록 설정해서 이를 해결할 수 있습니다.

 

 

젠킨스 shell에서 아래 커맨드 추가해서 sh 실행주체와 systemctl 경로 확인

whoami
which systemctl

 

 

 

sudoers 편집

 sudo visudo /etc/sudoers

 

 

 

jenkins ALL=(ALL) NOPASSWD: /usr/bin/systemctl stop dbserver
jenkins ALL=(ALL) NOPASSWD: /usr/bin/systemctl start dbserver
jenkins ALL=(ALL) NOPASSWD: /usr/bin/systemctl restart dbserver
jenkins ALL=(ALL) NOPASSWD: /usr/bin/systemctl status dbserver
반응형
LIST