Skip to content

Commit

Permalink
Add env var for platform of underlying device
Browse files Browse the repository at this point in the history
  • Loading branch information
saville committed Dec 11, 2023
1 parent 58f2ddf commit 8be2293
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions buildrunner/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import json
import logging
import os
import platform
import shutil
import sys
import tarfile
Expand Down Expand Up @@ -89,6 +90,7 @@ def _get_config_context(self, ctx=None, global_env=None):
"""

context = {
'BUILDRUNNER_PLATFORM': str(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)),
Expand Down
8 changes: 7 additions & 1 deletion tests/test-files/test-general.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
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'

0 comments on commit 8be2293

Please sign in to comment.