return base64.encodebytes(signature).strip().decode()
-def upload_artifact(file_name, content_type, device_name):
+def upload_artifact(file_name, key, content_type):
with open('.minio_credentials', 'r') as f:
credentials = json.load(f)["minio-packet.freedesktop.org"]
minio_key = credentials["AccessKeyId"]
minio_secret = credentials["SecretAccessKey"]
minio_token = credentials["SessionToken"]
- resource = '/artifacts/%s/%s/%s/%s' % (os.environ['CI_PROJECT_PATH'], os.environ['CI_PIPELINE_ID'], device_name, os.path.basename(file_name))
+ resource = '/artifacts/%s/%s/%s/%s' % (os.environ['CI_PROJECT_PATH'],
+ os.environ['CI_PIPELINE_ID'],
+ os.environ['CI_JOB_ID'],
+ key)
date = formatdate(timeval=None, localtime=False, usegmt=True)
url = 'https://minio-packet.freedesktop.org%s' % (resource)
to_sign = "PUT\n\n%s\n%s\nx-amz-security-token:%s\n%s" % (content_type, date, minio_token, resource)
os.makedirs(results_path, exist_ok=True)
shutil.move(log_file, os.path.join(results_path, os.path.split(log_file)[1]))
if not ok and os.environ.get('TRACIE_UPLOAD_TO_MINIO', '0') == '1':
- upload_artifact(image_file, 'image/png', device_name)
+ upload_artifact(image_file, 'traces/%s.png' % checksum, 'image/png')
if not ok or os.environ.get('TRACIE_STORE_IMAGES', '0') == '1':
image_name = os.path.split(image_file)[1]
shutil.move(image_file, os.path.join(results_path, image_name))
with open(os.path.join(RESULTS_PATH, 'results.yml'), 'w') as f:
yaml.safe_dump(results, f, default_flow_style=False)
if os.environ.get('TRACIE_UPLOAD_TO_MINIO', '0') == '1':
- upload_artifact(os.path.join(RESULTS_PATH, 'results.yml'), 'text/yaml', device_name)
+ upload_artifact(os.path.join(RESULTS_PATH, 'results.yml'), 'traces/results.yml', 'text/yaml')
return all_ok