0

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?

2
  • 1
    I'm assuming this is just a typo in your question and not in your code, but you're missing a closing ) in CHANGELOGMSG=$(urlencode $(cat changelog.file) 18 hours ago
  • @AdamMarshall thanks for the hint but that was Just an Copy Paste issue here, the main Problem here is still that the encoding the file with the changelog did not work out, i need the source with the commit Messages urlencoded because the API only Accept that
    – 178877
    11 hours ago

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.