Skip to content

Commit 7afca62

Browse files
author
Sheyla Trudo
committed
fixup! Move to Resource Module
1 parent 03e2272 commit 7afca62

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

.pipelines/templates/get-resources.steps.yaml

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,21 @@ steps:
5959
set -e
6060
[[ -n $SYSTEM_DEBUG ]] && [[ $SYSTEM_DEBUG =~ $IS_TRUE ]] && set -x || set +x
6161
62-
DEF=$(cat "$ROLEDEFINITION_FILEPATH" | \
63-
jq -rc \
64-
--arg RESOURCEID "/subscriptions/$SUBSCRIPTION_ID" \
65-
'.assignableScopes[] = $RESOURCEID')
66-
67-
DEFS_FOUND=$(az role definition list \
62+
DEFS=$(az role definition list \
6863
--name "$ROLEDEFINITION_NAME" \
6964
--custom-role-only \
70-
-ojson | \
71-
jq length)
65+
-ojson | jq -rc '.')
66+
DEFS_FOUND=$(echo "$DEFS" | jq length)
67+
68+
if [[ -z $DEFS ]] || \
69+
[[ $DEFS_FOUND == 'null' ]] || \
70+
(( $DEFS_FOUND < 1 )); then
71+
72+
DEFS=$(cat "$ROLEDEFINITION_FILEPATH" | \
73+
jq -rc \
74+
--arg RESOURCEID "/subscriptions/$SUBSCRIPTION_ID" \
75+
'.assignableScopes[] = $RESOURCEID')
76+
fi
7277

7378
echo >&2 "##vso[task.setvariable variable=${VAR_NAME};]$DEFS"
7479
echo >&2 "##vso[task.setvariable variable=${VAR_NAME}_LENGTH;]$DEFS_FOUND"

0 commit comments

Comments
 (0)