Jenkins流水线代码示例
提供扫描、编译、测试、调优相关能力的Jenkins流水线代码示例。
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('PARALLEL BUILD') { parallel { stage('Kunpeng') { agent { label 'kunpeng_scanner' } stages{ stage('source-code-migration') { steps { echo '====== 源码迁移 ======' sh ''' /usr/bin/rm -rf ./*.html devkit porting src-mig -i ./wtdbg2 -c make -r html mv ./src-mig*.html ./SourceCodeScanningReport.html ''' } post { always { publishHTML(target: [allowMissing: false, alwaysLinkToLastBuild: false, keepAll : true, reportDir : '.', reportFiles : 'SourceCodeScanningReport.html', reportName : 'Source Code Scanning Report'] ) } } } stage('vectorized-check') { steps { echo '====== 向量化检查 ======' sh ''' /usr/bin/rm -rf ./*.html devkit advisor vec-check -i ../src/test-gllvm -f ../src/test-gllvm -c make -r html mv ./vec-check*.html ./vectorized-check.html ''' } post { always { publishHTML(target: [allowMissing: false, alwaysLinkToLastBuild: false, keepAll : true, reportDir : '.', reportFiles : 'vectorized-check.html', reportName : 'vectorized-check Report'] ) } } } stages{ stage('A-FOT') { agent { label 'kunpeng_c_cpp_builder' } steps{ // 安装部署完成后已有GCC for openEuler的环境,请先执行与x86平台一致的编译命令 cd /xxx/lkp-test make sh 'a-fot --config_file a-fot.ini' } } } stage('bulid') { steps { script{ echo '====== build ======' sh ''' source ${HOME}/.local/wrap-bin/devkit_pipeline.sh // 如果想要使用毕昇编译器的相关能力,请添加这条命令 cd /xxx/lkp-test make // x86平台运行编译命令为:cd /xxx/lkp-test、make,请在此运行与x86平台致的编译命令 ''' sh ''' CURDIR=$(pwd) cp -rf /xxx/compatibility_testing/template.html.bak /xxx/compatibility_testing/template.html sudo lkp run /xxx/lkp-tests/programs/compatibility-test/compatibility-test-defaults.yaml cp -rf /xxx/test/compatibility_testing/compatibility_report.html $CURDIR ''' sh(script: "sudo bash /xxx/compatibility_testing/report_result.sh", returnStdout:true).trim() // 这个是用于判断lkp 命令后生成的结果是否符合预期,需要根据不同的run脚本生成的结果文件去做不同的结果判断结果 } } post { always { publishHTML(target: [allowMissing: false, alwaysLinkToLastBuild: false, keepAll : true, reportDir : '.', reportFiles : 'compatibility_report.html', reportName : 'compatibility test Report'] ) } } } stages{ stage('freshclam') { agent { label 'kunpeng_executor' } steps{ sh 'freshclam' } } stage('clamscan') { agent { label 'kunpeng_executor' } steps{ sh 'clamscan -i -r /home -l ~/clamscan.log' } } } } } } } } }
父主题: 代码示例