'GITLAB API post complex message to tag

i wanted to use the gitlab api to create a tag, but i have issues with a complex release message: following https://docs.gitlab.com/ee/api/tags.html#create-a-new-tag

i have the changelog as artifact like the following:

* FEATURE 1
* FEATURE 2

for sure the api expects urlencoded the message. i also tried to use a helper function, but sadly this was not able to urlencode the example i showed


urlencode() {
    # urlencode <string>
    local length="${#1}"
    for (( i = 0; i < length; i++ )); do
        local c="${1:i:1}"
        case $c in
            [a-zA-Z0-9.~_-]) printf "$c" ;;
            *) printf '%%%02X' "'$c" ;;
        esac
    done
}
CHANGELOGMSG=$(urlencode $(cat changelog.file))

    curl --silent --header "PRIVATE-TOKEN: XXXXX" -X POST "$gitlab.local/9/repository/tags?tag_name=test&ref=123&message=${CHANGELOGMSG}&private_token=XXX"


but sadly only Feature1 will be encoded Feature2 is missed.

so the question is, is there also a way to post as "Message" for the tag a file like a textfile or do i need another urlencode approach here?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source