编程知识 cdmana.com

The command line gets the tag of the image in the alicloud image warehouse

Get the image in the alicloud image warehouse tag

 

One 、 Install alicloud linux Client tools

Select download address of official website

1
2
3
4
5
# 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

  

Two 、 Use RAM Carry out sub account authority management

establish RAM Sub account number , And authorize the sub account , Record the account number AccessKey ID Etc

Permission to name
AliyunContainerRegistryFullAccess
AliyunContainerRegistryReadOnlyAccess

 

3、 ... and 、 Configure client tools

1
2
3
4
5
6
7
8
# 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 Sub account ID

  • Access Secret:RAM Sub account Secret

  • Region ID: Location of image warehouse in alicloud account ( This side is cn-hangzhou)

  • Language:zh

Four 、 Get image information

1
2
3
4
5
6
7
8
9
10
11
12
# aliyun cr GetRepoTags --help
Alibaba cloud CLI Command line tools 3.0.64
Product:     cr ( Container image service )
Method:      GET
PathPattern:  /repos/ [RepoNamespace]/[RepoName] /tags
Parameters:
   --RepoName      String  Required
   --RepoNamespace String  Required
   --Page          Integer Optional
   --PageSize      Integer Optional

  

  • Use --help See how to use ,cr Serving container mirroring

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# 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: The namespace in alicloud container image service

  • --RepoName: Name of image warehouse in alicloud container image service

     

Get only tag, It needs to be installed in advance jq command

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

  

If there are multiple mirrors , All images will be displayed , Can be in jenkins Select the image version number to publish as a parameter in

版权声明
本文为[KSA, the little monster beside the peach blossom tree]所创,转载请带上原文链接,感谢
https://cdmana.com/2020/12/20201225111125403e.html

Scroll to Top