How to use Bamboo Password Variable to SSH with Script task

お困りですか?

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

コミュニティに質問

The below code only works on Linux/Mac OS based system.

目的

This document is focused on how to utilize Bamboo password variables to SSH into remote host using Bamboo Script task.

ソリューション

Follow the steps to configure the script task:

  • Add a script task to your Bamboo plan and use the below code:

    #!/usr/bin/expect -f
    spawn ssh <username>@<hostname> "sh test.txt"
    expect "Password:"
    send "${bamboo.password_variable_name}\r"
    interact

    Pointers:

    • Replace <username> with a username and <hostname> with a hostname of the machine to which you will be establishing the connection.
    • "sh test.txt" could be changed to commands as well. For example - "echo hello". In this case, this "test.txt" file is present under the home directory of the host in which I am logging into using the SSH session.
    • "bamboo.password_variable_name" is the global variable which I am using here as the password. Name of that Global Variable is - "password_variable_name"
    • 前提条件:
      • expect - You have to get the binary of "expect" installed.





最終更新日: 2019 年 12 月 5 日

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

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