我试图通过以下/Library/LaunchDaemons/com.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>Label</key>
<string>com.jenkins.ci</string>
<key>UserName</key>
<string>jenkins</string>
<key>SessionCreate</key>
<true/>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/java</string>
<string>-Djava.awt.headless=true</string>
<string>-jar</string>
<string>/Users/jenkins/agent.jar</string>
<string>-jnlpUrl</string>
<string>http://jenkins2.domain.net:8080/computer/jenkins-mac/slave-agent.jnlp</string>
<string>-secret</string>
<string>23erft6yhujnhyujnbftyujbvcdrtyhbvcxswedaw</string>
<string>-workDir</string>
<string>"/Users/jenkins/jenkins_slave/"</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>StandardErrorPath</key>
<string>/Users/jenkins/error.log</string>
<key>StandardOutPath</key>
<string>/Users/jenkins/stdout.log</string>
</dict>
</plist>
然后
sudo launchctl load /Library/LaunchDaemons/com.jenkins.ci.plist
但是在/Users/jenkins/error.log
我明白了
Exception in thread "main" java.io.IOException: The specified working directory should be fully accessible to the remoting executable (RWX): "/Users/jenkins/jenkins_slave/"
at org.jenkinsci.remoting.engine.WorkDirManager.verifyDirectory(WorkDirManager.java:249)
at org.jenkinsci.remoting.engine.WorkDirManager.initializeWorkDir(WorkDirManager.java:202)
at hudson.remoting.Launcher.run(Launcher.java:300)
at hudson.remoting.Launcher.main(Launcher.java:283)
我打开/Users/jenkins/jenkins_slave/
时仍然遇到此错误。777
。
如果我在Mac上以jenkins
用户的身份运行,则可以正常运行
/usr/bin/java -Djava.awt.headless=true -jar /Users/jenkins/agent.jar -jnlpUrl http://jenkins2.domain.net:8080/computer/jenkins-mac/slave-agent.jnlp -secret 23erft6yhujnhyujnbftyujbvcdrtyhbvcxswedaw -workDir "/Users/jenkins/jenkins_slave/"
有人知道这是怎么回事吗?
我在:
产品名称:Mac OS X
产品版本:10.14.1
BuildVersion:18B75
答案 0 :(得分:2)
所以它对“ jenkins”用户有效的原因是因为Jenkins与jenkins
用户创建了一个具有运行/访问Jenkins(及其文件夹,在您的情况下为-workDir "/Users/jenkins/jenkins_slave/"
)的权限的应用程序帐户。这就是jenkins
可以运行命令的原因,但是当您尝试使用sudo运行该命令时将失败。
为什么sudo失败?
这主要是因为树中有更高的目录,您没有执行权限,因此即使使用777,您仍将无法运行它。
在目录上对您希望访问的用户执行chown
或usermod
sudo usermod -a -G rohit git
有关更多信息,https://askubuntu.com/questions/812513/permission-denied-in-777-folder