Created
February 6, 2019 23:03
-
-
Save cicorias/5ec27bd65182517ad795cd29c2cd6c93 to your computer and use it in GitHub Desktop.
vsts get service endpoints
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
pat="..." | |
serviceEndpointName="ago2-arm" | |
endpointId="66631332-2be3-46e4-b217-0c59776cc935" | |
echo "calling DevOps REST API" | |
body=$(curl --request GET \ | |
--url $SYSTEM_TEAMFOUNDATIONCOLLECTIONURI/$SYSTEM_TEAMPROJECT/_apis/serviceendpoint/endpoints/$endpointId?api-version=5.0-preview.2 \ | |
--header "Authorization: Bearer ${SYSTEM_ACCESSTOKEN}" \ | |
--header 'cache-control: no-cache') | |
echo $body | |
# body1=$(curl --request GET \ | |
# --url $SYSTEM_TEAMFOUNDATIONCOLLECTIONURI/$SYSTEM_TEAMPROJECT/_apis/serviceendpoint/endpoints?api-version=5.0-preview.2 \ | |
# --header "Authorization: Bearer ${SYSTEM_ACCESSTOKEN}" \ | |
# --header 'cache-control: no-cache') | |
# echo $? | |
# echo $body | |
echo "parsing json" | |
# result=$(echo $body | jq ".value | .[] | select( .name | test(\"^${serviceEndpointName}$\"; \"i\")) | { name: .name, id: .id }") | |
result=$(echo $body | jq ". | select( .name | test(\"^${serviceEndpointName}$\"; \"i\")) ") | |
echo "checking result" | |
if [ -z "$result" ]; then | |
echo 'not found' | |
exit 1 | |
else | |
echo $result | |
exit 0 | |
fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment