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.

preguntada hace 2 años952 visualizaciones
1 Respuesta
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 hace 2 años

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.

Pautas para responder preguntas