0

Artifactory ファイル情報を含む csv ファイルを完成させる必要がありますが、生成しようとするとフォーマットに問題があります。

csv で待機中のフォーマット: ここに画像の説明を入力

不正な形式で生成された形式: ここに画像の説明を入力

そのために、各コンポーネントの Artifactory でフォルダー内のファイル リストを取得し、それぞれのすべてのチェックサムを取得します。

function getArtifactoryMavenInfo {
    completPath="$1$commandeAsk"
    
    # get all files in one Artifactory folder => this is OK
    list_MAVEN_files=($(curl -H "Content-Type: text/plain" -u XXX:XXX -X GET "$completPath" | jq ".files" | sed -n -e '/^.*\"uri\"\: \"/p' | sed 's/^.*\"uri\"\: \"\///' | sed 's/".*$//'))

    # all_checksum will have all files with there checksums
    all_checksum=""
    for (( f=0; f<${#list_MAVEN_files[@]}; f++ )); do
        filePath="$1/${list_MAVEN_files[f]}"
        # all checksums have the good format => this is ok
        checksums_MAVEN_sha1=($(curl "$filePath" | jq ".checksums.sha1" | sed 's/"//' | sed 's/"$//'))
        checksums_MAVEN_md5=($(curl "$filePath" | jq ".checksums.md5" | sed 's/"//' | sed 's/"$//'))
        checksums_MAVEN_sha256=($(curl "$filePath" | jq ".checksums.sha256" | sed 's/"//' | sed 's/"$//'))
        # Trying to create an array with all files and there checksums => this is not sure ...
        all_checksum+=$(echo "${list_MAVEN_files[f]} : sha1=${checksums_MAVEN_sha1} / md5=${checksums_MAVEN_md5} / sha256=${checksums_MAVEN_sha256}")
    done
    
    # put the previous array on a list => it will be the third column in the csv
    finalListArtifactorySHA+=($(echo "$all_checksum"))
    # put the path of the folder on a list => it will be for example the first column
    finalListArtifactoryPath+=($(echo "$1/"))
}

これで、必要な情報はすべて揃いました。次に、そのすべてをcsvファイルに入れようとします:

echo "Component name;Component version;Artifacts checksums;Artifactory path;Repo path" > $CSV_FILE_NAME
for (( i=0; i<${#finalListComponentName[@]}; i++ )); do
    echo "${finalListComponentName[i]};${finalListComponentVersion[i]};${finalListArtifactorySHA[i]};${finalListArtifactoryPath[i]};${finalListRepoPath[i]}" >> $CSV_FILE_NAME
done

手伝ってくれませんか?多くの変更を試み、すべてのフォーラムをチェックしましたが、csv 出力で必要な結果が得られませんでした。

ご助力ありがとうございます !!!

4

1 に答える 1