Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save marcosborges/6c472f2658b733240b57ff15e2845efd to your computer and use it in GitHub Desktop.
Save marcosborges/6c472f2658b733240b57ff15e2845efd to your computer and use it in GitHub Desktop.
#!/bin/bash
# Definir variáveis de ambiente
ORGANIZATION="minhaorganizacao"
PROJECT="meuprojeto"
VAR_GROUP_NAME="nome_do_variable_group"
VAR_NAME="nome_da_variavel"
# Obter o ID do Variable Group com o nome especificado
VAR_GROUP_ID=$(curl -s -u ":$(pat)" \
"https://dev.azure.com/${ORGANIZATION}/${PROJECT}/_apis/distributedtask/variablegroups?api-version=6.0-preview.2" \
| jq -r ".value[] | select(.name == \"${VAR_GROUP_NAME}\") | .id")
# Fazer a requisição para a API de Variable Groups do Azure DevOps utilizando o ID obtido acima
response=$(curl -s -u ":$(pat)" \
"https://dev.azure.com/${ORGANIZATION}/${PROJECT}/_apis/distributedtask/variablegroups/${VAR_GROUP_ID}?api-version=6.0-preview.2")
# Filtrar a resposta utilizando o jq para encontrar a variável com o nome especificado
result=$(echo "${response}" | jq -r ".variables[] | select(.name == \"${VAR_NAME}\")")
# Exibir o resultado
echo "${result}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment