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 年前953 查看次数
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 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则