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_pipeline.sh # 如果想要使用毕昇编译器的相关能力,请添加这条命令 # x86平台运行编译命令为:cd /path/to/repository、make,请在此运行与x86平台一致的编译命令 cd /path/to/repository make ''' } } } } stages{ stage('A-FOT') { agent { label 'kunpeng_c_builder_gcc' } steps{ # 安装部署完成后已有GCC for openEuler的环境,请先执行与x86平台一致的编译命令 sh 'a-fot --config_file a-fot.ini' } } } }
- 以命令参数优化(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_pipeline.sh # 如果想要使用毕昇编译器的相关能力,请添加这条命令 # x86平台运行编译命令为:cd /path/to/repository、make,请在此运行与x86平台一致的编译命令 cd /path/to/repository 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' } } } }
父主题: Jenkins流水线