Save app version per environment

I want to carry/copy app version between environments. So if the app pipeline goes from dev->QA->Stage->Prod, I want to capture that app/docker version/tag to some var that the env picks up and deploys that version. That way I always know what version is in that environment, can re-deploy that whole environment, or create a new env based off of what is deployed in say Prod.