diff options
author | Daniel P. Berrangé <berrange@redhat.com> | 2024-04-15 18:58:05 +0100 |
---|---|---|
committer | Daniel P. Berrangé <berrange@redhat.com> | 2024-04-19 11:55:22 +0100 |
commit | 521cf2fe0619d08dedbbb81777ece10c414bb017 (patch) | |
tree | fe826f9f04727f00879d65491824da5c0d8749ad | |
parent | 0242bd3bfdb616e876437085dfac0b18cc7e6632 (diff) | |
download | libvirt-ci-521cf2fe0619d08dedbbb81777ece10c414bb017.zip libvirt-ci-521cf2fe0619d08dedbbb81777ece10c414bb017.tar.gz libvirt-ci-521cf2fe0619d08dedbbb81777ece10c414bb017.tar.bz2 |
gitlab: use 'cirrus-vars' tool for generating build file
The giant 'sed' command that is used to generate a Cirrus CI build YAML
file has a hardcoded list of environment variable substitutions it can
perform. For most projects this list is overkill and for some projects
it is insufficient.
Now that the 'cirrus-run' container has the 'cirrus-vars' command, we
can invoke that to dynamically perform the substitutions. Since the
'vars' files don't export the shell variables they declare, we must
add 'set -o allexport' to force all vars to be implicitly exported.
Note that when updating projects across this commit, their 'build.yml'
file will need changing for the special handling of '$PATH' that used
to be done by sed, and must now be done in the 'build.yml' directly:
- PATH: "@PATH@"
+ PATH: "@PATH_EXTRA@:$PATH"
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
-rw-r--r-- | lcitool/gitlab.py | 22 | ||||
-rw-r--r-- | tests/data/manifest/out/ci/gitlab/build-templates.yml | 22 |
2 files changed, 6 insertions, 38 deletions
diff --git a/lcitool/gitlab.py b/lcitool/gitlab.py index 277ac12..e5e2142 100644 --- a/lcitool/gitlab.py +++ b/lcitool/gitlab.py @@ -339,26 +339,10 @@ def cirrus_template(cidir): interruptible: true needs: [] script: + - set -o allexport - source {cidir}/cirrus/$NAME.vars - - sed -e "s|[@]CI_REPOSITORY_URL@|$CI_REPOSITORY_URL|g" - -e "s|[@]CI_COMMIT_REF_NAME@|$CI_COMMIT_REF_NAME|g" - -e "s|[@]CI_MERGE_REQUEST_REF_PATH@|$CI_MERGE_REQUEST_REF_PATH|g" - -e "s|[@]CI_COMMIT_SHA@|$CI_COMMIT_SHA|g" - -e "s|[@]CIRRUS_VM_INSTANCE_TYPE@|$CIRRUS_VM_INSTANCE_TYPE|g" - -e "s|[@]CIRRUS_VM_IMAGE_SELECTOR@|$CIRRUS_VM_IMAGE_SELECTOR|g" - -e "s|[@]CIRRUS_VM_IMAGE_NAME@|$CIRRUS_VM_IMAGE_NAME|g" - -e "s|[@]UPDATE_COMMAND@|$UPDATE_COMMAND|g" - -e "s|[@]UPGRADE_COMMAND@|$UPGRADE_COMMAND|g" - -e "s|[@]INSTALL_COMMAND@|$INSTALL_COMMAND|g" - -e "s|[@]PATH@|$PATH_EXTRA${{PATH_EXTRA:+:}}\\$PATH|g" - -e "s|[@]PKG_CONFIG_PATH@|$PKG_CONFIG_PATH|g" - -e "s|[@]PKGS@|$PKGS|g" - -e "s|[@]MAKE@|$MAKE|g" - -e "s|[@]PYTHON@|$PYTHON|g" - -e "s|[@]PIP3@|$PIP3|g" - -e "s|[@]PYPI_PKGS@|$PYPI_PKGS|g" - -e "s|[@]XML_CATALOG_FILES@|$XML_CATALOG_FILES|g" - <{cidir}/cirrus/build.yml >{cidir}/cirrus/$NAME.yml + - set +o allexport + - cirrus-vars <{cidir}/cirrus/build.yml >{cidir}/cirrus/$NAME.yml - cat {cidir}/cirrus/$NAME.yml - cirrus-run -v --show-build-log always {cidir}/cirrus/$NAME.yml rules: diff --git a/tests/data/manifest/out/ci/gitlab/build-templates.yml b/tests/data/manifest/out/ci/gitlab/build-templates.yml index 0b3eeb4..9aa81a1 100644 --- a/tests/data/manifest/out/ci/gitlab/build-templates.yml +++ b/tests/data/manifest/out/ci/gitlab/build-templates.yml @@ -276,26 +276,10 @@ interruptible: true needs: [] script: + - set -o allexport - source ci/cirrus/$NAME.vars - - sed -e "s|[@]CI_REPOSITORY_URL@|$CI_REPOSITORY_URL|g" - -e "s|[@]CI_COMMIT_REF_NAME@|$CI_COMMIT_REF_NAME|g" - -e "s|[@]CI_MERGE_REQUEST_REF_PATH@|$CI_MERGE_REQUEST_REF_PATH|g" - -e "s|[@]CI_COMMIT_SHA@|$CI_COMMIT_SHA|g" - -e "s|[@]CIRRUS_VM_INSTANCE_TYPE@|$CIRRUS_VM_INSTANCE_TYPE|g" - -e "s|[@]CIRRUS_VM_IMAGE_SELECTOR@|$CIRRUS_VM_IMAGE_SELECTOR|g" - -e "s|[@]CIRRUS_VM_IMAGE_NAME@|$CIRRUS_VM_IMAGE_NAME|g" - -e "s|[@]UPDATE_COMMAND@|$UPDATE_COMMAND|g" - -e "s|[@]UPGRADE_COMMAND@|$UPGRADE_COMMAND|g" - -e "s|[@]INSTALL_COMMAND@|$INSTALL_COMMAND|g" - -e "s|[@]PATH@|$PATH_EXTRA${PATH_EXTRA:+:}\$PATH|g" - -e "s|[@]PKG_CONFIG_PATH@|$PKG_CONFIG_PATH|g" - -e "s|[@]PKGS@|$PKGS|g" - -e "s|[@]MAKE@|$MAKE|g" - -e "s|[@]PYTHON@|$PYTHON|g" - -e "s|[@]PIP3@|$PIP3|g" - -e "s|[@]PYPI_PKGS@|$PYPI_PKGS|g" - -e "s|[@]XML_CATALOG_FILES@|$XML_CATALOG_FILES|g" - <ci/cirrus/build.yml >ci/cirrus/$NAME.yml + - set +o allexport + - cirrus-vars <ci/cirrus/build.yml >ci/cirrus/$NAME.yml - cat ci/cirrus/$NAME.yml - cirrus-run -v --show-build-log always ci/cirrus/$NAME.yml rules: |