How to change the user running remote agent daemon on macOS

お困りですか?

アトラシアン コミュニティをご利用ください。

コミュニティに質問

プラットフォームについて: Server および Data Center のみ。この記事は、Server および Data Center プラットフォームのアトラシアン製品にのみ適用されます。

Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Fisheye および Crucible は除く

要約

Due to some requirements, the remote agent's daemon running on macOS may need to run with a specific user.

診断

During the remote agent startup, we can check in the atlassian-bamboo-agent.log which user is running the process:

INFO   | jvm 1    | 2021/03/08 12:26:54 | 2021-03-08 12:26:54,592 INFO [AgentRunnerThread] [lifecycle] *******************************
INFO   | jvm 1    | 2021/03/08 12:26:54 | 2021-03-08 12:26:54,593 INFO [AgentRunnerThread] [lifecycle] *      System information     *
INFO   | jvm 1    | 2021/03/08 12:26:54 | 2021-03-08 12:26:54,593 INFO [AgentRunnerThread] [lifecycle] *******************************
INFO   | jvm 1    | 2021/03/08 12:26:54 | 2021-03-08 12:26:54,704 INFO [AgentRunnerThread] [lifecycle] com.atlassian.bamboo.configuration.SystemInfoImpl@2e0f7f47[
INFO   | jvm 1    | 2021/03/08 12:26:54 |   userName=root
INFO   | jvm 1    | 2021/03/08 12:26:54 |   userTimezone=America/New_York
INFO   | jvm 1    | 2021/03/08 12:26:54 |   userLocale=English (United States)
INFO   | jvm 1    | 2021/03/08 12:26:54 |   systemEncoding=UTF-8


原因

By default, the daemon will be set to run as root.

ソリューション

  1. Stop Bamboo agent;
  2. Remove the service using <Remote agent home>/bin/bamboo-agent.sh remove;
  3. Since the daemon probably ran as root before, we will need to change some permissions, run:

    sudo chown -R bamboo <Agent home folder>
  4. Install the service running <Remote agent home>/bin/bamboo-agent.sh install. Do not run it;
  5. Edit /Library/LaunchDaemons/org.tanukisoftware.wrapper.bamboo-agent.plist add <key>UserName</key> as in the example below:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
    <dict>
        <key>Label</key>
        <string>org.tanukisoftware.wrapper.bamboo-agent</string>
        <key>ProgramArguments</key>
        <array>
            <string>/Users/bamboo/agent-home-7.2.2/bin/bamboo-agent.sh</string>
            <string>launchdinternal</string>
        </array>
        <key>KeepAlive</key>
        <false/>
        <key>RunAtLoad</key>
        <true/>
        <key>UserName</key>
        <string>bamboo</string>
    </dict>
</plist>

    6. Start the agent by loading the daemon:


sudo launchctl load -w /Library/LaunchDaemons/org.tanukisoftware.wrapper.bamboo-agent.plist


Note: By default macOS daemon doesn't pick up the environment variables from the user, to add it please check the Incorrect environment variables when running remote agent on macOS KB.


Last modified on Mar 31, 2021

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.