0

AWS CodeDeploy タスクを使用して、Azure Devops パイプライン経由で AWS に何かをデプロイするビルド パイプラインがあります。AWS CodeDeploy タスクステップからのデプロイ Id の出力変数を入力として使用して、次のタスク AWS CLI コマンドを介してデプロイをクエリすることにより、このデプロイの詳細についてレポートしたいと考えています。

AWS CodeDeploy のステップと、出力変数の設定を次に示します。

ここに画像の説明を入力

次に、その変数を使用する手順を示します。

ここに画像の説明を入力

ビルド パイプラインからの出力エラーを次に示します。

コード デプロイ タスク:

Started deployment of new revision to deployment group VSTSEc2Targets for application VSTSTestApp, deployment ID d-PN4UXHVJO
Setting output variable deployment_id with the ID of the deployment
Waiting for deployment to complete

AWS CLI タスク:

[command]C:\windows\system32\cmd.exe /D /S /C "C:\hostedtoolcache\windows\Python\3.6.8\x64\Scripts\aws.cmd deploy get-deployment --deployment-id "$(codedeploy.deployment_id)""

An error occurred (InvalidDeploymentIdException) when calling the GetDeployment operation: Specified DeploymentId is not in the valid format: $(codedeploy.deployment_id)
##[error]Error: The process 'C:\hostedtoolcache\windows\Python\3.6.8\x64\Scripts\aws.cmd' failed with exit code 255

変数を実際の値に変換していないようです。誰でも手伝ってもらえますか?

PowerShell 経由で変数の出力をテストしたところ、次のエラーが発生しました。

variable check
codedeploy.deployment_id : The term 'codedeploy.deployment_id' is not recognized as the name of a cmdlet, function, 
script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is 
correct and try again.
At D:\a\_temp\4985f146-ca74-46a3-aed2-aa67cdc2e01a.ps1:5 char:14
+ Write-Host $(codedeploy.deployment_id)
+              ~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (codedeploy.deployment_id:String) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : CommandNotFoundException

##[error]PowerShell exited with code '1'.
##[section]Finishing: PowerShell Script

スクリプトの使用:

# Write your PowerShell commands here.

Write-Host "variable check"
Write-Host $(codedeploy.deployment_id)
4

1 に答える 1