Skip to content

Jira:Avatars:Collect Avatars

lbonanomi edited this page Jun 18, 2020 · 1 revision

Collect user avatars from https://source.jira.host to be served from https://target.jira.host by intravatar

#!/usr/bin/bash

USER=$1

curl -nsk "https://target.jira.host/rest/api/2/user?username=$USER" | jq .avatarUrls | grep 48 | grep -q jira.stg && (
        # Get old avatar
        FILE=$(curl -nsk "https://source.jira.host/rest/api/2/user?username=$USER" | jq ."emailAddress" | tr -d '"' | tr -d "\n" | md5sum - | awk '{ print $1 }')
        URL=$(curl -nsk "https://source.jira.host/rest/api/2/user?username=$USER" | jq .avatarUrls | grep 48 | awk -F"\"" '{ print $4 }')

        echo "$URL" | grep gravatar && (
                curl -nsk $URL > avatars/$FILE
        )

        echo "$URL" | grep gravatar || (
                curl -nsk $URL > avatars/$FILE
        )
)
Clone this wiki locally