jenkins代理在mac目录不可访问

jv4diomz  于 2023-11-17  发布在  Jenkins
关注(0)|答案(2)|浏览(205)

我正在尝试在Mac Mini上启动jenkins代理,如下所示/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/


如果我以jenkins用户的身份在mac上运行以下命令,它可以工作。
/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

t98cgbkg

t98cgbkg1#

所以它适用于“jenkins”用户的原因是因为Jenkins创建了一个具有jenkins用户的应用程序帐户,该用户有权运行/访问Jenkins(及其文件夹-在您的情况下为-workDir "/Users/jenkins/jenkins_slave/")。这就是为什么jenkins可以运行命令,但当您尝试使用sudo运行它时会失败。
为什么sudo会失败?
这主要是因为在树的更高的目录中,您没有执行权限,所以即使使用777,您仍然无法运行它。
相反,对希望获得访问权限的用户的目录执行chownusermod操作

sudo usermod -a -G rohit git

字符串
更多信息https://askubuntu.com/questions/812513/permission-denied-in-777-folder

zlhcx6iw

zlhcx6iw2#

我遇到了同样的问题。问题是目录的引号:

<string>"/Users/jenkins/jenkins_slave/"</string>

字符串
只要删除它们,它就会工作:

<string>/Users/jenkins/jenkins_slave/</string>

相关问题