다음을 통해 공유


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.
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.

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

속성

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

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

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

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

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

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

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

설명

참고

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

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

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

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

참고

파이프라인 완료 트리거는 수동 및 예약된 빌드에 기본 분기 설정을 사용하여 다른 파이프라인 완료의 결과로 파이프라인을 실행할지 여부를 결정할 때 평가할 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

중요

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

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

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

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

변수
Build.Reason ResourceTrigger
Resources.TriggeringAlias 이전 예제와 같은 source-pipeline 파이프라인 리소스의 이름입니다.
Resource.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 태스크는 라는 source-pipelineFabrikamFiber파이프라인 리소스의 를 출력합니다projectName.

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

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

참고

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

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

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

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/*

참고 항목