Skip to content

Commit 549aac4

Browse files
fix: use correct input for org in folder request (#19)
Use correct name for the UiPath organization used when requesting folder id to use when constructing test execution links. Improve logging and error handling on failed API requests.
1 parent 83f2594 commit 549aac4

1 file changed

Lines changed: 23 additions & 8 deletions

File tree

action.yml

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,10 @@ runs:
5858
body="grant_type=client_credentials&client_id=$clientId&client_secret=$clientSecret&scope=$scope"
5959
authResponse=$(curl -s -X POST "$orchestratorURL/identity_/connect/token" -H "${headers[@]}" -d "$body")
6060
accessToken=$(echo "$authResponse" | jq -r '.access_token')
61+
echo "::add-mask::$accessToken"
62+
echo Authentication response: "$authResponse"
6163
62-
if [ "$accessToken" == "null" ]; then
64+
if [ -z "$accessToken" ] || [ "$accessToken" == "null" ]; then
6365
echo "Error: Failed to obtain access token. Response: $authResponse"
6466
exit 1
6567
fi
@@ -70,12 +72,25 @@ runs:
7072
encodedParameters=$(jq -rn --arg params "$parameters" '$params | @uri')
7173
echo $encodedParameters
7274
73-
folderRequestURL="$orchestratorURL/${{ inputs.organizationId }}/${{ inputs.orchestratorTenant }}/orchestrator_/odata/folders?$encodedParameters"
74-
folderRequestHeaders=("Authorization: Bearer ${{ steps.get-orchestrator-token.outputs.accessToken }}")
75+
folderRequestURL="$orchestratorURL/${{ inputs.orchestratorLogicalName }}/${{ inputs.orchestratorTenant }}/orchestrator_/odata/folders?$encodedParameters"
76+
echo "Requesting folder ID from URL: $folderRequestURL"
77+
folderRequestHeaders=("Authorization: Bearer $accessToken")
7578
76-
# Get folder ID
77-
folderRequestResponse=$(curl -s -X GET "$folderRequestURL" -H "${folderRequestHeaders[@]}")
78-
folderId=$(echo "$folderRequestResponse" | jq -r '.value[0].Id')
79+
# Make the request and capture the response and status code
80+
httpStatus=$(curl -s -o response_body.txt -w "%{http_code}" -X GET "$folderRequestURL" -H "${folderRequestHeaders[@]}")
81+
responseBody=$(cat response_body.txt)
82+
83+
# Log the response and status code
84+
echo "HTTP Status: $httpStatus"
85+
echo "Response Body: $responseBody"
86+
87+
# Check if the status code is not 200
88+
if [ "$httpStatus" -ne 200 ]; then
89+
echo "Warning: Request failed with status code $httpStatus. Response: $responseBody"
90+
exit 1
91+
fi
92+
93+
folderId=$(echo "$responseBody" | jq -r '.value[0].Id')
7994
echo "folderId=$folderId" >> $GITHUB_OUTPUT
8095
8196
- id: run_tests
@@ -191,5 +206,5 @@ runs:
191206
192207
echo -e "$testResults" >> $GITHUB_STEP_SUMMARY
193208
194-
echo "${{ steps.run_tests.outputs.testExecutionLinks }}"
195-
echo "${{ steps.run_tests.outputs.testResults }}"
209+
echo "$testExecutionLinks"
210+
echo "$testResults"

0 commit comments

Comments
 (0)