다음을 통해 공유


resources.pipelines.pipeline 정의

아티팩트를 생성하는 Azure Pipeline이 있는 경우 파이프라인은 파이프라인 리소스를 정의하여 아티팩트를 사용할 수 있습니다. Azure DevOps Server 2020 이상에서는 파이프라인 리소스를 사용하여 파이프라인 완료 트리거를 사용하도록 설정할 수도 있습니다.

pipelines:
- pipeline: string # Required as first property. ID of the pipeline resource.
  project: string # Project for the source; defaults to current project.
  source: string # Name of the pipeline that produces the artifact.
  version: string # The pipeline run number to pick the artifact, defaults to latest pipeline successful across all stages; used only for manual or scheduled triggers.
  branch: string # Branch to pick the artifact. Optional; defaults to all branches, used only for manual or scheduled triggers.
  tags: [ string ] # List of tags required on the pipeline to pickup default artifacts. Optional; used only for manual or scheduled triggers.
  trigger:  # Specify none to disable, true to include all branches, or use the full syntax as described in the following examples.
    enabled: boolean # Whether the trigger is enabled; defaults to true.
    branches: branches # Branches to include or exclude for triggering a run.
    stages: [ string ] # List of stages that when matched will trigger the pipeline.
    tags: [ string ] # List of tags that when matched will trigger the pipeline.
pipelines:
- pipeline: string # Required as first property. ID of the pipeline resource.
  project: string # Project for the source; defaults to current project.
  source: string # Name of the pipeline that produces the artifact.
  version: string # The pipeline run number to pick the artifact, defaults to latest pipeline successful across all stages; used only for manual or scheduled triggers.
  branch: string # Branch to pick the artifact. Optional; defaults to all branches, used only for manual or scheduled triggers.
  tags: [ string ] # List of tags required on the pipeline to pickup default artifacts. Optional; used only for manual or scheduled triggers.
  trigger:  # Specify none to disable, true to include all branches, or use the full syntax as described in the following examples.
    enabled: boolean # Whether the trigger is enabled; defaults to true.
    branches: branches # Branches to include or exclude for triggering a run.

이 정의를 참조하는 정의: resources.pipelines

속성

pipeline 문자열입니다. 첫 번째 속성으로 필요합니다.
파이프라인 리소스의 ID입니다. 허용되는 값: [-_A-Za-z0-9]*.

project 문자열입니다.
원본에 대한 프로젝트입니다. 은 현재 프로젝트로 기본 설정됩니다.

source 문자열입니다.
아티팩트 생성 파이프라인의 이름입니다. 파이프라인이 폴더에 포함된 경우 앞에 오는 \포함하여 폴더 이름을 포함합니다(예: \security pipelines\security-lib-ci). 이 속성은 대/소문자를 구분하지 않으며 이름에 공백이 포함된 경우 따옴표가 필요하지 않습니다. 이름이 같은 여러 파이프라인이 있는 경우 폴더 경로를 지정해야 합니다.

version 문자열입니다.
아티팩트 선택을 위한 파이프라인 실행 번호입니다. 기본적으로 모든 단계에서 성공한 최신 파이프라인으로 설정됩니다. 수동 또는 예약된 트리거에만 사용됩니다.

branch 문자열입니다.
분기를 선택하여 아티팩트 선택 선택적; 는 수동 또는 예약된 트리거에만 사용되는 모든 분기로 기본 설정됩니다.

tags 문자열 목록입니다.
파이프라인에서 기본 아티팩트 픽업에 필요한 태그 목록입니다. 선택적; 수동 또는 예약된 트리거에만 사용됩니다.

resources.pipelines.pipeline.triggertrigger.
사용하지 않도록 설정하거나, 모든 분기를 포함하려면 true를 지정하거나, 다음 예제에 설명된 대로 전체 구문을 사용합니다.

비고

비고

