You can use the Bamboo SSH task to execute a SSH command on a remote computer as part of a Bamboo job.

You can use the SSH task to do such things as:

  • Calling database migration scripts 
  • Starting and stopping services
  • Anything you can run on the command line on a remote machine

See Configuring a deployment task for an overview of Bamboo deployment tasks.

To configure an SSH task:

  1. ジョブのタスク設定タブに移動します(新しいプランを作成するとデフォルト ジョブとなります)。
  2. Click the name of an existing SSH task, or click Add Task and then SSH Task to create a new task.
  3. Complete the following settings:
     

    タスクの説明タスクの目的を識別するのに役立ちます。
    このタスクを無効化オンまたはオフにすることで、選択的にこのタスクを実行します。
    ホストThe hostname or IP address of the remote server on which the SSH Command will be executed.
    接続時にリモート ホスト フィンガープリントを確認Enter the host fingerprint to be verified. See below for more details.
    ポートSSH 接続に使用されるリモート ホストのポート番号です。デフォルト値は 22 です。
    ユーザ名リモート ホストへの接続に使用するユーザー名です。
    認証タイプパスワードユーザー名に関連付けられたパスワードです。
    鍵(パスフレーズなし) – リモート ホストでの認証に使用する SSH 秘密鍵を参照します。
    鍵(パスフレーズあり) – リモート ホストでの認証に使用する SSH 秘密鍵を参照し、パスフレーズを提供します。
    SSH CommandThe shell command to execute on the remote host. You can only enter a single command here.
  4. Click Save.

ホスト フィンガープリント

以下のコマンドを実行して、ホストのフィンガープリントを判断することができます。

ssh-keygen -l -F <HOSTNAME>

以下のスクリーンショットに示すように、フィンガープリントはレスポンスの一部です。

  • ラベルなし

11 Comments

  1. Anonymous

    Would it be a nice feature to be able to set a base directory here from which the command will execute?

  2. Anonymous

    If you have a multi-line command, are the lines run in sequence?

  3. Anonymous

    Is there a plan to support multi-line command's?

    1. James Dumay

      You can just specify different commands on multiple lines.

  4. Odin Odin

    When executing commands through the SSH-task, the output from commands are only updated after each command line is executed. Is there any plans to change this behaviour so that the command ouput is shown in Bamboo's deployment log more regularly, i.e updated at a given interval?

  5. Alvaro GAreppe

    I need to run a command with sudo but I'm getting "sudo: sorry, you must have a tty to run sudo".

    To avoid this error and be able to run a sudo command I need to specify -t option to the ssh command. There is any way to do this ?

    1. James Dumay

      Hi Alvaro,

      I'm not sure what could be the problem here. Could you contact our support team? They would be better equipped to help you.

      Thanks
      James

      1. Frank

        exactly the same issue here...

  6. Anonymous

    Hi.

    How i can used variables in "SSH command" field?

    Thx

    1. NathanA

      Hi, what exactly are you trying to achieve? Can you provide a few more details?

      Cheers,

      Nathan

      1. Piotr Tomaszewski

        Same request here. I'd like to be able to put into the SSH command box something like:

        touch "${bamboo.build.number}.txt"

        Without it, the benefits of using bamboo deployments are very limited as we need to create a lot of environment-specific tasks.