5

我正在尝试使用以下命令在 mac mini 上启动 jenkins slave/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收到此错误。

jenkins2-slave3:~ jenkins$ ls -ld /Users/jenkins/jenkins_slave/
drwxrwxrwx  5 jenkins  jenkins  160 Nov 13  2018 /Users/jenkins/jenkins_slave/
jenkins2-slave3:~ jenkins$ ls -ld /Users/jenkins/
drwxr-xr-x+ 44 jenkins  staff  1408 Jun  5 10:12 /Users/jenkins/

如果我以用户身份在 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/"

有人知道这里有什么问题吗?

系统软件概述:

  System Version: macOS 10.14.4 (18E226)
  Kernel Version: Darwin 18.5.0
  Boot Volume: Macintosh HD
  Boot Mode: Normal
  Computer Name: jenkins-slave
  User Name: jenkins (jenkins)
  Secure Virtual Memory: Enabled
  System Integrity Protection: Enabled
  Time since boot: 7 days 23:11
4

1 回答 1

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

于 2018-11-27T02:57:00.967 回答