@@ -9,6 +9,7 @@ variables:
targz: disable
dtb: none
deploy: enable
+ deploy_kernelci: enable
stages:
- build
@@ -37,7 +38,8 @@ default:
- if [ "${release}" = "bullseye" ]; then base_yaml="${base_yaml}:kas/opt/bullseye.yml"; fi;
- echo "Building ${base_yaml}"
- kas build ${base_yaml}
- - if [ "${deploy}" = "enable" ]; then scripts/deploy-cip-core.sh ${release} ${target} ${extention} ${dtb}; fi
+ - if [ "${deploy}" = "enable" ]; then scripts/deploy-cip-core.sh ${release} ${target} ${extention} ${dtb}; fi;
+ - if [ "${deploy_kernelci}" = "enable" ]; then scripts/deploy-kernelci.py ${release} ${target} ${extention} ${dtb}; fi
# base image
build:simatic-ipc227e-base:
new file mode 100755
@@ -0,0 +1,48 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+
+import subprocess
+import requests
+import os
+import sys
+import time
+from urllib.parse import urljoin
+
+cdate=time.strftime("%Y%m%d")
+api="https://api.staging.kernelci.org/upload"
+token=os.getenv("KERNELCI_TOKEN")
+
+release=sys.argv[1]
+target=sys.argv[2]
+extension=sys.argv[3]
+
+rootfs_filename="cip-core-image-"+extension+"-cip-core-"+release+"-"+target+".tar.gz"
+initrd_filename="cip-core-image-"+extension+"-cip-core-"+release+"-"+target+"-initrd.img"
+input_dir="build/tmp/deploy/images/"+target
+upload_path="/images/rootfs/cip/"+cdate+"/"+target+"/"
+rootfs=input_dir+"/"+rootfs_filename
+initrd=input_dir+"/"+initrd_filename
+
+print("build directory contents:")
+print(os.listdir(input_dir))
+
+def upload_file(api, token, path, input_file, input_filename):
+ headers = {
+ 'Authorization': token,
+ }
+ data = {
+ 'path': path,
+ }
+ files = {
+ 'file': (input_filename, open(input_file, 'rb').read()),
+ }
+ url = urljoin(api, 'upload')
+ resp = requests.post(url, headers=headers, data=data, files=files)
+ resp.raise_for_status()
+
+if os.path.exists(rootfs) and os.path.exists(initrd):
+ print("uploading rootfs to KernelCI")
+ upload_file(api, token, upload_path, rootfs, rootfs_filename)
+ print("uploading initrd to KernelCI")
+ upload_file(api, token, upload_path, initrd, initrd_filename)
+ print("uploaded to: https://storage.staging.kernelci.org"+upload_path)
Create script for deploy images to KernelCI file server using KernelCI api Signed-off-by: Alice Ferrazzi <alice.ferrazzi@miraclelinux.com> --- .gitlab-ci.yml | 4 +++- scripts/deploy-kernelci.py | 48 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) create mode 100755 scripts/deploy-kernelci.py