Bash start Azure DevOps Release via API.
To start a release from Azure DevOps via the API using bash, you can use the following steps:
- Obtain a Personal Access Token (PAT) from Azure DevOps. This token will be used to authenticate your API requests.
- Determine the Azure DevOps organization name, project name, and release pipeline ID for the release you want to start. You can find the release pipeline ID by navigating to the Releases page in Azure DevOps, selecting the release pipeline, and copying the ID from the URL.
- Construct the API request URL with the appropriate parameters. The URL should have the following format:
https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/releases?api-version=7.0
Сменете {organization}
with the name of your Azure DevOps organization, {project}
with the name of your project you want to start.
- Create a bash script with the following code, замяна на контейнерите с вашите собствени стойности:
#!/bin/bash
# Set variables
PAT="YOUR-PAT-HERE"
ORGANIZATION="YOUR-ORGANIZATION-NAME-HERE"
PROJECT="YOUR-PROJECT-NAME-HERE"
RELEASE_ID="YOUR-RELEASE-ID-HERE"
# Construct API request URL
URL="https://vsrm.dev.azure.com/${ORGANIZATION}/${PROJECT}/_apis/release/releases?api-version=7.0"
# Start release
curl -X POST \
-H "Authorization: Basic $(echo -n ":${PAT}" | base64)" \
-H "Content-Type: application/json" \
-d "{"definitionId": "${RELEASE_ID}"}" \
${URL}
- Save the script and execute it in a terminal window. The script will start the release pipeline in Azure DevOps using the API.
Имайте предвид, че този скрипт предполага, че имате curl
инструмент за команден ред, инсталиран на вашата система. Ако нямате curl
, можете да го инсталирате с помощта на вашия мениджър на пакети.
Обърнете внимание, че ако трябва автоматично да стартирате версии в Release Pipeline (без ръчни действия) направете тази промяна в Release Pipeline