簡體   English   中英

AWS Run Command的行為不同於在本地服務器上運行的行為

[英]AWS Run Command act different than running on server locally

我在Bamboo服務器上的EC2實例上運行命令時遇到問題。 我有一個從AWS控制台中的Run Command生成的命令。 我將該命令放在竹服務器上的腳本中並運行:

aws ssm send-command --document-name "AWS-RunPowerShellScript" --targets '{\"Key\":\"tag:Name\",\"Values\":[\"Auto-Scaling-Group\"]}' --parameters '{\"commands\":[\"$fileEXE = \\\"C:\\\\Program Files (x86)\\\\NUnit\\\\NUnit.ConsoleRunner.3.7.0\\\\tools\\\\nunit3-console.exe\\\\\\\"\",\"$testDll = \\\"C:\\\\TestFramework\\\\TestFramework\\\\Tests\\\\bin\\\\Debug\\\\TESTS.dll\\\"\",\"[System.Diagnostics.Process]::Start($fileEXE,$testDll)\"]}' --comment "Run Test UI Testing" --timeout-seconds 600 --region us-east-1

它確實運行測試。 但是它將Chrome.exe瀏覽器和chromedriver.exe作為后台進程運行。 因為沒有瀏覽器顯示,所以拋出NoSuchWindowException。

我可以在本地實例上的PowerShell中運行相同的命令:(*請注意,這是粘貼到“運行命令”控制台中以生成上述代碼的同一命令。)

$fileEXE = "C:\Program Files (x86)\NUnit\NUnit.ConsoleRunner.3.7.0\tools\nunit3-console.exe\"
$testDll = "C:\TestFramework\TestFramework\Tests\bin\Debug\TESTS.dll"
[System.Diagnostics.Process]::Start($fileEXE,$testDll)

它工作正常。 chromedriver.exe是一個后台進程,而chrome.exe(瀏覽器)是一個正常運行的應用程序,工作原理與正常情況相同。

我相信我的問題是Run Command如何運行我的測試程序。

運行命令( send-command )和在本地運行PowerShell命令有什么區別? 它不應該做同樣的事情嗎?

我認為引號和轉義方式有點混亂。

請參閱: 如何在雙引號內轉義雙引號?

這個版本看起來應該簡單得多:

CMD='$fileEXE = "C:\Program Files (x86)\NUnit\NUnit.ConsoleRunner.3.7.0\tools\nunit3-console.exe";'
CMD+='$testDll = "C:\TestFramework\TestFramework\Tests\bin\Debug\TESTS.dll";'
CMD+='[System.Diagnostics.Process]::Start($fileEXE,$testDll);'

aws ssm send-command --document-name "AWS-RunPowerShellScript" \
  --filters "Name=tag:Name,Values=Auto-Scaling-Group" \
  --comment "Run Test UI Testing" --timeout-seconds 600 --region us-east-1 \
  --parameters commands="'$CMD'"

注意:在Bash shell中運行它。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM