How to enable ci/cd in gitlab-ci.yml with the new tag and automate CI/CD

,

Replace this template with your information

Describe your question in as much detail as possible:

  • i want to deploy app using gitlab-ci.yml file in AWS ECS but with unique image tag including version every time, it will be new tag every time rather than latest tag of image.
  • for example: my image name is 500.dkr.ecr.ap-south-1.amazonaws.com/apiserver-express-betapoc:$version ( like 1234_0.0.35 ) so every time i have to create new revision for ECS task definition and then update the ECS service for that new task definition.
  • How do i enable ci/cd in gitlab-ci.yml with this new tag and automate it ?
  • What are you seeing, and how does that differ from what you expect to see?

  • Consider including screenshots, error messages, and/or other helpful visuals

  • What version are you on? Are you using self-managed or GitLab.com?
    Gitlab.com

  • Add the CI configuration from .gitlab-ci.yml and other configuration if relevant (e.g. docker-compose.yml)

deploy_beta_poc_env:
stage: post
script:
- aws --version
- aws ecr get-login-password --region ap-south-1 | docker login --username AWS --password-stdin 500.dkr.ecr.ap-south-1.amazonaws.com
- docker build -t 500.dkr.ecr.ap-south-1.amazonaws.com/apiserver-express-betapoc:$CI_PIPELINE_IID .
- docker push 500.dkr.ecr.ap-south-1.amazonaws.com/apiserver-express-betapoc:$CI_PIPELINE_IID
- aws ecs register-task-definition --region ap-south-1 --family api-express-betapoc --container-definitions=“500.dkr.ecr.ap-south-1.amazonaws.com/apiserver-express-betapoc:$CI_PIPELINE_IID
- aws ecs update-service --cluster chainparserecs --task-definition apiserver-express-betapoc --service api-server-express-betapoc-service --force-new-deployment --region ap-south-1
only:
- feature_all_merge

  • What troubleshooting steps have you already taken? Can you link to any docs or other resources so we know where you have been?

I have tried with different combinations to confirm whether it is working or not but still getting error.

Thanks,
Hardik

What error message are you receiving?