首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何从Nexus迁移到JFrog Artifactory?

如何从Nexus迁移到JFrog Artifactory?
EN

Stack Overflow用户
提问于 2021-10-14 11:27:17
回答 1查看 712关注 0票数 1

我有两台服务器,一台带有Nexus,另一台带有JFrog Artifactory。

我想迁移到JFrog Artifactory,但是因为它是开源的,所以没有工具可以迁移。如果是专业版的话,我可以很容易地迁移。

我需要一些关于如何从Nexus迁移到JFrog Artifactory的一些想法。

EN

回答 1

Stack Overflow用户

发布于 2022-08-04 19:06:23

我完成这一任务的方式是:

  1. 从Nexus手动下载repos。对于nexus2,您可以直接从文件系统复制repos。对于nexus3,您需要使用API。对于nexus3,我使用了下面的脚本,

  1. ,Zip,repos到文件夹中,
  2. ,用导入工具将压缩的文件上传到工件。转到管理面板,工件,导入,存储库.

你应该多多少少从那里出发。我必须手动设置一些权限和快照设置。

警告!此脚本不能100%工作,您可能/必须修改它。警告!

代码语言:javascript
复制
sourceServer=
sourceRepo=
sourceUser=
sourcePassword=
logfile=$sourceRepo-backup.log
outputFile=$sourceRepo-artifacts.txt

# ======== GET DOWNLOAD URLs =========
url=$sourceServer"/service/rest/v1/assets?repository="$sourceRepo
contToken="initial"
while [ ! -z "$contToken" ]; do
    if [ "$contToken" != "initial" ]; then
        url=$sourceServer"/service/rest/v1/assets?continuationToken="$contToken"&repository="$sourceRepo
    fi
    echo Processing repository token: $contToken | tee -a $logfile
    response=`curl -ksSL -u "$sourceUser:$sourcePassword" -X GET --header 'Accept: application/json' "$url"`
    readarray -t artifacts < <( jq  '[.items[].downloadUrl]' <<< "$response" )
    printf "%s\n" "${artifacts[@]}" > artifacts.temp
    sed 's/\"//g' artifacts.temp > artifacts1.temp
    sed 's/,//g' artifacts1.temp > artifacts.temp
    sed 's/[][]//g' artifacts.temp > artifacts1.temp
    cat artifacts1.temp >> $outputFile
#for filter in "${filters[@]}"; do
     #   cat artifacts.temp | grep "$filter" >> $outputFile
    #done
    #cat maven-public-artifacts.txt
    contToken=( $(echo $response | sed -n 's|.*"continuationToken" : "\([^"]*\)".*|\1|p') )
done


# ======== DOWNLOAD EVERYTHING =========
    echo Downloading artifacts...
    urls=($(cat $outputFile)) > /dev/null 2>&1
    for url in "${urls[@]}"; do
        path=${url#http://*:*/*/*/}
        dir=$sourceRepo"/"${path%/*}
        mkdir -p  $dir
        cd $dir
        pwd
        curl -vks -u "$sourceUser:$sourcePassword" -D response.header -X GET "$url" -O  >> /dev/null 2>&1
        responseCode=`cat response.header | sed -n '1p' | cut -d' ' -f2`
        if [ "$responseCode" == "200" ]; then
            echo Successfully downloaded artifact: $url
        else
            echo ERROR: Failed to download artifact: $url  with error code: $responseCode
        fi
        rm response.header > /dev/null 2>&1
        cd $curFolder
    done
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69569892

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档