zoukankan      html  css  js  c++  java
  • jenkins回滚之groovy动态获取版本号

    grovvy调试:
    部署路径确定下来, 每个服务写死,传参 服务名 + 环境 给版本服务返回版本信息:
    
    groovy取分支:
    def gettags = ("git ls-remote -h git@gitlab.zi.com:crm/zi-crm-app.git").execute()
    gettags.text.readLines().collect { it.split()[1].replaceAll('refs/heads/', '')  }.unique()
    def gettags = ("ls -l").execute()
    gettags.text.readLines().collect { it.split()[1].replaceAll('refs/heads/', '')  }.unique()
    curl baidu.com
    String[] envVars = jenkins.model.Jenkins.getInstance().getGlobalNodeProperties().toMap().collectMany{it.value.getEnvVars().collect{"$it.key=$it.value"}}
    def jobName= manager.getEnvVariable('JOB_BASE_NAME')
    echo -e `curl -s -d "sname=zi-data-dr-test-bk&env=test" 0.0.0.0:8000/version/|tr """ " "`
    
    def gettags = ("curl -s -d "env=zi-data-dr-test-bk,test" 10.11.7.183:8000/version/").execute()
    gettags.text.readLines()
    
    def proc1 = ['/bin/bash', '-c', 'echo -e `curl -s -d "sname=zi-data-dr-test-bk&env=test" 10.11.7.183:8000/version/|tr """ " "`'].execute()
    
    def proc1 = ['/bin/bash', '-c', 'curl -s -d "sname=zi-data-dr-test-bk&env=test" 10.11.7.183:8000/version/'].execute()
    pproc1 = ['echo -e', $proc1].execute()
    def proc2 = ['/bin/bash', '-c', 'echo -e curl -s -d "env=zi-data-dr-test-bk,test" 10.11.7.183:8000/version/|tr """ " "'].execute()
    
    
    # def gettags = ['/bin/bash', '-c', 'curl -s -d "sname=zi-data-dr-test-bk&env=test" 10.11.7.183:8000/version/'].execute()
    # gettags.text.readLines()
    
    Script:
    if (BuildEnv.equals('test')) {
    return ['test']
    } else if (BuildEnv.equals('prod')) {
    return ['prod']
    } else {
    return ['abc']
    }
    Fallback Script: return ['xxx']
    
    def job_name = this.binding.jenkinsProject.name 这个可以获取到 
    
    
    def job_name = this.binding.jenkinsProject.name
    def job_env= this.binding.BuildEnv
    if (BuildEnv.equals('test')) {
    def gettags = ['/bin/bash', '-c', 'curl -s -d "sname=${job_name}&env=${job_env}" 10.11.7.183:8000/version/'].execute()
    return gettags.text.readLines()} 
    if (BuildEnv.equals('develop')) {
    return [job_name,job_env]
    }
  • 相关阅读:
    Spring Boot 3.日志
    Inspection info: Checks Spring Boot Application Setup. @SpringBootApplication used in default package Redundant @ComponentScan declaration Redundant @EnableAutoConfiguration declaration New in 2018.2
    mac下编译安装pcntl扩展
    php的if判断出现的问题思考
    php判断类的方法是否存在
    mac下phpstorm快捷键
    php关于always_populate_raw_post_data报错的解决方案
    如何使用mac快捷键打开终端
    linux文件权限管理(超详细)
    linux常用命令合集
  • 原文地址:https://www.cnblogs.com/yum777/p/11217157.html
Copyright © 2011-2022 走看看