CodeDeploy Environment Variables On Windows

0

I am using CodeDeploy to deploy a .Net app to a Windows Server 2022 machine. I am using an AppSpec.yml file to manage the deployment steps. I have read that you can read in the CodeDeploy environment variables such as $DEPLOYMENT_GROUP_NAME in your hook scripts e.g. https://aws.amazon.com/blogs/devops/using-codedeploy-environment-variables/. The example are always in linux scripts though e.g.

    
if [ "$DEPLOYMENT_GROUP_NAME" == "Staging" ]
then

I am wanting to do this in a cmd file as when deploying to Windows you can't use .sh files. I have tried as a test echoing the results of a variable from a cmd file but it always comes out as not being set to my Deployment Group Name. Are CodeDeploy variables not available in windows deployments or am I using them wrong. What I am trying to achieve ultimately is to know which Deployment Group (Test or Prod) is being deployed to so that I can update some configuration accordingly.

已提問 2 年前檢視次數 952 次
1 個回答
1

Actually figured it out. For Windows when using cmd or bat files you need to use a slightly different variable syntax. It is

%DEPLOYMENT_GROUP_NAME%

instead of

$DEPLOYMENT_GROUP_NAME

The %DEPLOYMENT_GROUP_NAME% gets replaced with the correct value. In my case "Staging".

已回答 2 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南