Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save noman404/9df67806c8f04c0f66eb82daa1fa1eb9 to your computer and use it in GitHub Desktop.
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
#./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