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.

feita há 2 anos952 visualizações
1 Resposta
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".

respondido há 2 anos

Você não está conectado. Fazer login para postar uma resposta.

Uma boa resposta responde claramente à pergunta, dá feedback construtivo e incentiva o crescimento profissional de quem perguntou.

Diretrizes para responder a perguntas