CI: expand variables in before_script

Variables that are defined in a job are not expanded in the before script of the job.

If that would work it would be possible to write nice templates to install dependencies in job specific before_scripts, e.g. something like:

.before_template: &install_deps
  before_script:
    - sudo sh -c 'echo "deb http://my.aptrepo.com/ubuntu $DISTRO_CODENAME main" > /etc/apt/sources.list.d/myrepo.list'
    - sudo apt-get update -yq && sudo apt-get install -y mydependency

.amd64_template: &amd64_job
  image: ubuntu:trusty
  variables:
    DISTRO_CODENAME: trusty
  <<: *install_deps
  tags:
    - amd64
    - docker

.armhf_template: &armhf_job
  image: armhf/ubuntu:trusty
  variables:
    DISTRO_CODENAME: trusty
  <<: *install_deps
  tags:
    - armhf
    - docker

.amd64_xenial_template: &amd64_xenial_job
  image: ubuntu:xenial
  variables:
    DISTRO_CODENAME: xenial
  <<: *install_deps
  tags:
    - amd64
    - docker

.armhf_xenial_template: &armhf_xenial_job
  image: armhf/ubuntu:xenial
  variables:
    DISTRO_CODENAME: xenial
  <<: *install_deps
  tags:
    - armhf
    - docker

.build_t: &build
  stage: build
  script:
    - mkdir build
    - cd build
    - cmake ..
    - make -j 4

.package_testing_t: &package_testing
  stage: deploy
  script:
    - mkdir build
    - cd build
    - cmake ..
    - make -j 4
    - make package
    - upload_deb.sh $DISTRO_CODENAME-testing *.deb
  only:
    - master

.package_stable_t: &package_stable
  stage: deploy
  script:
    - mkdir build
    - cd build
    - cmake ..
    - make -j 4
    - make package
    - upload_deb.sh $DISTRO_CODENAME-stable *.deb
  only:
    - /^v[0-9.]+$/
  except:
    - branches

##############
# Jobs
##############
build_amd64:
  <<: *amd64_job
  <<: *build

build_armhf:
  <<: *armhf_job
  <<: *build

build_xenial_amd64:
  <<: *amd64_xenial_job
  <<: *build

build_xenial_armhf:
  <<: *armhf_xenial_job
  <<: *build

package_testing_amd64:
  <<: *amd64_job
  <<: *package_testing

package_stable_amd64:
  <<: *amd64_job
  <<: *package_stable

package_testing_armhf:
  <<: *armhf_job
  <<: *package_testing

package_stable_armhf:
  <<: *armhf_job
  <<: *package_stable

package_xenial_testing_amd64:
  <<: *amd64_xenial_job
  <<: *package_testing

package_xenial_stable_amd64:
  <<: *amd64_xenial_job
  <<: *package_stable

package_xenial_testing_armhf:
  <<: *armhf_xenial_job
  <<: *package_testing

package_xenial_stable_armhf:
  <<: *armhf_xenial_job
  <<: *package_stable