一、问题描述

在Mac上使用jenkins的过程里,执行某些shell脚本时出现报错,查看报错信息发现是当前用户没有权限删除某个文件夹导致的。于是在网上搜了很多资料,发现可用的是少之又少,于是自己写篇博客总结一下如何在OSX操作系统中修改jenkins的默认用户

二、步骤

①打开终端terminal

②停止jenkins: launchctl unload /Library/LaunchDaemons/org.jenkins-ci.plist

③编辑/Library/LaunchDaemons/org.jenkins-ci.plist,文件内容如下

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">

<plist version="1.0">

  <dict>

    <key>StandardOutPath</key>

    <string>/var/log/jenkins/jenkins.log</string>

    <key>StandardErrorPath</key>

    <string>/var/log/jenkins/jenkins.log</string>

    <key>EnvironmentVariables</key>

    <dict>

      <key>JENKINS_HOME</key>

      <string>/Users/Shared/Jenkins/Home</string>

    </dict>

    <key>GroupName</key>

    <string>wheel</string>#此处为用户所属的组,改为root用户所属的组

    <key>KeepAlive</key>

    <true/>

    <key>Label</key>

    <string>org.jenkins-ci</string>

    <key>ProgramArguments</key>

    <array>

      <string>/bin/bash</string>

      <string>/Library/Application Support/Jenkins/jenkins-runner.sh</string>

    </array>

    <key>RunAtLoad</key>

    <true/>

    <key>UserName</key>

    <string>root</string>#此处为jenkins默认用户,默认值为jenkins用户,改为root用户

    <key>SessionCreate</key>

    <true/>

  </dict>

</plist>


④更改jenkins文件夹的所属用户与组:

chown -R root Jenkins/

chgrp -R wheel Jenkins/


⑤启动jenkins:launchctl load /Library/LaunchDaemons/org.jenkins-ci.plist







Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