Skip to content

Commit 8cfd805

Browse files
author
Philip Skinner
committed
CCM-981
Periodically this step in the pipeline will fail - this requires APIM producers to have to press the retry button in order to get a successful build. The manual retry process is normally successful after only 1 retry. The error thrown here is a 401 - this makes me believe that token created within the `Get Apigee Access Token` step was failing. `jq` is being used to extract the .access_token path from the JSON response - previously it was not returning an error code when the payload did not contain the path. This updates the `jq` call with the `-e` flag which will error when `.access_token` is not within the response. An automated retry mechanism for when this error occurs has been added to this step. It uses the built in azure devops retryCountOnTaskFailure which will automatically back off on subsequent failures. See https://learn.microsoft.com/en-us/azure/devops/pipelines/process/tasks?view=azure-devops&tabs=yaml#number-of-retries-if-task-failed
1 parent 334a6a6 commit 8cfd805

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

azure/components/get-access-token.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,15 @@ steps:
2222
2323
- bash: |
2424
set -euo pipefail
25+
26+
# fetch the access token
2527
curl -X POST https://${{ parameters._auth_server[parameters.apigee_organization] }}/oauth/token \
2628
-H "Content-Type: application/x-www-form-urlencoded" \
2729
-H "Accept: application/json;charset=utf-8" \
2830
-H "Authorization: Basic ZWRnZWNsaTplZGdlY2xpc2VjcmV0" \
29-
-d "username=${{ parameters.apigee_username }}&password=${{ parameters.apigee_password }}&mfa_token=$(secret.MFACode)&grant_type=password" | jq .access_token > .token
31+
-d "username=${{ parameters.apigee_username }}&password=${{ parameters.apigee_password }}&mfa_token=$(secret.MFACode)&grant_type=password" | jq -e .access_token > .token
3032
3133
# Set token into variable
3234
echo "##vso[task.setvariable variable=secret.AccessToken;issecret=true]`cat .token`"
3335
displayName: 'Get Apigee Access Token'
36+
retryCountOnTaskFailure: 5

0 commit comments

Comments
 (0)