Run shell command in jenkins as root user?

后端 未结 5 635
梦毁少年i
梦毁少年i 2020-12-08 01:42

I have recently started using Jenkins for integration. All was well until I was running jobs on master node without shell command but I have to run jobs on master as well as

5条回答
  •  生来不讨喜
    2020-12-08 01:49

    You just need to run the shell command on Linux machine using Root privileges from Jenkins.

    Steps :

    1) sudo vi /etc/sudoers

    2) Add line :

    jenkins ALL=NOPASSWD:/path of script/
    

    3) From Jenkins,run the script on remote shell using sudo . for eg : sudo ps -ef

    4) Build Jenkins job now. This job runs the script on Linux machine using root privileges.

提交回复
热议问题