diff --git a/.oebuild/workflows/jenkinsfile_nativesdk_release b/.oebuild/workflows/jenkinsfile_nativesdk_release index 0bc518884d8f88ab23bdf96d03b28b2fc621bc15..7c9ebfff26a656181fcdb986a5ef3785bd292438 100644 --- a/.oebuild/workflows/jenkinsfile_nativesdk_release +++ b/.oebuild/workflows/jenkinsfile_nativesdk_release @@ -23,6 +23,47 @@ def createReleaseAndUploadFile(String yaml_path, String file_dir, gitee_token){ """ } +def translateCompileToHost(String yocto_dir, + String arch, + String image_name){ + def read_image_yaml = "${yocto_dir}/.oebuild/samples/${arch}/${image_name}.yaml" + def samples_dir = "/home/jenkins/agent/samples/${arch}" + sh "mkdir -p ${samples_dir}" + def write_image_yaml = "${samples_dir}/${image_name}.yaml" + def code = """ +import subprocess +try: + from ruamel.yaml import YAML +except ModuleNotFoundError: + subprocess.call(args="pip install ruamel.yaml -i https://pypi.tuna.tsinghua.edu.cn/simple", + stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL, + shell=True) + from ruamel.yaml import YAML + +with open("$read_image_yaml", "r", encoding="utf-8") as file: + yaml = YAML() + data = yaml.load(file.read()) + +data["build_in"] = "host" +data["local_conf"] += '\\nINHERIT += "rm_work"' + +with open("$write_image_yaml", "w", encoding="utf-8") as file: + yaml = YAML() + yaml.dump(data, file) +""" + def file_name = getRandomStr() + writeFile file: file_name, text: code, encoding: "UTF-8" + sh "python3 ${file_name}" + return write_image_yaml +} + +def getRandomStr(){ + return sh(script: """ + cat /proc/sys/kernel/random/uuid + """, returnStdout: true).trim() +} + pipeline { agent { node "${node}" } environment { @@ -74,12 +115,17 @@ pipeline { steps{ dir("/home/jenkins/agent"){ script{ - // 构建sdk + def yocto_dir = "/home/jenkins/agent/yocto-meta-openeuler" + def arch = "x86-64" + def image_name = "prebuilt_tool" + def compile_path = translateCompileToHost(yocto_dir, arch, image_name) + // prepare oebuild build environment sh """ - oebuild init workspace - cd workspace/src - ln -s /home/jenkins/agent/yocto-meta-openeuler yocto-meta-openeuler - oebuild generate -t /usr1/openeuler/gcc/openeuler_gcc_arm64le -n /opt/buildtools/nativesdk -b_in host -d nativesdk -sdk + oebuild init oebuild_workspace + cd oebuild_workspace + mkdir -p build + ln -sf /home/jenkins/agent/yocto-meta-openeuler src/yocto-meta-openeuler + oebuild ${compile_path} """ } } @@ -100,8 +146,8 @@ pipeline { dir('/home/jenkins/agent/embedded-ci'){ script{ withCredentials([string(credentialsId: "${giteeId}", variable: 'GITEETOKEN')]){ - sdkYamlPath = "/home/jenkins/agent/yocto-meta-openeuler/.oebuild/nativesdk/release.yaml" - fileDir = "/home/jenkins/agent/workspace/build/nativesdk/tmp/deploy/sdk" + sdkYamlPath = "/home/jenkins/agent/yocto-meta-openeuler/.oebuild/prebuilt_tool/release.yaml" + fileDir = "/home/jenkins/agent/oebuild_workspace/build/prebuilt_tool/tmp/deploy/sdk" createReleaseAndUploadFile(sdkYamlPath, fileDir, "$GITEETOKEN") } }