从 json 创建多个工件存储库

Create multiple artifactory repositories from json

我想通过 .json 文件自动执行从另一个 Artifactory 导入现有存储库结构的过程。 到目前为止,我已经成功地使用以下命令从 json 制作了单个回购。

curl -X PUT --insecure -u admin -H "Content-type: application/json" -T repository-config.json "https://artifactory.test.net/artifactory/api/repositories/acqbo-docker-release-local"

有没有办法从单个 json 文件和单个 curl 导入 multiple/array 个存储库?

最终为此编写了我自己的 bash 脚本。 您必须使用要复制的存储库创建一个文件:

#!/bin/bash

#############
# This script copies the repository structure from one Artifactory server to another
# repos.list file is required to have repositories that we want to copy, each in new line.
# user with the admin rights is necessary
#############


#Where to copy repos from and to
ARTIFACTORY_SOURCE="https://source.group.net/artifactory/api/repositories/"
ARTIFACTORY_DESTINATION="https://destination.group.net/artifactory/api/repositories/"

NOLINES=$(wc -l < repos.list)   #get total nuber of lines in repos.line
COUNTER=1                       #Set the counter to 1

while [ $COUNTER -le $NOLINES ] #loops times number of lines in the repos.line
do
        REPONAME=$(awk "NR==$COUNTER" repos.list) #get only repo name, line by line

        curl -GET --insecure -u admin:adminpass  "$ARTIFACTORY_SOURCE$REPONAME" > xrep.json  #Obtain data from Artifactory source, repo by repo, and writes it to the xrep.json
        curl -X PUT --insecure -u admin:adminpass -H "Content-type: application/json" -T xrep.json "$ARTIFACTORY_DESTINATION$REPONAME"   #Sends data from json to the destination Artifactory server

        #print in blue color
        printf "\e[1;34m$COUNTER repo done\n\e[0m"


    ((COUNTER++))
done
    printf "\e[1;34mAll repos exported!\n\e[0m"