CREATE DATABASE jenkins CREATE USER "jenkins" WITH PASSWORD 'root123' WITH ALL PRIVILEGES
安装influxdb插件、配置Influxdb信息。
try { //pipeline currentBuild.description = "构建成功" //定义Jenkins构建描述,默认无。 } catch(err){ currentBuild.description = "构建失败" //定义Jenkins构建描述,默认无。 throw err }finally{ step([$class: 'InfluxDbPublisher', customData: null, customDataMap: null, customPrefix: null, target: 'influxdb', // Jenkins中配置的Influxdb。 selectedTarget: 'influxdb', // Jenkins中配置的Influxdb。 //jenkinsEnvParameterTag: 'KEY=' + env.PARAM, // OPTIONAL,自定义tag jenkinsEnvParameterField: 'build_agent_name=' + 'master' + '\n' + 'build_status_message=' + currentBuild.description, // OPTIONAL, 自定义字段 measurementName: 'jenkins_data', // OPTIONAL, 表名称 replaceDashWithUnderscore: false, // OPTIONAL, 是否替换 "-"为 "_"。 ]) } //基于插件自定义字段名称(非完全自定义) /* step([$class: 'InfluxDbPublisher', customData: null, customDataMap: null, customPrefix: null, target: 'influxdb', selectedTarget: 'influxdb', jenkinsEnvParameterTag: 'project_name=' + "${JOB_NAME}".split('/')[-1] , // OPTIONAL, 自定义project_name jenkinsEnvParameterField: 'build_agent_name=' + 'master' + "\n" + //自定义参数列表,每个参数加上一个换行符 'build_status_message=' + currentBuild.description + "\n" + 'midwareType=' + "${midwareType}" + "\n" + 'listenPort=' + "${port}" + "\n" + 'runUser=' + "${user}" + "\n" + 'repoName=' + "${srcUrl}".split("/")[-1] - '.git' + '\n' + 'project_name=' + "${JOB_NAME}".split('/')[-1] + '\n' + 'deployHosts=' + "${targetHosts}" , measurementName: 'jenkins_data', replaceDashWithUnderscore: false, ]) */
查看Influxdb数据
> USE jenkins Using database jenkins > SHOW SERIES key --- jenkins_data,build_result=SUCCESS,project_name=cxy-influxdb-demo_PROD jenkins_data,build_result=SUCCESS,project_name=cxy-influxdb1-demo_PROD > select * from jenkins_data name: jenkins_data time build_agent_name build_exec_time build_measured_time build_number build_result build_result_1 build_result_ordinal build_scheduled_time build_status_message build_successful build_time deployHosts last_stable_build last_successful_build listenPort midwareType project_build_health project_name project_name_1 project_path repoName runUser ---- ---------------- --------------- ------------------- ------------ ------------ -------------- -------------------- -------------------- -------------------- ---------------- ---------- ----------- ----------------- --------------------- ---------- ----------- -------------------- ------------ -------------- ------------ -------- ------- 1559345943038000000 master 1559345921459 1559345943038 2132 SUCCESS SUCCESS 0 1559345921426 构建成功 true 21612 VM_7_14_centos 2131 2131 80 Nginx 100 cxy-influxdb-demo_PROD cxy-influxdb-demo_PROD cxy-influxdb-demo_PROD devops-tools-web nginx 1559345945612000000 master 1559345927303 1559345945612 2091 SUCCESS SUCCESS 0 1559345927254 构建成功 true 18358 VM_7_14_centos 2090 2090 80 Nginx 80 cxy-influxdb1-demo_PROD cxy-influxdb1-demo_PROD cxy-influxdb1-demo_PROD devops-tools-web nginx 1559345963040000000 master 1559345940685 1559345963040 2092 SUCCESS SUCCESS 0 1559345940669 构建成功 true 22371 VM_7_14_centos 2091 2091 80 Nginx 80 cxy-influxdb1-demo_PROD cxy-influxdb1-demo_PROD cxy-influxdb1-demo_PROD devops-tools-web nginx 1559345964061000000 master 1559345940689 1559345964061 2133 SUCCESS SUCCESS 0 1559345940686 构建成功 true 23375 VM_7_14_centos 2132 2132 80 Nginx 100 cxy-influxdb-demo_PROD cxy-influxdb-demo_PROD cxy-influxdb-demo_PROD devops-tools-web nginx
dashboard ->templating
效果图
参考资料:
本文分享自微信公众号 - DevOps持续集成(devopsadmin)
原文出处及转载信息见文内详细说明,如有侵权,请联系 yunjia_community@tencent.com 删除。
原始发表时间:2019-06-01
本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。
我来说两句