You need to modify the permission for jenkins user so that you can run the shell commands. You can install the jenkins as as service (download the rpm package), You might need to change the ports because by default it runs http on 8080 and AJP on 8009 port.

Following process is for CentOS
1. Open up the this script (using VIM or other editor):

vim /etc/sysconfig/jenkins

2. Find this $JENKINS_USER and change to “root”:

$JENKINS_USER="root"

3. Then change the ownership of Jenkins home, webroot and logs:

chown -R root:root /var/lib/jenins
chown -R root:root /var/cache/jenkins
chown -R root:root /var/log/jenkins

4) Restart Jenkins and check the user has been changed:

service jenkins restart
ps -ef | grep jenkins

Now you should be able to run the Jenkins jobs as the root user and all the shell command will be executed as root.

Jenkins--Run shell command in jenkins as root user?的更多相关文章

  1. ubuntu服务器上提示 To run a command as administrator (user "root"), use "sudo <command>". See " 解决方案

    原因是你执行命令必须要在root用户下执行.其他用户权限不够.运行  sudo -s 切换到root用户下就可以了

  2. Run Shell Commands in Python

    subprocess.call This is the recommended way to run shell commands in Python compared with old-fashio ...

  3. Jenkins可用环境变量列表以及环境变量的使用(Shell/Command/Maven/Ant)

    一.可用环境变量列表(以下来自google翻译): BRANCH_NAME 对于多分支项目,这将被设置为正在构建的分支的名称,例如,如果您希望从而master不是从特征分支部署到生产. CHANGE_ ...

  4. 以root用户运行jenkins中shell命令 重要

    以centOS系统为例,记录下修改Jenkins以root用户运行的方法. 修改Jenkins配置文件 # 打开配置文件vim /etc/sysconfig/jenkins# 修改$JENKINS_U ...

  5. 写个shell脚本搭载jenkins让你的程序部署飞起来

    [转载请注明]: 原文出处:https://www.cnblogs.com/jstarseven/p/11399251.html    作者:jstarseven    码字挺辛苦的.....  说明 ...

  6. jenkins执行shell提示命令不存在

    问题描述: jenkins编译项目,不继承linux环境变量 ~/.bash_profile  ~/.bashrc  /etc/profile,导致在执行shell脚本,提示命令找不到! [sz-hg ...

  7. Dockerfile 构建前端nginx应用并用shell脚本实现jenkins自动构建

    Dockerfile 文件构建docker镜像 FROM centos MAINTAINER zh********h.cn RUN rm -f /etc/nginx/nginx.conf COPY n ...

  8. Jenkins在shell脚本运行docker权限报错解决

    报错环境 系统信息 Distributor ID: Ubuntu Description: Ubuntu 16.04.1 LTS Release: 16.04 Codename: xenial doc ...

  9. Dockerfile 构建后端springboot应用并用shell脚本实现jenkins自动构建

    Dockerfile 文件构建docker镜像 FROM centos MAINTAINER zh*****eng "z*******ch.cn" ENV LANG en_US.U ...

随机推荐

  1. 鼠标放在预览图a.gif上,旁边有放大图出现

    原文发布时间为:2009-04-23 -- 来源于本人的百度文章 [由搬家工具导入] <html><script type="text/javascript"&g ...

  2. C#图解教程学习笔记——方法

    一.字段和本地变量.本地常量字段:隶属于类的变量,即类的成员变量.本地变量:于保存本地的或临时的计算数据,即局部变量.本地常量:必须声明在块内部,声明时必须初始化,声明后不能改变.实例字段与本地变量区 ...

  3. Lotus Notes Error: your mail file cannot be located. use file location manage location to ensure that your mail file is specified correctly

    在notes客户端中,当我们切换到另一个ID的时候,通过程序发送邮件,会报错:

  4. hdu 4519(数学题)

    郑厂长系列故事——体检 Time Limit: 500/200 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Total S ...

  5. (一)python 简单网页爬虫

    1.基于window环境,使用的工具是 Anaconda 下载地址 https://www.anaconda.com/download/ 2.所使用的包 BeautifulSoup,用来解析html代 ...

  6. 解决dvajs使用BrowserHistory路由模式后仍然会出现hash(哈希)

    在dvajs中,如果你在初始化dva对象的时候不作任何处理,那么你就会发现即使你是用了BrowserRouter来作为Router url中也是会出现#/.解决方法也很简单: 使用前先手动安装下 hi ...

  7. Codeforces Round #467 (Div. 2) A. Olympiad[输入一组数,求该数列合法的子集个数]

    A. Olympiad time limit per test 1 second memory limit per test 256 megabytes input standard input ou ...

  8. CodeChef February Challenge 2018 Points Inside A Polygon (鸽笼原理)

    题目链接  Points Inside A Polygon 题意  给定一个$n$个点的凸多边形,求出$[ \frac{n}{10}]\ $个凸多边形内的整点. 把$n$个点分成$4$类: 横坐标奇, ...

  9. Java NIO中的FileLock(文件锁)

    FileLock,文件锁. 文件锁在OS中很常见,如果多个程序同时访问.修改同一个文件,很容易因为文件数据不同步而出现问题.给文件加一个锁,同一时间,只能有一个程序修改此文件,或者程序都只能读此文件, ...

  10. 使用aspnet_regsql.exe 创建ASPState数据库,用来保存session会话

    使用aspnet_regsql.exe 创建ASPState数据库,用来保存session会话   因为公司有多台服务器,所以session要保存在sql server上,因此要在数据库中建立存放se ...