如何获取Nexus存储库的给定命名空间中的工件名称列表

问题描述 投票:0回答:1

我需要在nexus存储库中只获取给定命名空间下的工件名称。

上传的Nexus网址:http://nexus.it.test.com:8080/nexus/repository/rawcentral/com.test/

示例工件名称:release_dev_2018909.tar.gz

请帮我使用确切的shell命令获取所有工件名称的列表。 TIA

shell jenkins repository nexus
1个回答
0
投票

上面的脚本可以帮到你

#!/bin/bash

url="http://fileserver/service/rest/beta/search/assets?repository=maven-releases&name=dot-files"

artifact=( $(curl -s -X GET --header 'Accept: application/json' \
    "$url" | grep -Po '"downloadUrl" : ".*?[^\\]*.(zip.sha1|zip)",' | \
    awk -F '"' '{print $4}' | sort -Vr | head -n2) )

((${#artifact[@]})) || echo "ERROR! No artifacts found at provided url!"

for i in "${artifact[@]}"; do
    if [[ $i =~ (sha1) ]]; then
        checksum=$(curl -s "$i" | awk '{print $1}')
    else
        file="$(echo "$i" | awk -F "/" '{print $NF}')"
        curl -sO "$i" || { echo "ERROR: Download failed!"; exit 1; }

        if [ "$(sha1sum "$file" | awk '{print $1}')" != "$checksum" ]; then
            echo "ERROR: Checksum validation on $file failed!"; exit 1;
        else
            printf "Downloaded : %s\nChecksum   : %s\n" "$file" "$checksum"
        fi
    fi
done
#EOF
© www.soinside.com 2019 - 2024. All rights reserved.