How to run a PowerShell Script task with specific user account in Bamboo

お困りですか?

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

コミュニティに質問

プラットフォームについて: 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 は除く

要約

Bamboo runs the Script tasks as the user account which Bamboo runs as. If you require to run a  PowerShell Script task as a different user other than Bamboo you do not have a way to specify in the Script Task configuration.


環境 

  • A Script Task in your plan requires running as a specific user other than the Bamboo user.

ソリューション

  1. Run remote agent as a different user: Run a remote agent on the windows server as the user you would like to run the script as and run the build plan with that agent.

  2. Run multiple agents as different users: Split the Plan into different stages and use different agent capabilities that may indicate which agent would run each task. This way, you can have agents running over different users and still have control over the same Plan

  3. Run PowerShell Script: If you could run a PowerShell Script to switch to a different user and perform a command, you could use the same script in the Bamboo Script task

              eg: 

PowerShell Script New-PSSession
$password = ConvertTo-SecureString $Env:bamboo_test_password -AsPlainText -Force
$username =  $Env:bamboo_test_username
echo "Password From Bamboo variable ::: " $password
echo "Username  From Bamboo variable  ::: " $username
$Cred = New-Object System.Management.Automation.PSCredential ($username, $password)

echo $Cred
New-PSSession -Credential $Cred  | Enter-PSSession

最終更新日: 2022 年 2 月 24 日

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

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