I have a bash script which checks if the ACCESS_TOKEN is equal to null it will exit.
ACCESS_TOKEN=$(jq -r '.access_token' <<<"$(curl --request GET \
--url 'https://'$LANDSCAPE'/oauth/token/?grant_type=client_credentials' \
-u "$CLIENT_ID":"$CLIENT_SECRET")")
if [[ -n $ACCESS_TOKEN -eq null ]]; then
exit 1
fi
or:
ACCESS_TOKEN=$(jq -r '.access_token' <<<"$(curl --request GET \
--url 'https://'$LANDSCAPE'/oauth/token/?grant_type=client_credentials' \
-u "$CLIENT_ID":"$CLIENT_SECRET")")
if [ -n "$ACCESS_TOKEN" -eq null ]; then
exit 1
fi
the console logs:
+ ACCESS_TOKEN=null
+ '[' -n null -eq null ']'
/tmp/jenkins6798373284183556496.sh: line 8: [: too many arguments
It seems that the if condition is not working well.