이 사이트를 이용함으로써, 당신은 다음에 동의합니다 개인 정보 보호 정책.
수용하다
엔터인IT엔터인IT엔터인IT
  • 집
  • IT 프로
  • 기술
  • 마이크로 소프트
    • 하늘빛
    • 구성 관리자/SCCM
    • DPM
    • 오케스트레이터
    • Hyper-V
    • 마이크로소프트 엣지 인사이더
    • MSI
    • 사무실 365
    • 사무실 내부자
    • 파워 BI
    • 스카이프
    • SQL 서버
    • 팀
  • 창
    • Windows 관리 센터
    • 윈도우 클라이언트
    • 윈도우 서버
  • SCCM 쿼리 컬렉션 목록
독서: Creating a New Azure DevOps Build and Updating its Variables with REST API
글꼴 크기 조정기아아
엔터인IT엔터인IT
글꼴 크기 조정기아아
  • 집
  • IT 프로
  • 기술
  • 마이크로 소프트
  • 창
  • SCCM 쿼리 컬렉션 목록
찾다
  • 집
  • IT 프로
  • 기술
  • 마이크로 소프트
    • 하늘빛
    • 구성 관리자/SCCM
    • DPM
    • 오케스트레이터
    • Hyper-V
    • 마이크로소프트 엣지 인사이더
    • MSI
    • 사무실 365
    • 사무실 내부자
    • 파워 BI
    • 스카이프
    • SQL 서버
    • 팀
  • 창
    • Windows 관리 센터
    • 윈도우 클라이언트
    • 윈도우 서버
  • SCCM 쿼리 컬렉션 목록
Azure DevOps

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

게시: 2월 19, 2024
4 최소 읽기
공유하다

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 this article, 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:

  • The -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, where {organization} is the name of your Azure DevOps organization and {project} is the name of your project. The api-version parameter specifies the version of the API we want to use.
  • The -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. The id property specifies the ID of the build definition.
    • parameters: a JSON-formatted string that specifies the build parameters. The {parameter_name} 그리고 {parameter_value} placeholders should be replaced with the actual parameter name and value, respectively.

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:

  • The -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
태그됨:APIAzure DevOpsBashCI/CDcurlJSONMicrosoft Azure
이전 기사 Smoothly Upgrading from Ubuntu 18 to Ubuntu 20
다음 기사 Almalinux에서 EPEL 및 EPEL Next 활성화 9 또는 록키 리눅스 9 Almalinux에서 EPEL 및 EPEL Next 활성화 9 또는 록키 리눅스 9
코멘트를 남겨주세요 코멘트를 남겨주세요

답장을 남겨주세요 답장 취소

귀하의 이메일 주소는 공개되지 않습니다. 필수 입력란이 표시되어 있습니다 *

이 사이트는 스팸을 줄이기 위해 Akismet을 사용합니다.. 댓글 데이터가 처리되는 방법 알아보기.

번역

English中文(简体)DanskNederlandsFrançaisDeutschItaliano한국어PolskiPortuguêsRomânăEspañolУкраїнська
~에 의해 Transposh - translation plugin for wordpress

인기 게시물

Windows Server의 시스템 요구 사항 2016
윈도우 서버
구성 관리자 쿼리 컬렉션 목록
구성 관리자 쿼리 컬렉션 목록
configmgr
클래식 팀 사이트의 최신 페이지에서 구조적/관리형 탐색 활성화
기술
SCCM이 DP 위치를 MP에서 예상 버전으로 가져오지 못했습니다.
configmgr

최근 게시물

Ubuntu에서 SSH 보호를 위한 Fail2ban 설치 및 구성 24.04
리눅스
AlmaLinux에서 FirewallD 활성화 및 구성
리눅스
AlmaLinux에서 사용자 생성 및 SSH 키 설정
리눅스
AlmaLinux에서 비밀번호를 재설정하는 방법
리눅스

© 2023 엔터인IT

모바일 버전으로 이동하십시오
돌아온 것을 환영합니다!

귀하의 계정에 로그인하세요

사용자 이름 또는 이메일 주소
비밀번호

비밀번호를 잃어버렸습니다?