pipeline: 파이프라인 리소스의 이름을 지정합니다. 파이프라인 리소스 변수를 사용하거나 아티팩트 다운로드와 같이 파이프라인의 다른 부분에서 파이프라인 리소스를 참조할 때 여기에 정의된 레이블을 사용합니다.

파이프라인 리소스 트리거의 stagestags 대한 자세한 내용은 파이프라인 완성 트리거를 참조하세요.

파이프라인 리소스 트리거에 대한 자세한 내용은 파이프라인 완성 트리거를 참조하세요.

파이프라인 리소스 트리거 구문

비고

파이프라인 완료 트리거는 수동 및 예약된 빌드 설정에 기본 분기를 사용하여 다른 파이프라인 완료의 결과로 파이프라인을 실행할지 여부를 결정할 때 평가할 YAML 파이프라인의 분기 필터 버전을 결정합니다. 기본적으로 이 설정은 리포지토리의 기본 분기를 가리킵니다. 자세한 내용은 파이프라인 완료 트리거 -분기 고려 사항을 참조하세요.

파이프라인 리소스에서 트리거를 정의하는 방법에는 여러 가지가 있습니다. 참조된 파이프라인의 실행이 완료될 때 실행을 트리거하려면 trigger: true사용합니다.

resources:
  pipelines:
  - pipeline: source-pipeline
    source: TriggeringPipeline
    trigger: true

파이프라인 리소스 트리거를 사용하지 않도록 설정하려면 none값을 지정합니다.

resources:
  pipelines:
  - pipeline: source-pipeline
    source: TriggeringPipeline
    trigger: none

분기 필터를 구성하려면 전체 구문을 사용합니다. 분기 필터는 포함할 분기 목록 또는 제외할 분기 목록과 함께 포함할 분기 목록으로 지정할 수 있습니다.

포함 및 제외할 분기 목록을 지정하려면 다음 trigger 구문을 사용합니다.

