首页 > 其他分享 >jenkins 发版获取镜像仓库中tag

jenkins 发版获取镜像仓库中tag

时间:2022-11-08 17:02:45浏览次数:57  
标签:tags -- json tag aliyun jenkins 发版 RepoNamespace def

一、安装阿里云linux客户端工具

选择官网下载地址

# wget wget https://aliyuncli.alicdn.com/aliyun-cli-linux-latest-amd64.tgz

# tar -xf aliyun-cli-linux-latest-amd64.tgz

# cp aliyun /usr/local/bin

二、使用RAM进行子账号权限管理

创建RAM子账号,并对该子账号授权,记录账号的AccessKey ID等信息

权限名称
AliyunContainerRegistryFullAccess
AliyunContainerRegistryReadOnlyAccess

三、配置客户端工具

# aliyun configure
Configuring profile 'default' in 'AK' authenticate mode...
Access Key Id [*********************kCg]:
Access Key Secret [***************************2w7]:
Default Region Id [cn-hangzhou]:
Default Output Format [json]: json (Only support json)
Default Language [zh|en] zh:
Saving profile[default] ...Done.
  • Access ID:RAM子账号的ID

  • Access Secret:RAM子账号的Secret

  • Region ID:阿里云账号中镜像仓库的区位(这边是cn-hangzhou)

  • Language:zh

四、获取镜像信息

aliyun cr GetRepoTags --help
阿里云CLI命令行工具 3.0.64

Product:     cr (容器镜像服务)
Method:      GET
PathPattern: /repos/[RepoNamespace]/[RepoName]/tags

Parameters:
  --RepoName      String  Required
  --RepoNamespace String  Required
  --Page          Integer Optional
  --PageSize      Integer Optional
  • 使用--help 查看使用方法,cr为容器镜像服务
# aliyun cr GetRepoTags --RepoNamespace xxxx --RepoName xxxxxxx
{
    "data": {
        "page": 1,
        "pageSize": 30,
        "tags": [
            {
                "digest": "c06e0fe7ca4759dc15c517007a21465cfce16cc35ac3f83058c306880f804ea9",
                "imageCreate": 1606813621000,
                "imageId": "878046fe77276fe5ff5883537a5435734c9d21a953b271534df8d01f4da14e1e",
                "imageSize": 154166831,
                "imageUpdate": 1606813621000,
                "status": "NORMAL",
                "tag": "1.0.2"
            }
        ],
        "total": 1
    }
}

  • --RepoNamespace:阿里云容器镜像服务中的命名空间

  • --RepoName:阿里云容器镜像服务中的镜像仓库名称

只获取tag,需要提前安装jq命令

# aliyun cr GetRepoTags --RepoNamespace xxxx --RepoName xxxxxxxxx | jq ".data.tags[].tag"
"1.0.2"

五、Jenkins配置

import groovy.json.JsonSlurperClassic

def cmd = "/var/jenkins_home/aliyun cr GetRepoListByNamespace   --RepoNamespace  payfun --PageSize  100"
def aliyun_images_json = cmd.execute()

// Parse JSON into Groovy object
def data = new JsonSlurperClassic().parseText(aliyun_images_json.text)

// Prepare the results list
def aliyun_images = [];

// Add all tags
data.data.repos.each { aliyun_images.push(it.repoName) }


return aliyun_images

image.png

import groovy.json.JsonSlurperClassic

def cmd1 = "/var/jenkins_home/aliyun cr  GetRepoTags  --RepoNamespace  payfun --RepoName  " +  project
def aliyun_tags_json = cmd1.execute()

// Parse JSON into Groovy object
def data1 = new JsonSlurperClassic().parseText(aliyun_tags_json.text)

// Prepare the results list
def aliyun_tags = [];

// Add all tags
data1.data.tags.each { aliyun_tags.push(it.tag) }


return aliyun_tags

image.png

import groovy.json.JsonSlurperClassic

def cmd1 = "/var/jenkins_home/aliyun cr  GetRepoTags  --RepoNamespace  xxxx --RepoName  " +  'aiotjp-data'
def aliyun_tags_json = cmd1.execute()

// Parse JSON into Groovy object
def data1 = new JsonSlurperClassic().parseText(aliyun_tags_json.text)

// Prepare the results list
def aliyun_tags = [];

// Add all tags
data1.data.tags.each { aliyun_tags.push(it.tag) }


return aliyun_tags

image.png
image.png

标签:tags,--,json,tag,aliyun,jenkins,发版,RepoNamespace,def
From: https://www.cnblogs.com/dagongzhe/p/16870267.html

相关文章

  • docker 安装jenkins
    1.dockerpulljenkins/jenkins 2.创建Jenkins挂载目录并授权权限(我们在服务器上先创建一个jenkins工作目录/var/jenkins_mount,赋予相应权限,稍后我们将jenkins容器目录......
  • 前端快应用发版流程
    1,首先确定拉取的分支环境是否正确(正式环境:xiang52.com测试环境:tiandizw2.com) 2,快应用开发工具进行打包(打包完会在dist文件夹生成rpk包) 3,在代码manifest.json配......
  • 在WPF中用DataGrid实现表格样式
    资源文件定义颜色及样式<SolidColorBrushx:Key="TextColorGeneral"Color="#a2a2a2"/><StyleTargetType="DataGridColumnHeader"><SetterProperty="Horizon......
  • 使用插件实现Jenkins参数化构建
     一、插件安装1、打开插件管理,在此界面可以安装插件 二、参数化1、在“可选插件”中查找如下两个插件然后安装,安装后重启JenkinsBuildWithParameters输入框式的参数Per......
  • Jenkins安装和自动化部署
    1、Jenkins安装机器安装要求可以参考官网https://www.jenkins.io  2、下载jenkins的war包上传到linux上部署    3、安装jdk、git、maven3.1、安装jdk......
  • DataGear 自定义数据可视化图表
    DataGear内置了很多常用的图表(折线图、柱状图、饼图、散点图、雷达图、地图等等),能满足大部分数据可视化需求,当内置图表无法满足时,则可以通过自定义图表或插件的方式,实现特......
  • Jenkins Pipeline SSH Publisher 环境变量、参数引用 要用双引号
    JenkinsPipelineSSHPublisher环境变量、参数引用 要用双引号在Pipeline 脚本中,如果要使用变量,就必须使用“ 双引号pipeline{agentanyenvironment......
  • 我把分布式音乐播放器适配了Stage模型
     OpenAtomOpenHarmony(以下简称“OpenHarmony”)应用开发自API8及其更早版本一直使用的是FA模型进行开发。FA模型是FeatureAbility的缩写,它和PA(ParticleAbility)两种类型......
  • Jenkins-推送镜像到阿里云仓库或者本地镜像库
    申请及开通阿里云镜像服务账户不再赘述,直接讲jenkins配置部分。aliyun配置这个变量,ALIYUN_REGISTRY=credentials('aliyun-registry-account')使用时,用ALIYUN_REGISTRY_......
  • 最新版Jenkins(jdk11)-----JAVA项目使用低版本jdk编译的解决办法
    背景开源Devops工具Jenkins宣布:从6月28日发布的Jenkins2.357和即将发布的9月LTS版本开始,Jenkins最低需要Java11。所以,你懂得,很坑,项目只是jdk1.8解决......