【问题标题】:Running job on Bamboo "Not privileged to remove service." on osx在 Bamboo 上运行作业“无权删除服务”。在 osx 上
【发布时间】:2021-01-20 20:12:31
【问题描述】:

当我运行脚本时:

launchctl remove com.apple.CoreSimulator.CoreSimulatorService

在构建机器上的终端中它工作正常,但是当我从竹子运行它时它失败并且在日志中我看到“没有特权删除服务。”。我尝试回显用户 ID,它在终端和竹日志中是相同的。我不明白为什么会这样。请问,您知道如何解决吗?它也不适用于 sudo。

【问题讨论】:

    标签: macos service bamboo access-rights


    【解决方案1】:

    根据Bruce Tu的回答:

    您的 Bamboo-Agent 作为 launchDaemon 而不是 launchAgent 运行。

    要解决此问题,您必须将 com.atlassian.bamboo-agent.plist 文件从 /Library/LaunchDaemons 移动到 /Library/LaunchAgents 并重新启动服务器。

    然后您可以将其添加到您的竹子构建脚本中以解决 CoreSimulator 问题:

    killall -9 com.apple.CoreSimulator.CoreSimulatorService || true
    launchctl remove com.apple.CoreSimulator.CoreSimulatorService || true
    

    【讨论】:

      【解决方案2】:

      我在 Jenkins 构建中遇到了同样的问题。我的解决方案也可能适用于 Bamboo。 我通过在构建开始之前运行的 shell 脚本中运行以下命令来解决它。

      这假设您无需输入密码即可允许 sudo。 如果没有,您也可以使用 chown -R the user:group 来执行杀戮/删除。

      希望这会有所帮助。

          sudo chmod -R g-w $(xcode-select -p)/Library/PrivateFrameworks/CoreSimulator.framework/Versions/A/XPCServices/com.apple.CoreSimulator.CoreSimulatorService.xpc 
          sudo chown -R root:wheel $(xcode-select -p)/Library/PrivateFrameworks/CoreSimulator.framework/Versions/A/XPCServices/com.apple.CoreSimulator.CoreSimulatorService.xpc 
          sudo killall -9 com.apple.CoreSimulator.CoreSimulatorService || true
          sudo launchctl remove com.apple.CoreSimulator.CoreSimulatorService || true
      

      【讨论】:

        【解决方案3】:

        我在 Mac 上的 Bamboo 中尝试运行命令时遇到了同样的问题

        launchctl remove com.apple.CoreSimulator.CoreSimulatorService
        

        问题是我将 Bamboo 设置为 LaunchDaemon 而不是 LaunchAgent。 LaunchAgent 无法访问 iOS 模拟器、配置文件、权限问题等。在我停止 LaunchDaemon 服务并将 Bamboo 设置为 LaunchAgent 后,我​​能够运行该命令。

        有关 LaunchDaemon 与 LaunchAgent 的更多信息,请参阅: http://mgrebenets.github.io/mobile%20ci/2015/02/01/mobile-ci-daemon-vs-agent

        【讨论】:

          【解决方案4】:

          尝试使用 sudo -u"USER" launchctl remove <service> 在根上下文中启动 LaunchAgent 时遇到相同的错误。

          这里的问题是sudo -u 并非在所有情况下都有效(例如:当它用于包的安装后脚本时)。

          解决方案:

          使用sudo -ulaunchctl asuser <userId> 的组合

          launchctl asuser <uid> sudo -u <uName> launchctl load -S Aqua -w "/Library/LaunchAgents/<plist>"
          

          该组合保证有效。

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 2013-12-20
            • 1970-01-01
            • 2011-09-03
            • 2016-12-18
            • 2015-06-20
            • 2021-11-07
            • 1970-01-01
            • 2021-12-25
            相关资源
            最近更新 更多