授权

  1. #正则示例
  2. jws1.*
  3. IT-jws1(/merge(/.*)?)?
  4. IT-jws1(/register(/(merge.*|register-etcd))?)?

DSL相关

注意-新版本任务名称改变

  1. #Old version
  2. workflowJob(jobname){
  3. description('xxx')
  4. parameters {
  5. choiceParam('SPEED', ['0.5', '1.0', '1.5'], 'xxx')
  6. }
  7. }
  8. #New version 2.150.1
  9. pipelineJob(jobname){
  10. description('xxx')
  11. parameters {
  12. choiceParam('SPEED', ['0.5', '1.0', '1.5'], 'xxx')
  13. }
  14. }

Jenkins之Groovy个人示例

判断关联变量关系后返回
  1. #AssignDatabase return Yes or No
  2. import groovy.json.JsonSlurper
  3. if (AssignDatabase.contains('Yes')){
  4. def redis_ip = new URL("http://10.4.0.198:2379/v2/keys/SL210/210/6201/gm/redis").text
  5. "http://10.4.0.198:2379/v2/keys/SL210/210/6201/gm/redis"
  6. def slurper = new JsonSlurper()
  7. def result = slurper.parseText(redis_ip)
  8. return [result.node.value.split(':')[0]]
  9. }else{
  10. return ['Auto']
  11. }

对关联变量进行截取取值
  1. #ACID:210:6201:ad52a590-7db1-41e5-93e8-a25ae83ad275
  2. import groovy.json.JsonSlurper
  3. String gid = ACID.split(':')[0]
  4. String shardid = ACID.split(':')[1]
  5. etcd_url = 'http://10.4.0.198:2379' + 'v2/keys' + '/SL210/' + gid + '/' + shardid + '/gm/redis'
  6. def etcd_data = new URL(etcd_url).text
  7. def slurper = new JsonSlurper()
  8. def result = slurper.parseText(etcd_data)
  9. return etcd_url

权限控制相关

可以使用以下插件

  • role-based strategy
  • Folder Authorization Strategy
  1. #对于目录下的任务授权类似(参考https://issues.jenkins.io/browse/JENKINS-24767)或直接使用Folder这个插件
  2. scratch-parent(/scratch-child(/.*)?)?