Durch die Nutzung dieser Website, Sie stimmen dem zu Datenschutzrichtlinie.
Akzeptieren
EnterinITEnterinITEnterinIT
  • HEIM
  • IT-PROFI
  • TECH
  • MICROSOFT
    • Azurblau
    • ConfigMgr/SCCM
    • DPM
    • Orchestrator
    • Hyper-V
    • Microsoft Edge Insider
    • MSI
    • Büro 365
    • Büro-Insider
    • Power BI
    • Skype
    • SQL-Server
    • Mannschaften
  • FENSTER
    • Windows Admin Center
    • Windows-Client
    • Windows-Server
  • SCCM-Abfragesammlungsliste
Lektüre: Creating a New Azure DevOps Build and Updating its Variables with REST API
Schriftart-ResizerAa
EnterinITEnterinIT
Schriftart-ResizerAa
  • HEIM
  • IT-PROFI
  • TECH
  • MICROSOFT
  • FENSTER
  • SCCM-Abfragesammlungsliste
Suchen
  • HEIM
  • IT-PROFI
  • TECH
  • MICROSOFT
    • Azurblau
    • ConfigMgr/SCCM
    • DPM
    • Orchestrator
    • Hyper-V
    • Microsoft Edge Insider
    • MSI
    • Büro 365
    • Büro-Insider
    • Power BI
    • Skype
    • SQL-Server
    • Mannschaften
  • FENSTER
    • Windows Admin Center
    • Windows-Client
    • Windows-Server
  • SCCM-Abfragesammlungsliste
Azure DevOps

Creating a New Azure DevOps Build and Updating its Variables with REST API

Veröffentlicht im November 29, 2024
4 Min. Lesezeit
AKTIE

Creating a New Azure DevOps Build and Updating its Variables with REST API.

Azure DevOps is a comprehensive suite of development tools and services designed to help teams build and ship software faster and more efficiently. One of the key features of Azure DevOps is its build system, which allows teams to automate the build, test, and deployment process of their software.

In diesem Artikel, we will explore how to create a new Azure DevOps build and update its variables using REST API. We will use a sample code snippet that demonstrates how to create a new build using cURL, but you can use any programming language that supports REST API calls.

The first step in creating a new Azure DevOps build is to define its properties, such as the build definition and the build parameters. The build definition defines the build steps, which can include tasks like compiling code, running tests, and creating artifacts. The build parameters are variables that are used by the build steps to customize the build process.

To create a new build using REST API, you need to send a POST request to the Azure DevOps API endpoint that creates builds. The following code snippet demonstrates how to create a new build using cURL:

curl -X POST "https://dev.azure.com/{organization}/{project}/_apis/build/builds?api-version=7.0" \
-H "Content-Type: application/json" \
-d '{
    "definition": {
        "id": {definition_id}
    },
    "parameters": "{\"{parameter_name}\":\"{parameter_value}\"}"
}'

Working example with PAT:

curl -X POST "https://{username}:{PAT}@dev.azure.com/{organization}/{project}/_apis/build/builds?api-version=7.0" \
-H "Content-Type: application/json" \
-d '{
    "definition": {
        "id": {definition_id}
    },
    "parameters": "{\"{parameter_name}\":\"{parameter_value}\"}"
}'

Let’s break down this code snippet:

  • Der -X POST flag specifies that we want to send a POST request.
  • The API endpoint for creating builds is https://dev.azure.com/{organization}/{project}/_apis/build/builds?api-version=7.0, Wo {organization} is the name of your Azure DevOps organization and {project} is the name of your project. Der api-version parameter specifies the version of the API we want to use.
  • Der -H "Content-Type: application/json" flag specifies that we are sending JSON data in the request body.
  • The request body is a JSON object that contains the following properties:
    • definition: an object that specifies the build definition. Der id property specifies the ID of the build definition.
    • parameters: a JSON-formatted string that specifies the build parameters. Der {parameter_name} Und {parameter_value} placeholders should be replaced with the actual parameter name and value, jeweils.

In the example code snippet, we are creating a new build using the build definition with ID 15 and updating its NUMBER_OF_WORKERS parameter with the value of a variable 2_NUMBER_OF_WORKERS, which can be replaced with an actual value at runtime. We are also setting the NUMBER_OF_WORKERS2 parameter to a static value of 5.

To update a build variable using REST API, you need to send a PATCH request to the API endpoint that updates build variables. The following code snippet demonstrates how to update a build variable using cURL:

curl -X PATCH "https://dev.azure.com/{organization}/{project}/_apis/build/builds/{build_id}/variables?api-version=7.0" \
-H "Content-Type: application/json" \
-d '{
    "variables": {
        "{variable_name}": {
            "value": "{new_value}"
        }
    }
}'

Let’s break down this code snippet:

  • Der -X PATCH flag specifies that we want to send a PATCH request.
  • The API endpoint for updating build variables is `https://dev.azure.com/{organization}/{project}/_apis/build/builds/{build_id}/variables?api-version=7.0
GETAGGT:APIAzure DevOpsBashCI/CDcurlJSONMicrosoft Azure
Vorheriger Artikel Reibungsloses Upgrade von Ubuntu 18 zu Ubuntu 20
Nächster Artikel Activating EPEL and EPEL Next in Almalinux 9 or Rocky Linux 9 Activating EPEL and EPEL Next in Almalinux 9 or Rocky Linux 9
Hinterlassen Sie einen Kommentar Hinterlassen Sie einen Kommentar

Hinterlassen Sie eine Antwort Antwort abbrechen

Ihre E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind markiert *

Diese Website verwendet Akismet, um Spam zu reduzieren. Erfahren Sie, wie Ihre Kommentardaten verarbeitet werden.

Übersetzung

English中文(简体)DanskNederlandsFrançaisDeutschItaliano한국어PolskiPortuguêsRomânăEspañolУкраїнська
 Übersetzung bearbeiten
von Transposh - Übersetzungs-Plug-In für WordPress

Beliebte Beiträge

Systemanforderungen für Windows Server 2016
Windows-Server
Configuration Manager-Abfragesammlungsliste
Configuration Manager-Abfragesammlungsliste
ConfigMgr
Strukturierte/verwaltete Navigation auf modernen Seiten in klassischen Teamsites aktiviert
Techn
SCCM konnte DP-Standorte nicht als erwartete Version von MP abrufen
ConfigMgr

Aktuelle Beiträge

Installieren und Konfigurieren von Fail2ban für den SSH-Schutz unter Ubuntu 24.04
Linux
Aktivieren und Konfigurieren von FirewallD auf AlmaLinux
Linux
Benutzererstellung und SSH-Schlüsseleinrichtung in AlmaLinux
Linux
So setzen Sie das Passwort unter AlmaLinux zurück
Linux

© 2023 EnterinIT

Gehen Sie zur mobilen Version
Werbebanner
Willkommen zurück!

Melden Sie sich bei Ihrem Konto an

Benutzername oder E-Mail-Adresse
Passwort

Passwort verloren?