@@ -147,13 +147,13 @@ steps:
147147 MI_DATA=$(az identity list \
148148 --resource-group "$ACNCI_BUILD_RESOURCEGROUP" | \
149149 jq -rc '.')
150- MI_DATA_LENGTH=$(echo "$MA_DATA " | jq length)
150+ MI_DATA_LENGTH=$(echo "$MI_DATA " | jq length)
151151
152152 echo $MI_DATA
153153 echo $MI_DATA_LENGTH
154- if [[ -n $MA_DATA ]] && \
155- [[ $MA_DATA != null ]] && \
156- (( $MA_DATA_LENGTH > 0 )); then
154+ if [[ -n $MI_DATA ]] && \
155+ [[ $MI_DATA != null ]] && \
156+ (( $MI_DATA_LENGTH > 0 )); then
157157 echo >&2 "##vso[task.setvariable variable=MI_DATA;isoutput=true]$MI_ID"
158158 echo >&2 "##vso[task.setvariable variable=CREATE_NEW_MI;]false"
159159 else
@@ -226,9 +226,16 @@ steps:
226226
227227 set -x
228228 pwd
229- DEFS_FOUND=$(az role definition list --name "$ACNCI_BUILDUSER_ROLE_NAME" --custom-role-only -ojson | jq length)
230-
231- DEF=$(cat ./azure-container-networking/.pipelines/templates/mi-build-role.json | jq -rc --arg RESOURCEID "/subscriptions/$SUBSCRIPTION_ID" '.assignableScopes[] = $RESOURCEID')
229+ DEFS_FOUND=$(az role definition list \
230+ --name "$ACNCI_BUILDUSER_ROLE_NAME" \
231+ --custom-role-only \
232+ -ojson | \
233+ jq length)
234+
235+ DEF=$(cat ./azure-container-networking/.pipelines/templates/mi-build-role.json | \
236+ jq -rc \
237+ --arg RESOURCEID "/subscriptions/$SUBSCRIPTION_ID" \
238+ '.assignableScopes[] = $RESOURCEID')
232239 echo "here1"
233240 if (( "$DEFS_FOUND" < 1 )); then
234241 echo "here2"
@@ -260,11 +267,12 @@ steps:
260267
261268 R_QUERY="[? principalId == '$ACNCI_MANAGEDIDENTITY_OBJECTID' ]"
262269 MI_ROLE_DATA=$(az role assignment list \
263- --role "$ACNCI_BUILDUSER_ROLE_NAME"
264- --resource-group "$ACNCI_BUILD_RESOURCEGROUP"
265- --query "$R_QUERY"
270+ --role "$ACNCI_BUILDUSER_ROLE_NAME" \
271+ --resource-group "$ACNCI_BUILD_RESOURCEGROUP" \
272+ --query "$R_QUERY" \
266273 --output json | jq -rc '.')
267- MI_ROLE_DATA_LENGTH=$(echo "$MA_ROLE_DATA" | jq length)
274+ MI_ROLE_DATA_LENGTH=$(echo "$MI_ROLE_DATA" | jq length)
275+
268276 echo >&2 "##vso[task.setvariable variable=MI_ROLE_DATA;]$MI_ROLE_DATA"
269277 echo >&2 "##vso[task.setvariable variable=MI_ROLE_LENGTH;]$MI_ROLE_DATA_LENGTH"
270278 env :
@@ -284,8 +292,8 @@ steps:
284292 [[ -n $SYSTEM_DEBUG ]] && [[ $SYSTEM_DEBUG =~ $IS_TRUE ]] && set -x || set +x
285293
286294 if [[ -n $MI_ROLE_DATA_LENGTH ]] && \
287- [[ $MA_DATA != null ]] && \
288- (( $MA_DATA_LENGTH > 0 )); then
295+ [[ $MI_DATA != null ]] && \
296+ (( $MI_DATA_LENGTH > 0 )); then
289297 az role assignment create \
290298 --role "$ACNCI_BUILDUSER_ROLE_NAME"
291299 --assignee-object-id "$ACNCI_MANAGEDIDENTITY_OBJECTID" \
0 commit comments