Jenkins设置默用户为root

最近在需要在jenkins执行shell脚本,由于Jenkins之前是默认在线安装的,这样jenkins设置了默认用户jenkins权限

如果要执行root用户命令,则报权限错误


Jenkins设置默用户为root_第1张图片
image.png

所以要更换jenkins为root用户

改变步骤如下:

  1. 首先查找在线安装jenkins的目录, 然后执行

chown -R root:root xxxx

root@ubuntu:/usr/share# find / -name "jenkins"
find: ‘/proc/13931’: No such file or directory
/var/lib/jenkins
/var/log/jenkins
/var/cache/jenkins
/run/jenkins
/etc/default/jenkins
/etc/init.d/jenkins
/etc/logrotate.d/jenkins
/usr/share/jenkins
/usr/share/doc/jenkins
  1. 编辑文件 /etc/default/jenkins

JENKINS_USER=root
JENKINS_GROUP=root

Jenkins设置默用户为root_第2张图片
image.png
  1. 启动jenkins服务
root@ubuntu:/usr/share# /etc/init.d/jenkins 
Correct java version found
Usage: /etc/init.d/jenkins {start|stop|status|restart|force-reload}
  1. 浏览器登录查看是否ok

你可能感兴趣的:(Jenkins设置默用户为root)