resources:
  pipelines:
  - pipeline: source-pipeline
    source: TriggeringPipeline
    trigger:
      branches:
        include:
        - main
        - develop
        - features/*
        exclude:
        - features/experimental/*

포함할 분기 목록을 제외 없이 지정하려면 exclude 값을 생략하거나 다음 구문을 사용하여 branches바로 다음에 포함할 분기 목록을 지정합니다.

resources:
  pipelines:
  - pipeline: source-pipeline
    source: TriggeringPipeline
    trigger:
      branches:
      - main
      - develop

단계 또는 태그별로 필터링하려면 다음 trigger 구문을 사용합니다.

resources:
  pipelines:
  - pipeline: source-pipeline
    source: TriggeringPipeline
    trigger:
      branches: # Branches to include
      tags: # List of tags that when matched will trigger the pipeline. 
      - release25
      stages: # List of stages that when complete will trigger the pipeline. 
      - build

자세한 내용은 파이프라인 완료 트리거참조하세요.

중요합니다

리소스 트리거를 정의할 때 파이프라인 리소스가 현재 파이프라인과 동일한 리포지토리에 있는 경우 트리거는 이벤트가 발생하는 동일한 분기 및 커밋을 따릅니다. 그러나 파이프라인 리소스가 다른 리포지토리에서 온 경우 현재 파이프라인은 수동 및 예약된 빌드 설정을 위해 기본 분기에서 지정한 분기에서 트리거됩니다. 자세한 내용은 파이프라인 완료 트리거에 대한분기 고려 사항을 참조하세요.

미리 정의된 변수로 파이프라인 리소스 메타데이터

각 실행에서 파이프라인 리소스에 대한 메타데이터는 모든 작업에서 다음 미리 정의된 변수로 사용할 수 있습니다. 이러한 변수는 런타임에 파이프라인에서 사용할 수 있으므로 파이프라인 컴파일 시간에 평가되는 템플릿 식 사용할 수 없습니다.

resources.pipeline.<Alias>.projectName
resources.pipeline.<Alias>.projectID
resources.pipeline.<Alias>.pipelineName
resources.pipeline.<Alias>.pipelineID
resources.pipeline.<Alias>.runName
resources.pipeline.<Alias>.runID
resources.pipeline.<Alias>.runURI
resources.pipeline.<Alias>.sourceBranch
resources.pipeline.<Alias>.sourceCommit
resources.pipeline.<Alias>.sourceProvider
resources.pipeline.<Alias>.requestedFor
resources.pipeline.<Alias>.requestedForID

중요합니다

파이프라인 리소스에 지정된 project 값이 없는 경우 변수에 projectName 없습니다. project 속성은 동일한 프로젝트의 파이프라인을 참조하는 파이프라인 리소스에 대해 선택 사항이지만 원하는 경우 지정할 수 있습니다.

<Alias> 파이프라인 리소스의 ID로 바꿉니다. 다음 파이프라인 리소스의 경우 runID 액세스하는 변수는 resources.pipeline.source-pipeline.runID.

resources:
  pipelines:
  - pipeline: source-pipeline
    source: TriggeringPipeline

파이프라인 리소스 중 하나에 의해 파이프라인이 트리거되면 이전 목록의 변수 외에도 다음 변수가 설정됩니다.

변수 가치
Build.Reason ResourceTrigger
Resources.TriggeringAlias 이전 예제의 source-pipeline 같은 파이프라인 리소스의 이름입니다.
Resources.TriggeringCategory pipeline

다음 예제에는 두 개의 파이프라인 리소스가 있습니다.

resources:
 pipelines:
   - pipeline: source-pipeline
     source: PipelineTriggerSource
     project: FabrikamFiber
     trigger: true
   - pipeline: other-project-pipeline
     source: PipelineTriggerFromOtherProject
     project: FabrikamRepo
     trigger: true

trigger: none # Only trigger with pipeline resource trigger

pool:
  vmImage: ubuntu-latest

- bash: echo $(resources.pipeline.source-pipeline.projectName)
- bash: printenv | sort

이 파이프라인이 실행되면 첫 번째 bash 태스크는 FabrikamFibersource-pipeline이라는 파이프라인 리소스의 projectName 출력합니다.

두 번째 bash 태스크는 이 섹션에 설명된 파이프라인 리소스 변수를 포함하여 작업에 사용할 수 있는 모든 환경 변수를 출력합니다. 환경 변수 나열은 일반적으로 프로덕션 파이프라인에서 수행되지 않지만 문제 해결에 유용할 수 있습니다. 이 예제에는 두 개의 파이프라인 리소스가 있으며 출력에는 다음 두 줄이 포함됩니다.

RESOURCES_PIPELINE_OTHER-PROJECT-PIPELINE_PROJECTNAME=FabrikamRepo
RESOURCES_PIPELINE_SOURCE-PIPELINE_PROJECTNAME=FabrikamFiber

비고

시스템 및 사용자 정의 변수는 플랫폼에 대한 환경 변수로 삽입됩니다. 변수가 환경 변수로 변환되면 변수 이름이 대문자가 되고 마침표가 밑줄로 바뀝니다. 예를 들어 변수 이름 any.variableANY_VARIABLE됩니다.

변수 및 변수 구문을 사용하는 방법에 대한 자세한 내용은 변수 구문이해, 조건 지정 및 참조하세요.

download 작업을 사용하여 파이프라인 리소스에서 아티팩트를 사용할 수 있습니다. steps.download 키워드를 참조하세요.

예시

resources:
  pipelines:
  - pipeline: MyAppA
    source: MyCIPipelineA
  - pipeline: MyAppB
    source: MyCIPipelineB
    trigger: true
  - pipeline: MyAppC
    project:  DevOpsProject
    source: MyCIPipelineC
    branch: releases/M159
    version: 20190718.2
    trigger:
      branches:
        include:
        - main
        - releases/*
        exclude:
        - users/*

참고하십시오