我正在尝试从当前构建管道和分支下载给定标签的最新可用工件,但出现以下错误。
##[error]No builds currently exist in the pipeline definition supplied.
Run Code Online (Sandbox Code Playgroud)
这是一个用于自动化测试的 3 阶段管道,具有构建、部署和运行测试阶段。在运行测试阶段,我尝试下载构建阶段中最新可用的工件,这可能是本次运行,也可能是较早的运行。
如果我保留标签选项,它将尝试从上次可用的运行中获取它,但当时可能尚未创建此工件,因此我使用标签来尝试过滤它。
- task: DownloadPipelineArtifact@2
displayName: 'Download Latest DLLs'
inputs:
source: 'specific'
project: $(System.TeamProjectId)
pipeline: $(System.DefinitionId)
runVersion: 'latestFromBranch'
runBranch: $(Build.SourceBranch)
tags: 'myBuildTag'
allowPartiallySucceededBuilds: true
artifact: myArtifactName
patterns: '**/IntegrationTests/**/*'
path: '$(Agent.TempDirectory)\myArtifactName'
continueOnError: true
Run Code Online (Sandbox Code Playgroud)
任何帮助,将不胜感激
azure-devops azure-pipelines azure-pipelines-tasks azure-pipelines-yaml
我有一个 devops yaml 管道,它运行 DotNetCoreCLI@2 任务来恢复、构建和测试。
如果一个或多个测试失败,我希望管道继续并发布为 DevOps 版本做好准备的输出。
最初,如果测试失败,整个管道执行将报告“构建失败”。在构建管道 yaml 的顶部添加以下内容后:
jobs:
- job: Build
continueOnError: true
Run Code Online (Sandbox Code Playgroud)
我现在得到“构建部分成功”。
但是,当我检查管道执行摘要页面时,我发现有 0 个工件:
即使测试失败,如何使管道发布?
为了完整起见,完整的 yaml 如下
stages:
- stage: Build
jobs:
- job: Build
continueOnError: true
pool:
name: Hosted Windows 2019 with VS2019
demands:
- msbuild
- visualstudio
variables:
solution: '**/*.sln'
projects: '**/Interfaces.Avaloq.Presentation.AzureFunctions.csproj'
unitTestProjects: '**/*Testing.Unit*/*.csproj'
integrationTestProjects: '**/*Testing.Integration*/*.csproj'
buildPlatform: 'Any CPU'
buildConfiguration: 'Debug'
steps:
- script: |
- task: DotNetCoreCLI@2
displayName: Restore Functions
inputs:
command: restore
projects: '$(projects)'
feedsToUse: config
nugetConfigPath: …Run Code Online (Sandbox Code Playgroud) yaml .net-core azure-devops azure-pipelines azure-pipelines-yaml
我在 YML 文件中创建了一个多阶段管道,包括构建阶段以及部署到开发、测试和生产。我希望有一个仪表板来显示部署状态以及部署到每个阶段的发布版本?我检查“部署状态”小部件,但它仅适用于发布选项。那么有人有经验支持我吗?
azure-devops azure-pipelines azure-pipelines-release-pipeline azure-pipelines-yaml azure-dashboard
我希望该PublishTestResults@2任务仅在前一个任务script(运行单元测试)实际运行时才运行。
condition: succeededOrFailed()thenPublishTestResults@2运行,即使上一步没有运行 - 我认为这就是目的condition: always()。always()和 和有什么区别succeededOrFailed()? # This step only runs if the previous step was successful - OK
- script: |
cd $(System.DefaultWorkingDirectory)/application/src
yarn test:unit --silent --ci --reporters=jest-junit
displayName: 'Jest Unit Tests'
env:
JEST_JUNIT_OUTPUT_DIR: $(System.DefaultWorkingDirectory)/testresults
JEST_JUNIT_OUTPUT_NAME: 'jest-junit.xml'
# This step ALWAYS runs - NO
# This step should ONLY run if the previous step RAN (success OR fail)
- task: PublishTestResults@2
displayName: …Run Code Online (Sandbox Code Playgroud) 我知道可以在 azure pipelines yml 中有条件地设置变量。请参阅https://learn.microsoft.com/en-us/azure/devops/pipelines/process/expressions?view=azure-devops#conditional-insertion
是否也可以有条件地使用变量组?
假设如果管道运行变量已设置或具有特定值,则管道应使用变量组。如果不是,则不得使用该组。
谢谢
我有两个环境,preprod 和 prod,它们几乎相同。
所以我创建了一个 yaml 文件,InfurstructionTemplate.yaml
parameters:
xxxx
jobs:
- job: provision_job
Run Code Online (Sandbox Code Playgroud)
我想在我的两个环境中使用这个模板,以下是我的想法:
stages:
- stage: PreProd Environment
- template: InfurstructureTemplate.yaml
- parameters:
xxxx
- stage: Prod Environment
- template: InfurstructureTemplate.yaml
- parameters:
xxxx
Run Code Online (Sandbox Code Playgroud)
这是使用 yaml 模板的正确方法吗?当我用谷歌搜索这个时,似乎模板处于阶段级别,并且您不能将其放在阶段上。
我有几个使用连接字符串的集成测试。该测试是从 azure devops 管道运行的,具有 yaml 定义(DotNetCoreCLI@2 任务)
这个 connstrings 曾经在 .runsettings 文件中设置,但我希望它们是秘密的,所以我将 conn 字符串移动到管道库,并标记为秘密。
同时,我已从运行设置文件中删除了机密,将参数值保留为空字符串。
所以现在,我只需在运行 dotnet test 时覆盖测试运行参数值...
通过阅读Microsoft的文档,我已经验证我可以在 Powershell 中完成此操作
dotnet test path\to\mytest.dll --logger trx --settings path\to\my.runsettings --% -- TestRunParameters.Parameter(name=\"Customer1.TestConnStr\", value=\"Id=xxx;Pass=yyy\") TestRunParameters.Parameter(name=\"Customer2.TestConnStr\", value=\"Id=xxx;Pass=yyy\")
Run Code Online (Sandbox Code Playgroud)
我还发现从 cmd 运行时不使用 --%,我认为这更适合我的 yaml 管道(在 Windows 代理上运行)。但是,我仍然无法在我的 yaml 任务中表达上述内容。我做了很多猜测,一个例子在这里:
- ${{ each project in parameters.projects }}:
- task: DotNetCoreCLI@2
displayName: Execute ${{ project }} integration tests
condition: succeededOrFailed()
inputs:
command: 'test'
projects: '$(Pipeline.Workspace)/IntegrationTests/*/*${{ project }}.Test.dll'
arguments: '--settings ${{ parameters.testRunSettingsFile }} -- TestRunParameters.Parameter(name=\"Customer1.TestConnStr\", value=\"${{ …Run Code Online (Sandbox Code Playgroud) 我正在尝试将 Azure Devops yml 管道中的 if else 条件与变量组一起使用。我正在尝试按照最新的 Azure Devops yaml pipeline build 来实现它。
以下是我的场景中 if else 条件的示例代码。test 是 my-global 变量组内的变量。
variables:
- group: my-global
- name: fileName
${{ if eq(variables['test'], 'true') }}:
value: 'product.js'
${{ elseif eq(variables['test'], false) }}:
value: 'productCost.js'
jobs:
- job:
steps:
- bash:
echo test variable value $(fileName)
Run Code Online (Sandbox Code Playgroud)
当执行上面的代码时,在 echo 语句中我们看不到文件名的任何值,即它为空,这意味着上面的 if else 条件都没有被执行,但是当我使用以下条件测试 if else 条件时。
- name: fileName
${{ if eq('true', 'true') }}:
value: 'product.js'
Run Code Online (Sandbox Code Playgroud)
文件名确实回显了正确的值,即product.js。所以我的结论是我无法正确引用变量组中的变量。因此,任何建议都会有所帮助并受到赞赏。谢谢!
最近,我将 Azure DevOps CI 管道从经典的先前系统更新为新的 yaml 文件。看来我在正确设置触发器方面遇到了一些问题。
让我先向您展示错误消息,然后会给您完整的 yaml 文件。
我已经阅读了官方文档,并尝试通过多种变体来解决此问题,但我不明白。似乎什么都不起作用。
和细节
和我的 yaml 文件:
# ASP.NET
# Build and test ASP.NET projects.
# Add steps that publish symbols, save build artifacts, deploy, and more:
# https://learn.microsoft.com/azure/devops/pipelines/apps/aspnet/build-aspnet-4
trigger:
branches:
include:
- master
- release/*
pool:
name: Hosted VS2017
demands:
- msbuild
- visualstudio
- vstest
name: 3.$(Date:yy).$(BuildID)
variables:
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
steps:
- task: NuGetToolInstaller@1
displayName: 'Use NuGet 4.4.1'
inputs:
versionSpec: 4.4.1
- task: NuGetCommand@2
displayName: 'NuGet restore' …Run Code Online (Sandbox Code Playgroud)