[libvirt PATCH 1/2] gitlab: Add and use 'environment' template

Andrea Bolognani abologna at redhat.com
Fri Mar 27 17:15:58 UTC 2020


This template provides a standardized place where environment
variables, which might not be static but depend on the output of
some shell command, can be defined for later use. It's not very
interesting right now, but we'll put it to good use in a second.

This pattern is already used in libosinfo's GitLab CI integration.

Signed-off-by: Andrea Bolognani <abologna at redhat.com>
---
 .gitlab-ci.yml | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 1e3675ace0..eeeff7ed48 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,5 +1,4 @@
 variables:
-  MAKE: make
   GIT_DEPTH: 100
 
 stages:
@@ -7,6 +6,8 @@ stages:
   - native_build
   - cross_build
 
+.environment: &environment |
+  export MAKE="make"
 
 # Common templates
 
@@ -18,6 +19,7 @@ stages:
       - ccache/
     key: "$CI_JOB_NAME"
   before_script:
+    - *environment
     - mkdir -p ccache
     - export CC="ccache gcc"
     - export CCACHE_BASEDIR=${PWD}
@@ -45,6 +47,7 @@ stages:
       - ccache/
     key: "$CI_JOB_NAME"
   before_script:
+    - *environment
     - mkdir -p ccache
     - export CC="ccache ${ABI}-gcc"
     - export CCACHE_BASEDIR=${PWD}
@@ -163,6 +166,8 @@ mingw64-fedora-30:
 #    https://gitlab.com/libvirt/libvirt/-/jobs/artifacts/master/download?job=website
 website:
   stage: prebuild
+  before_script:
+    - *environment
   script:
     - mkdir build
     - cd build
@@ -183,6 +188,8 @@ website:
 
 codestyle:
   stage: prebuild
+  before_script:
+    - *environment
   script:
     - mkdir build
     - cd build
@@ -198,6 +205,8 @@ potfile:
   stage: prebuild
   only:
     - master
+  before_script:
+    - *environment
   script:
     - mkdir build
     - cd build
@@ -222,6 +231,8 @@ potfile:
 dco:
   stage: prebuild
   image: quay.io/libvirt/buildenv-libvirt-fedora-31:latest
+  before_script:
+    - *environment
   script:
     - ./scripts/require-dco.py
   only:
-- 
2.25.1




More information about the libvir-list mailing list