我试图让我的第二阶段运行,即使第一阶段的两个作业之一失败,但我无法使用作业状态检查功能让它按预期工作succeeded('JobName')。
在下面的 YAML 管道中,我希望只要Job1成功,即使Job2失败,它也会运行Stage2,但事实并非如此:
stages:
- stage: Stage1
jobs:
- job: Job1
steps:
- pwsh: echo "Job1"
- job: Job2
steps:
- pwsh: write-error "Job2 error"
- stage: Stage2
condition: succeeded('Job1')
jobs:
- job: Job3
steps:
- pwsh: echo "Job3"
Run Code Online (Sandbox Code Playgroud)
即使Job2失败,只要 Job1 成功,如何让Stage2运行?
使用always()将使Stage2始终运行,但我希望它取决于Job1的成功状态,而不管Job2状态如何。
相关文档:
最近,我从传统的图形部署管道迁移到可重用的 yaml 构建和部署管道。yaml 构建管道正在交付在部署管道中使用的(多个)工件。
当运行部署管道(使用参数和设置)、yaml 模板等时...我看到,当管道完成时,会有如下描述:
<build id> - <部署管道所在的最新签入消息>
由于部署管道与构建管道不在同一存储库中,因此消息/描述与实际状态无关。
是否可以更改这些消息/描述,以便当我显示管道的运行时,我可以看到对我来说重要的内容,而不是上次签入消息?
谢谢,巴特
管道中是否有任何变量(环境、系统、资源)保存 foo_repo 和 bar_repo 的值?我正在寻找路径(just/code/ foo和 just/code/ bar),因为我不想在配置中重复它。
$(Build.Repository.Name)将返回存储库名称,self但其他存储库呢?
resources:
repositories:
- repository: foo_repo
type: git
name: just/code/foo
- repository: bar_repo
type: git
name: just/code/bar
stages:
- checkout: foo_repo
- checkout: bar_repo
- checkout: self
Run Code Online (Sandbox Code Playgroud) 我正在使用 Azure DevOps 构建 python 轮。我想让它尽可能通用,以便团队中的每个人都可以使用相同的管道来构建自己的 python 轮并将它们部署在一些 databricks 工作区中。为此,我需要知道构建管道输出中的文件名是什么,以便在我的发布管道中使用它。
目前在这种情况下,该文件是保存在构建管道输出中的 python 轮。我在管道 yaml 中使用以下代码在构建管道输出和 Azure 工件源中发布它。
- task: PublishBuildArtifacts@1
inputs:
pathToPublish: '$(Build.ArtifactStagingDirectory)'
artifactName: dfordbx
- task: UniversalPackages@0
displayName: Publish
inputs:
command: publish
publishDirectory: $(Build.ArtifactStagingDirectory)/dist/
vstsFeedPublish: 'MyProject/py_artifacts_1732'
vstsFeedPackagePublish: $(packageBuildName)
Run Code Online (Sandbox Code Playgroud)
构建管道运行结束后,dist文件夹中会出现一个wheel文件。我需要得到这个轮子的名称。对于我自己的代码,我当然知道名字。但是当其他人为他们的代码运行管道时,我不清楚这一点。我需要在我的发布管道中获取这个名称。
换句话说,我正在我的 yaml 文件中寻找一种方法来获取以下结构中的“py_sample_package-0.6.5-py3-none-any.whl”名称:
通过选择已发布的工件:
获取文件:
突出显示的部分是我需要进入管道的部分。谢谢。
我一直在关注这个 Microsoft 文档,并在 YAML 中创建了一个发布管道,一切正常。
我有一个条件步骤也可以正常工作:
- ${{ if contains(parameters.environment, 'PROD') }}:
Run Code Online (Sandbox Code Playgroud)
现在需求发生了一些变化,相同的条件步骤需要检查多个值。
因为如果这包含 PROD 或 UAT 则为 true。
我一直在阅读不同的地方并尝试了以下内容但没有运气:
- ${{ or(if contains(parameters.environment, 'PROD'), if contains(parameters.environment, 'UAT')) }}:
- ${{ if contains(parameters.environment, 'PROD', 'UAT') }}:
Run Code Online (Sandbox Code Playgroud)
知道这是否可能以及如何解决吗?非常感激
我有一个 Azure DevOps 系统已启动并正在运行,并具有根据 PR 以及夜间计划运行管道的触发器,如下所示:
trigger:
batch: true
branches:
include:
- main
- release/*
- pre-release/*
schedules:
- cron: "0 0 * * *"
displayName: Daily midnight build
branches:
include:
#- main
#- release/*
- pre-release/*
always: false
Run Code Online (Sandbox Code Playgroud)
有没有办法让工作知道这是从 Schedule 而不是 PR 调用的?我想添加另一系列更严格的测试,但只是在夜间进行,作为日常工作的一部分。
也许设置一个可以稍后在管道中检查的变量。
我们正在使用 Microsoft 托管代理来运行应用程序自动化测试场景的构建管道。我们想要实现的是,通过自动化程序下载文件(从无头 Chrome 浏览器),然后导航到下载路径并打开它。
如何找到代理内下载文件的路径?
我想在分支触发器和计划触发器的构建管道中运行不同的作业。
branch trigger => run job 1
scheduled trigger => run job 2
有什么方法可以区分触发器吗?这样我就会根据这种不同的条件来运行我的工作。
我的思考过程
我正在考虑在计划触发期间设置变量,因此我可以在工作条件评估中使用该变量。但我无法设置变量。
# Sample azure-build-pipeline.yml file
variables:
# by default the variable is false
isScheduledTrigger: false
trigger:
- develop
- master
schedules:
- cron: "0 0 * * *"
displayName: Daily midnight build
branches:
include:
- develop
always: true
# somewhere here i want to set the isScheduledTrigger variable to TRUE
jobs:
- job: Branch trigger job
condition: or(eq(variables['Build.SourceBranchName'], 'develop'),eq(variables['Build.SourceBranchName'], 'master'))
steps:
# Multiple …Run Code Online (Sandbox Code Playgroud) azure azure-devops azure-pipelines-build-task azure-pipelines azure-pipelines-yaml
我创建了主项目
https://dev.azure.com/GilbertHsu/pipeline_test
以 3 个项目作为主项目中的子模块
https://dev.azure.com/GilbertHsu/otherProjectA
https://dev.azure.com/GilbertHsu/otherProjectB
https://dev.azure.com/GilbertHsu/otherProjectC
其中使用每个项目的默认设置。在管道 azure-pipelines.yml 中:
jobs:
- job: MacOS
strategy:
matrix:
mac:
imageName: 'macOS-10.14'
pool:
vmImage: $(imageName)
steps:
- template: azure-pipelines-ci/macos.yml
Run Code Online (Sandbox Code Playgroud)
在 azure-pipelines-ci/macos.yml 中:
# macOS-specific:
# ref. https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=azure-devops&tabls=schema%2Cparameter-schema&tabs=schema%2Cparameter-schema#checkout
steps:
- checkout: self
clean: true
path: pipeline-test
submodules: true
Run Code Online (Sandbox Code Playgroud)
.gitmodules:
[submodule "otherProjectA"]
path = otherProjectA
url = ../../../otherProjectA/_git/otherProjectA
[submodule "otherProjectB"]
path = otherProjectB
url = ../../../otherProjectB/_git/otherProjectB
[submodule "otherProjectC"]
path = otherProjectC
url = ../../../otherProjectC/_git/otherProjectC
Run Code Online (Sandbox Code Playgroud)
当我触发管道时,它总是失败
Submodule 'otherProjectA' (https://GilbertHsu@dev.azure.com/GilbertHsu/otherProjectA/_git/otherProjectA) registered for path 'otherProjectA'
Submodule 'otherProjectB' …Run Code Online (Sandbox Code Playgroud) git azure-devops azure-pipelines-build-task azure-pipelines azure-pipelines-yaml
在构建和部署 docker image.Getting Unexpected value 'Steps' 在第 27 行之前,我试图将视频文件从 GPM 复制到 app/dist/asset/images 文件夹。
如果我删除了复制视频文件的步骤,YML 文件就可以正常工作。
azure-pipelines.yml
trigger:
branches:
include: ['*']
pool:
name: Default
# templates repo
resources:
repositories:
- repository: templates
type: git
name: comp.app.common.devops-templates
ref: master
# Global Variables
variables:
# necessary variables defined in this template
- template: azure-templates/vars/abc-vars.yml@templates
- name: dockerRepoName
value: 'docker-it/library/xyz'
# needed for k8 deployment
- name: helmReleaseName
value: xyz
stages:
- steps:
- bash: 'curl -o aa.mp4 https://gpm.mmm.com/endpoints/Application/content/xyz/bb.mp4'
workingDirectory: '$(System.DefaultWorkingDirectory)/_hh_app/drop/app/dist/assets/images'
displayName: 'Download Assets' …Run Code Online (Sandbox Code Playgroud)