Last active
May 7, 2020 10:51
-
-
Save noman404/9df67806c8f04c0f66eb82daa1fa1eb9 to your computer and use it in GitHub Desktop.
Shell script to upload file using CURL, can be used as 'Jenkins Build Step'. Supports only MULTIPART FORM-DATA POST request with additional params
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#./sh or sh >> upload-archive.sh FILE_PATH APP_ID VERSION_NAME BUILD_NUMBER BUILD_TYPE URL API_KEY | |
#!/bin/bash | |
#The Url form cli argument no 6 | |
URL=$6 | |
#Register and obtain an Api Key form appstore, passed from cli argument no 7 | |
api_key=$7 | |
#Special character to read file | |
file_special_character='@/' | |
#Additional params | |
file_path="${file_special_character}${1}" | |
app_id=$2 | |
build_name=$3 | |
build_number=$4 | |
build_type=$5 | |
#The request | |
STATUS_CODE=$(curl --location -s -o /dev/null -w '%{http_code}' --request POST $URL \ | |
--header "key: ${api_key}" \ | |
--form "appId=${app_id}" \ | |
--form "versionName=${build_name}" \ | |
--form "buildNumber=${build_number}" \ | |
--form "buildType=${build_type}" \ | |
--form "appFile=${file_path}") | |
echo $STATUS_CODE | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment