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. 自定义JavaScript字典类jsdictionary.js

    /* Dictionary类:本类实现了字典功能,所有方法.属性都模仿System..Collection.Generic.Dictionary类 构造函数: Dictionary() 属性: Com ...

  2. Android布局实现阴影效果

    最近某个模块的UI,设计想要卡片式阴影效果.之前查阅过资料,用传统的xml方式作为布局的background <?xml version="1.0" encoding=&qu ...

  3. bzoj 5092: [Lydsy1711月赛]分割序列

    5092: [Lydsy1711月赛]分割序列 Time Limit: 5 Sec  Memory Limit: 256 MBSubmit: 219  Solved: 100[Submit][Stat ...

  4. linux查看hostname以及修改hostname

    查看hostname   :   hostname 修改hostname   :   hostnamectl set-hostname  master (比如要修改为master) 修改完重启生效 : ...

  5. Java获取路径的方法分析详解(Application/Web)

    1.利用System.getProperty()函数获取当前路径: System.getProperty("user.dir");//user.dir用户当前的工作目录,输出:D: ...

  6. 深入理解 JavaScript Function

    1.Function Arguments JavaScript 函数的参数 类型可以是 复杂类型如  Object or Array 和简单类型 String Integer null undefin ...

  7. lock与monitor的区别

    1.Lock 只能对引用对象加锁 Lock锁定区间内可以对锁定值修改而不发生运行时错误,通常也会采用此种修改方式.这种方式又有点类同于使用Monitor.Wait取得资源,并对这个资源进行操作. 用法 ...

  8. Geoserver跨域问题

    1 Geoserver位war包,使用Tomcat发布的情况 由于geoserver为war形式,需要解决tomcat跨域问题,geoserver版本为2.9.1. (1)下载跨域war包 下载cor ...

  9. 聊聊、Zookeeper 客户端 ZkClient

    [ZkClient]  ZkClient 是 GitHub 上一个开源的客户端,如果我们用 Maven 来管理工程,则引用如下. <dependency> <groupId>o ...

  10. Linux shell 提取文件名和目录名的一些方法(转)

    很多时候在使用Linux的shell时,我们都需要对文件名或目录名进行处理,通常的操作是由路径中提取出文件名,从路径中提取出目录名,提取文件后缀名等等.例如,从路径/dir1/dir2/file.tx ...