title: Tagging a Docker image with auto incremented global version in Gitlab in yaml
body: <p>I'm currently digging in Gitlab CI. I would like to add a way in my YAML files to tag my docker images with a version number composed in the following fashion : MajorVersion.Minorversion.AutoincrementedGlobalversionNumber</p>
  
  <p>I would like to auto-increment the globally defined variable "AutoincrementedGlobalversionNumber" each time I deploy.</p>
  
  <p>I have used CI_PIPELINE_IID however it keeps incrementing for each pipeline request, I need something to keep a version where I can keep track of and it should increment only when I pack and deploy.</p>
  
  <pre><code>   variables:
        CI_VERSION: "1.0.${CI_PIPELINE_IID}"
  
      build-master:
        stage: build
        script:
          - docker build --pull -t "$CI_REGISTRY_IMAGE" -t "$CI_REGISTRY_IMAGE:$CI_VERSION"   ./postfix
          - docker push "$CI_REGISTRY_IMAGE"
        only:
          - master
  </code></pre>