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. sql联合主键,用于多对多,关系映射

    如题.记录下. 复合主键,由多个字段共同确定一行信息 composite key, containing multi cols to fix one element.

  2. [LeetCode] Add Two Numbers 链表

    You are given two linked lists representing two non-negative numbers. The digits are stored in rever ...

  3. OpenGL ES 画直线代码实例

    http://blog.csdn.net/yexiaozi_007/article/details/7978620 以画xyz坐标轴为例,很多人会遇到用glcolor设置了颜色,但是直线画出来还是黑色 ...

  4. 修复无法启动的mariadb

    一直在用的数据库,今天无论如何启动不了了,最后在archlinux wiki上查到了解决方法: mysql_install_db --user=mysql --basedir=/usr --datad ...

  5. c# Thread类

    现在C#已经建议摈弃使用 Suspend, Resume 暂停/恢复线程, 也尽量少用 Abort方法中断一个线程. 建议使用线程的同步手段有:  Mutex.ManualResetEvent.Aut ...

  6. 解决mysql 远程链接问题

    grant all privileges on *.* to 'root'@'192.168.2.204' identified by '123456' with grant option;flush ...

  7. Codeforces Gym100735 D.Triangle Formation (KTU Programming Camp (Day 1) Lithuania, Birˇstonas, August 19, 2015)

    日常训练题解 D.Triangle Formation You are given N wooden sticks. Your task is to determine how many triang ...

  8. 2018年东北农业大学春季校赛 E 阶乘后的0【数论】

    链接:https://www.nowcoder.com/acm/contest/93/E来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 262144K,其他语言52428 ...

  9. APACHE 配置虚拟主机和HTTPS

    prepare the running env of os make sure you are using redhat or centen os 7.5 cat /etc/redhat-releas ...

  10. jcraft--SFTP demo

    import java.awt.Container; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import ...