博客
关于我
jenkins使用pipeline获取当前构建任务的构建人
阅读量:420 次
发布时间:2019-03-06

本文共 881 字,大约阅读时间需要 2 分钟。

pipeline中的全局变量,默认是不支持获取当前构建任务的构建人的,要想获取构建人的信息,只能通过插件来帮助我们获取

插件:build-user-vars-plugin

插件下载地址:https://github.com/jenkinsci/build-user-vars-plugin

下载插件的源码

wget https://github.com/jenkinsci/build-user-vars-plugin/archive/build-user-vars-plugin-1.5.zip

打包构建

进入到解压后的插件目录中

执行mvn打包命令

mvn install

打包完成后,会生成一个target目录,目录中会生成一个build-user-vars-plugin.hpi文件,然后拿到这个.hpi结尾的文件后,jenkins上手动上传插件即可

结合pipeline

声明式语法的写法

pipeline {    agent any    stages {        stage('test') {            steps {                wrap([$class: 'BuildUser']) {                    BUILD_USER = "${env.BUILD_USER}"                             }            }        }    }}

脚本式语法

node {    stage {            wrap([$class: 'BuildUser']) {                script {                    BUILD_USER = "${env.BUILD_USER}"                }                            }            }}

下面是我的微信公众号,有兴趣的可以关注一波哦,基本上每天都会分享一些技术类或者其他领域的文章哦

转载地址:http://cmyuz.baihongyu.com/

你可能感兴趣的文章
nginx异常:the “ssl“ parameter requires ngx_http_ssl_module in /usr/local/nginx/conf
查看>>
nginx总结及使用Docker创建nginx教程
查看>>
nginx报错:the “ssl“ parameter requires ngx_http_ssl_module in /usr/local/nginx/conf/nginx.conf:128
查看>>
nginx报错:the “ssl“ parameter requires ngx_http_ssl_module in usrlocalnginxconfnginx.conf128
查看>>
nginx日志分割并定期删除
查看>>
Nginx日志分析系统---ElasticStack(ELK)工作笔记001
查看>>
Nginx映射本地json文件,配置解决浏览器跨域问题,提供前端get请求模拟数据
查看>>
nginx最最最详细教程来了
查看>>
Nginx服务器---正向代理
查看>>
Nginx服务器上安装SSL证书
查看>>
Nginx服务器基本配置
查看>>
Nginx服务器的安装
查看>>
Nginx标准配置文件(包括反向代理、大文件上传、Https证书配置、文件预览等)
查看>>
Nginx模块 ngx_http_limit_conn_module 限制连接数
查看>>
Nginx模块 ngx_http_limit_req_module 限制请求速率
查看>>
nginx添加模块与https支持
查看>>
nginx状态监控
查看>>
Nginx用户认证
查看>>
Nginx的location匹配规则的关键问题详解
查看>>
Nginx的Rewrite正则表达式,匹配非某单词
查看>>