标签: azure-pipelines-yaml

Azure Pipelines 中的单个 CI 与批量 CI

Azure Pipelines 中的单个 CI 和批量 CI 有什么区别?

batch它与 Azure Pipelines YAML 中的选项有何关系trigger

trigger:
  batch: 'true'
  branches:
    include:
     - main
Run Code Online (Sandbox Code Playgroud)

continuous-integration azure-pipelines azure-pipelines-yaml

5
推荐指数
1
解决办法
9505
查看次数

Azure YAML管道条件插入不起作用

考虑以下管道片段,这是模板的一部分。

- task: Bash@3
  inputs:
    targetType: 'inline'
    script: |
      echo "##vso[task.setvariable variable=AppType;]WebJob"
      echo "##[debug] AppType set to WebJob"

# This works, using the task condition
- task: DotNetCoreCLI@2
  condition: eq(variables['AppType'], 'WebJob')
  displayName: 'net publish for WebJob'
  inputs:
    command: 'publish'

# This doesn't work, using the conditional insertion, index syntax
- ${{ if eq(variables['AppType'], 'WebJob') }}:
  - task: DotNetCoreCLI@2
    displayName: 'net publish for WebJob'
    inputs:
      command: 'publish'

# This also doesn't work, using the conditional insertion, property dereference syntax
- ${{ …
Run Code Online (Sandbox Code Playgroud)

yaml azure-devops azure-pipelines azure-pipelines-yaml

5
推荐指数
2
解决办法
3631
查看次数

Azure DevOps 存储库触发器未触发

我希望在提交到同一 Azure 项目内的另一个存储库后运行一个存储库的管道。

我的管道定义:

resources:         
  repositories:
  - repository: SupDevA
    name: Sup.Dev.A
    type: git
    ref: test
    trigger:
      branches:
        include:
        - test
  
steps:
- script: 'echo test'


- template: dummy-template.yml@SupDevA
  parameters:
    text: 'testing if the dummy templates is executed'
Run Code Online (Sandbox Code Playgroud)

Sup.Dev.A 是在分支上进行提交时应触发我的管道的存储库的名称test。但是当我在分支测试上创建提交时,触发器不会触发。

两个存储库都在同一个项目中,我错过了什么吗?该代码基于MS文档https://learn.microsoft.com/en-us/azure/devops/pipelines/repos/multi-repo-checkout?view=azure-devops#triggers

编辑:添加了 -template 部分,因此很明显,当手动触发时,管道会成功执行资源存储库中的模板

azure-devops azure-pipelines azure-pipelines-yaml

5
推荐指数
1
解决办法
1939
查看次数

Azure Pipelines 中的取消任务后

我们有一个场景,一旦我们手动取消 Azure DevOps 中的管道,我们需要终止特定进程 (exe)。我们想知道如何在 YAML 取消后触发任务来实现这一目标。

azure-devops azure-pipelines azure-pipelines-yaml

5
推荐指数
1
解决办法
2652
查看次数

从 Azure Pipeline .yaml 干净退出?

有没有比让脚本抛出错误更好/更干净/更惯用的方法来退出基于 .yaml 的 Azure Pipeline?

例如,这可行,但感觉很笨拙:

- task: PowerShell@2
  displayName: "Exit"
  inputs:
    targetType: 'inline'
    script: |
      throw 'Exiting';
Run Code Online (Sandbox Code Playgroud)

yaml exit azure-pipelines azure-pipelines-yaml

5
推荐指数
1
解决办法
7062
查看次数

在 Azure DevOps 中的不同项目之间共享变量

希望你们一切都好!

我需要问一个关于azure devops的问题,我已经阅读了文档,但是我没有找到解决这些疑问的方法

我有 X、Y 和 Z 项目,并在 X 项目中在管道 >> Libray中创建一组称为常规的变量,我希望与 Y 和 Z 管道共享,在配置该组时我启用了选项“允许访问所有管道”。

在 Y 和 Z 管道的 YAML 中,我进行了以下配置:**变量:

  • 组:一般**

运行管道时,他返回一个授权请求,甚至单击授权,根据下面的打印:

打印授权错误

There was a resource authorization issue: 
"An error occurred while loading the YAML build pipeline.  
 Variable group was not found or is not authorized for use.  
 For authorization details, refer to https://aka.ms/yamlauthz."
Run Code Online (Sandbox Code Playgroud)

我的问题是,有没有办法在不同用途的管道之间共享变量,如果有的话,您能给我发送一些可以帮助我配置这个的文档吗?

azure-devops azure-pipelines-yaml

5
推荐指数
2
解决办法
9270
查看次数

如何将单元测试失败消息显示为 .Net Core 中的构建错误?

我们使用 dotnet test --no-build 在 PR/CI 构建期间运行单元测试:

- task: DotNetCoreCLI@2
  ${{ if eq(parameters.shortName, '') }}:
    displayName: "Test ${{ parameters.name }}"
  ${{ if ne(parameters.shortName, '') }}:
    displayName: "Test ${{ parameters.shortName }}"
  inputs:
    command: "test"
    projects: ${{ parameters.path }}
    ${{ if eq(parameters.testFilter, '') }}:
      arguments: $(TestBinLogArg) -c $(BuildConfiguration) --no-build ${{ parameters.commonFlags }} ${{ parameters.moreTestArgs }} --filter ${{ parameters.unitTestFilter }}
    ${{ if ne(parameters.testFilter, '') }}:
      arguments: $(TestBinLogArg) -c $(BuildConfiguration) --no-build ${{ parameters.commonFlags }} ${{ parameters.moreTestArgs }} --filter (${{ parameters.unitTestFilter }})&(${{ parameters.testFilter }})
    publishTestResults: …
Run Code Online (Sandbox Code Playgroud)

unit-testing azure-devops azure-pipelines azure-pipelines-yaml

5
推荐指数
1
解决办法
409
查看次数

在模板作业中跨阶段使用管道变量

问题描述

我在尝试在另一个阶段使用在一个阶段中创建的变量时遇到了一些问题,并设法找到了各种新旧文章来描述如何完成此操作。识别新语法的最新文章/帖子

$[stageDependencies.{stageName}.{jobName}.outputs['{stepName}.{variableName}']

像这样使用:

variables:
  myVariable: $[stagedependencies.CreateStageVarStage.CreateStageVarJob.outputs['SetValueStep.VariableFromFirstStage']]
Run Code Online (Sandbox Code Playgroud)

在您需要使用作业模板之前,这非常有效。

我在网上找到的示例都没有涵盖模板的情况。他们只是演示了同一个 yaml 文件中的多个阶段如何获取该值。

语法取决于能否将表达式放入变量中。不幸的是,当您在作业中使用模板时,无法声明变量并将其作为参数传递,从而导致其无法求值。

- stage: UseJobTemplateStage
  displayName: 'Use Job Template Stage'
  dependsOn: CreateStageVarStage
  jobs:
  - template: templates/job-showstagevars.yml
    parameters:
      ValueToOutput: $[ stagedependencies.CreateStageVarStage.CreateStageVarJob.outputs['SetValueStep.VariableFromFirstStage'] ]
Run Code Online (Sandbox Code Playgroud)

在这个片段中,它按原样出现。该值不会被替换。

理论上,您可以将作业设置为使表达式存在于变量块中,但这种硬编码破坏了模板的主要优点之一。

相关文章

在 Azure DevOps Pipelines 中跨阶段共享变量
Azure DevOps 发行说明 - sprint 168

azure-devops azure-pipelines-yaml

5
推荐指数
1
解决办法
4560
查看次数

Bash 中的 Yaml 变量赋值问题

我在尝试在 yaml 文件中使用以下语法分配变量时遇到问题。以下代码取自 Microsoft 文档中定义变量的理解变量语法部分:

variables:
- name: one
  value: initialValue 

steps:
  - script: |
      echo ${{ variables.one }} # outputs initialValue
      echo $(one)
    displayName: First variable pass
  - bash: echo '##vso[task.setvariable variable=one]secondValue'
    displayName: Set new variable value
  - script: |
      echo ${{ variables.one }} # outputs initialValue
      echo $(one) # outputs secondValue
    displayName: Second variable pass
Run Code Online (Sandbox Code Playgroud)

具体来说,我发现问题出在语法注释'##vso[task.setvariable variable=one]secondValue' :我没有使用直接写入上面一行的字符串,我使用的是 bash 变量,其语法$variableName代替secondValue

问题是:

variables:
- name: one
  value: "initialValue" 

steps:
- task: Bash@3 …
Run Code Online (Sandbox Code Playgroud)

bash yaml azure-devops azure-pipelines azure-pipelines-yaml

5
推荐指数
1
解决办法
851
查看次数

YAML 隐式键需要位于单行上,隐式映射键需要后跟映射值

trigger:
- develop

pool:
  vmImage: windows-2019

- task: MSBuild@1
  inputs:
    solution: '**/*.sln'
- task: DownloadBuildArtifacts@1
  inputs:
    buildType: 'current'
    downloadType: 'single'
    itemPattern: '**/*.exe'
    downloadPath: '$(System.ArtifactsDirectory)'
Run Code Online (Sandbox Code Playgroud)

我在 Azure DevOps 和使用 VS Code 的 YAML 扩展中遇到此 YAML 错误。我正在尝试构建一个 Windows 服务,然后将 .exe 文件放在我可以下载的地方。

Azure 开发运营: azdo 截图 VS代码 vscode 截图

错误:

隐式键需要位于一行上,隐式映射键需要后跟映射值

yaml azure-devops azure-pipelines-yaml

5
推荐指数
1
解决办法
2万
查看次数