diff --git a/README.rst b/README.rst index b63fb11b..1a83ca3c 100755 --- a/README.rst +++ b/README.rst @@ -485,6 +485,7 @@ Buildrunner injects special environment variables and volume mounts into every run container. The following environment variables are set and available in every run container: +:``BUILDRUNNER_PLATFORM``: the platform of the current device (x86_64, aarch64, etc), equivalent to ``platform.machine()`` :``BUILDRUNNER_BUILD_NUMBER``: the build number :``BUILDRUNNER_BUILD_ID``: a unique id identifying the build (includes vcs and build number information), e.g. "main-1791.Ia09cc5.M0-1661374484" diff --git a/buildrunner/__init__.py b/buildrunner/__init__.py index 52a0d1b5..06b6c75a 100644 --- a/buildrunner/__init__.py +++ b/buildrunner/__init__.py @@ -16,6 +16,7 @@ import json import logging import os +import platform as python_platform import shutil import sys import tarfile @@ -89,6 +90,7 @@ def _get_config_context(self, ctx=None, global_env=None): """ context = { + 'BUILDRUNNER_PLATFORM': str(python_platform.machine()), 'BUILDRUNNER_BUILD_NUMBER': str(self.build_number), 'BUILDRUNNER_BUILD_ID': str(self.build_id), 'BUILDRUNNER_BUILD_DOCKER_TAG': str(sanitize_tag(self.build_id)), diff --git a/setup.py b/setup.py index 0354b121..d96df318 100644 --- a/setup.py +++ b/setup.py @@ -13,7 +13,7 @@ from setuptools import setup, find_packages -BASE_VERSION = '3.0' +BASE_VERSION = '3.1' SOURCE_DIR = os.path.dirname( os.path.abspath(__file__) diff --git a/tests/test-files/test-general.yaml b/tests/test-files/test-general.yaml index 95b7cb80..6b64eb2c 100644 --- a/tests/test-files/test-general.yaml +++ b/tests/test-files/test-general.yaml @@ -145,4 +145,10 @@ steps: test-uncompressed-dirs: run: image: {{ DOCKER_REGISTRY }}/centos:8 - cmd: 'if [ $(ls -laR /artifacts/setup-uncompress-dirs/ | grep tar.gz | wc -l) != 0 ]; then exit 1; fi' \ No newline at end of file + cmd: 'if [ $(ls -laR /artifacts/setup-uncompress-dirs/ | grep tar.gz | wc -l) != 0 ]; then exit 1; fi' + + test-platform: + run: + image: {{ DOCKER_REGISTRY }}/centos:8 + cmd: 'if [ -z "{{ BUILDRUNNER_PLATFORM }}" ]; then exit 1; else echo "Platform is {{ BUILDRUNNER_PLATFORM }}"; fi' +