随笔分类 -  Groovy

Groovy Urlencode编码
摘要:title=‘程序邮箱’ java.net.URLEncoder.encode(title, "UTF-8") //编码URLDecoder.decode("%C4%E3%BA%C3", "GBK") //解码 阅读全文
posted @ 2020-11-12 17:53 momingliu11 阅读(1531) 评论(0) 推荐(0) 编辑
Groovy获取对象类型、属性
摘要://获取对象类型: println pp.getClass() //获取对象属性: println pp.getProperties() 阅读全文
posted @ 2020-11-11 17:48 momingliu11 阅读(4979) 评论(0) 推荐(0) 编辑
Groovy调用MD5加密
摘要:import java.security.MessageDigest def today = new Date().format("yyyy-MM-dd") def snstr = ‘a=$a&b=$b&today=$today’ def sn = MessageDigest.getInstance 阅读全文
posted @ 2020-11-10 11:23 momingliu11 阅读(1838) 评论(0) 推荐(0) 编辑
Jenkins Pipeline调用 httpRequest插件提交Http请求
摘要:#!groovy def call(reqMode,url,reqBody){ //调用httpRequest插件 if(reqMode == 'POST'){ response = httpRequest customHeaders: [[name: 'Content-Type', value: 阅读全文
posted @ 2020-11-10 11:20 momingliu11 阅读(4837) 评论(0) 推荐(0) 编辑
Json String转换为Json Object
摘要:Json String转换为Json Object Pipeline中写法如下: ec2 = '{"first_name":"John","full_name":"John Doe","last_name":"Doe"}' println ec2.getClass() //Return: class 阅读全文
posted @ 2020-09-10 15:55 momingliu11 阅读(1570) 评论(0) 推荐(0) 编辑
Jenkins pipeline使用git共享库(ShareLibrary)
摘要:1.在Jenkins Server本地创建git库 mkdir /data/Jenkins2Library/SharedLibrary #vars目录托管定义可从Pipeline访问的全局脚本(一般我们可以在这里编写标准化脚本)。 我们在pipeline中调用的指令就是在这里定义的 mkdir /d 阅读全文
posted @ 2020-08-04 10:59 momingliu11 阅读(2216) 评论(0) 推荐(1) 编辑
Groovy Map排序
摘要:def m = [:] //定义空map def m = [a:6,b:20,c:1,d:22] def sorted = m.sort { a, b -> b.value <=> a.value } //降序排列 def sorted = m.sort { a, b -> a.value <=> 阅读全文
posted @ 2020-07-30 18:43 momingliu11 阅读(1004) 评论(0) 推荐(0) 编辑
Jenkins Pipeline使用File parameter
摘要:Jenkins Pipeline使用File parameter,将文件通过publish over cifs上传到Windows Share. Jenkins Pipeline直接使用File parameter,无法将文件上传到当前job的workspace下面,需要通过调用第三方jenkins 阅读全文
posted @ 2020-07-27 15:57 momingliu11 阅读(7646) 评论(0) 推荐(0) 编辑
Jenkins Active Parameters之Groovy Script(获取具有管理员权限的组+组成员)
摘要:1.添加Active Choices Parameter参数GroupList,Groovy Script内容如下: import hudson.model.User def cuser=User.current().getId() //获取当前登录用户id def obj_groups = """ 阅读全文
posted @ 2020-07-22 15:53 momingliu11 阅读(1448) 评论(0) 推荐(0) 编辑
Jenkins Extended choice parameter和Active Choices param 之Groovy Script使用
摘要:Groovy Script调用python脚本返回值,方法如下: 添加Extended Choice Parameter参数 pp01,逗号分隔,items数量可多不可少: 1.编写Python脚本test.py,内容如下: #!/usr/bin/env python3 #coding=utf-8 阅读全文
posted @ 2020-07-22 11:26 momingliu11 阅读(3969) 评论(1) 推荐(0) 编辑


点击右上角即可分享
微信分享提示