11#! /bin/sh
22
33# Parse env variables
4- env_list =" "
5- if [ -n " $env " ]; then
6- # Convert Bitrise key-value format to -e KEY=VALUE format
7- while IFS=' | ' read -r key value || [ -n " $key " ] ; do
4+ env_list_parsed =" "
5+ if [ -n " $env_list " ]; then
6+ # Convert newline-separated key-value pairs to -e KEY=VALUE format
7+ while IFS=' = ' read -r key value; do
88 if [ -n " $key " ]; then
99 # Append each env var with -e prefix
10- env_list =" $env_list -e $key =$value "
10+ env_list_parsed =" $env_list_parsed -e $key =$value "
1111 fi
12- done <<< " $env "
12+ done <<< " $env_list "
1313fi
1414
1515# Refine variables
@@ -22,31 +22,30 @@ cd $BITRISE_SOURCE_DIR
2222EXIT_CODE=0
2323
2424# Log all variables for debugging
25- echo " Environment variables:"
26- echo " api_key: $api_key "
27- echo " api_url: $api_url "
28- echo " app_binary_id: $app_binary_id "
25+ echo " DCD variables:"
2926echo " additional_app_binary_ids: $additional_app_binary_ids "
3027echo " additional_app_files: $additional_app_files "
3128echo " android_api_level: $android_api_level "
3229echo " android_device: $android_device "
30+ echo " api_key: $api_key "
31+ echo " api_url: $api_url "
32+ echo " app_binary_id: $app_binary_id "
33+ echo " app_file: $app_file "
3334echo " async: $async "
3435echo " device_locale: $device_locale "
3536echo " download_artifacts: $download_artifacts "
37+ echo " env_list: $env_list "
3638echo " exclude_flows: $exclude_flows "
3739echo " exclude_tags: $exclude_tags "
3840echo " google_play: $google_play "
3941echo " include_tags: $include_tags "
40- echo " ios_version: $ios_version "
4142echo " ios_device: $ios_device "
43+ echo " ios_version: $ios_version "
44+ echo " is_async: $is_async "
4245echo " name: $name "
4346echo " orientation: $orientation "
4447echo " retry: $retry "
45- echo " env: $env "
46- echo " app_file: $app_file "
4748echo " workspace: $workspace "
48- echo " env_list: $env_list "
49- echo " is_async: $is_async "
5049
5150
5251echo " Running command: npx --yes @devicecloud.dev/dcd cloud --quiet \
@@ -69,7 +68,7 @@ ${ios_device:+--ios-device \"$ios_device\"} \
6968${name: +--name \" $name \" } \
7069${orientation: +--orientation \" $orientation \" } \
7170${retry: +--retry \" $retry \" } \
72- ${env : + $env } \
71+ ${env_list_parsed } \
7372\" $app_file \" \" $workspace \" "
7473
7574npx --yes @devicecloud.dev/dcd cloud --quiet \
@@ -92,9 +91,26 @@ ${ios_device:+--ios-device "$ios_device"} \
9291${name: +--name " $name " } \
9392${orientation: +--orientation " $orientation " } \
9493${retry: +--retry " $retry " } \
95- ${env : + $env } \
94+ ${env_list_parsed } \
9695" $app_file " " $workspace " || EXIT_CODE=$?
9796
98- # to do: handle download artifacts
97+ # Handle artifacts download
98+ if [ -n " $download_artifacts " ] && [ -f " artifacts.zip" ]; then
99+ case " $download_artifacts " in
100+ " ALL" |" FAILED" )
101+ echo " Extracting artifacts.zip (mode: $download_artifacts )..."
102+ unzip -o artifacts.zip -d " $BITRISE_DEPLOY_DIR "
103+ if [ $? -eq 0 ]; then
104+ echo " Artifacts successfully extracted to $BITRISE_DEPLOY_DIR "
105+ else
106+ echo " Warning: Failed to extract artifacts.zip"
107+ EXIT_CODE=1
108+ fi
109+ ;;
110+ * )
111+ echo " Warning: Invalid download_artifacts value: $download_artifacts . Expected 'ALL' or 'FAILED'"
112+ ;;
113+ esac
114+ fi
99115
100116exit $EXIT_CODE
0 commit comments