Jenkins流水线编译代码示例
若需要使用毕昇编译器或GCC for openEuler相关能力,请使用以下代码示例。
A-FOT(配置文件参数优化)
pipeline { agent any options { timeout(time: 1, unit: 'HOURS') } parameters { string(name: 'GIT_URL', defaultValue: 'https://github.com/ruanjue/wtdbg2.git', description: '--> git url <--') string(name: 'GIT_BRANCH', defaultValue: 'v2.5', description: '--> code branch <--') string(name: 'GIT_TARGET_DIR_NAME', defaultValue: 'wtdbg2', description: '--> code branch <--') } stages{ stage('Git Code') { agent { label 'kunpeng_scanner' } steps { echo '====== 获取源码 ======' checkout scmGit(branches: [[name: "${params.GIT_BRANCH}"]], browser: github("${params.GIT_URL}"), extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: "${params.GIT_TARGET_DIR_NAME}"], cleanBeforeCheckout(deleteUntrackedNestedRepositories: true)], userRemoteConfigs: [[url: "${params.GIT_URL}"]]) } } stage('build') { agent { # 如果想要使用毕昇编译器的相关能力,label请指定为kunpeng_c_builder_bisheng_compiler label 'kunpeng_c_builder_gcc' } steps { script{ sh ''' source ${HOME}/.local/wrap-bin/devkit_NonInvasiveSwitching.sh cd /home/test/build make ''' } } } } stages{ stage('A-FOT') { agent { label 'kunpeng_c_builder_gcc' } steps{ # 安装部署完成后已有GCC for openEuler的环境,编译命令与其他平台保持一致。 #################################### # 此处替换为用户实际场景的编译命令 # #################################### sh 'a-fot --config_file a-fot.ini' } } } }

“/home/test/build”指项目文件路径,编译命令为make,请根据实际情况进行替换。
A-FOT(命令行参数优化)
pipeline { agent any options { timeout(time: 1, unit: 'HOURS') } parameters { string(name: 'GIT_URL', defaultValue: 'https://github.com/ruanjue/wtdbg2.git', description: '--> git url <--') string(name: 'GIT_BRANCH', defaultValue: 'v2.5', description: '--> code branch <--') string(name: 'GIT_TARGET_DIR_NAME', defaultValue: 'wtdbg2', description: '--> code branch <--') } stages{ stage('Git Code') { steps { echo '====== 获取源码 ======' checkout scmGit(branches: [[name: "${params.GIT_BRANCH}"]], browser: github("${params.GIT_URL}"), extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: "${params.GIT_TARGET_DIR_NAME}"], cleanBeforeCheckout(deleteUntrackedNestedRepositories: true)], userRemoteConfigs: [[url: "${params.GIT_URL}"]]) } } stage('build') { agent { # 如果想要使用毕昇编译器的相关能力,label请指定为kunpeng_c_builder_bisheng_compiler label 'kunpeng_c_builder_gcc' } steps { script{ sh ''' source ${HOME}/.local/wrap-bin/devkit_NonInvasiveSwitching.sh cd /home/test/build make ''' } } } } stages{ stage('A-FOT') { agent { label 'kunpeng_c_builder_gcc' } steps{ sh 'a-fot --opt_mode AutoFDO --gcc_path /usr --run_script /root/run.sh --build_script /root/build.sh --build_mode Wrapper --work_path ./ --bin_file /tmp/test' } } } }

“/home/test/build”指项目文件路径,编译命令为make,请根据实际情况进行替换。
父主题: 编译&调优