用于构建和发布的Azure管道分支名称

问题描述 投票:0回答:1

我正在尝试设置 Azure Devops 构建和发布管道,以使用 Databricks 资产包构建和部署 Databricks 作业。我一直在关注以下文档: https://learn.microsoft.com/en-us/azure/databricks/dev-tools/ci-cd/ci-cd-azure-devops

构建管道是一个简单的管道,如下所示,在合并到主分支和开发分支时触发。

trigger:
  branches:
    include:
      - feature/azure-pipeline

pool:
  vmImage: ubuntu-22.04

steps:
- checkout: self
  clean: true
  fetchDepth: 1
  persistCredentials: true


- bash: echo $(Build.SourceBranch)

- task: ArchiveFiles@2
  inputs:
    rootFolderOrFile: '$(Build.SourcesDirectory)'
    includeRootFolder: false
    archiveType: 'zip'
    archiveFile: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip'
    replaceExistingArchive: true

- task: PublishBuildArtifacts@1
  inputs:
    ArtifactName: 'DatabricksBuild'

现在,在发行版中我有一个环境变量,它将取决于触发构建的分支。如何在构建管道中保存触发分支名称以在管道的发布部分中使用它?

azure-devops azure-pipelines azure-databricks azure-pipelines-release-pipeline databricks-asset-bundle
1个回答
0
投票

据我了解,您的要求是检索发布管道中的分支名称;提交/合并到此分支会触发上游构建管道,然后生成工件并触发下游发布管道。

为此,您可以直接使用

release pipeline
中的
$(Build.SourceBranch)
$(Build.SourceBranchName)的[预定义变量](经典发布和工件变量 - Azure Pipelines | Microsoft Learn); Azure Pipelines 为指定的主要工件填充此类变量。

如果您添加了由不同构建管道生成的多个工件,您还可以使用·$(Release.Artifacts.{alias}.SourceBranch)·和

$(Release.Artifacts.{alias}.SourceBranchName)
来获取不同构建管道工件的每个触发分支。

© www.soinside.com 2019 - 2024. All rights reserved.