我使用 Azure DevOps 有一段时间了,并且在制作 Build Pipeline 时我总是使用经典编辑器 GUI。现在我正在尝试使用 YAML 创建新管道。一切顺利,构建成功。但是,与使用经典编辑器的管道相比,我注意到结帐任务中的不同行为。在两个管道中,“获取源”选项卡中使用的设置是相同的(请参见下面的屏幕截图)
在经典编辑器管道的情况下,签出任务删除并重新创建$(Agent.BuildDirectory).这将导致为每个构建初始化一个新的本地 Git 存储库。但是,对于 YAML 管道,结帐任务仅执行 agit clean -ffdx并仅删除源目录。如何解决 YAML 管道的这个问题?
YAML 管道日志:
经典编辑器管道日志:
git devops azure-devops azure-pipelines azure-yaml-pipelines
我有一个yaml。我需要根据另一个任务将服务连接传递给脚本/模板,该任务检索所有必需的订阅。问题是:我可以将动态值传递给服务连接吗?它给我编译时错误。
我的代码如下:
trigger: none
pr: none
parameters:
- name: AzureSubscription
type: object
default:
xxx:
Sub: xxx
yyy:
Sub: yyy
jobs:
- job: Updating
condition: succeeded()
pool:
vmImage: "windows-latest"
strategy:
maxParallel: 10
matrix: ${{ parameters.AzureSubscription }}
steps:
- task: AzurePowerShell@5
displayName: Tes
inputs:
azureSubscription: 'zzz'
ScriptType: 'InlineScript'
Inline: |
Write-Output "subcriptionList ---- $(Sub)"
FailOnStandardError: true
azurePowerShellVersion: 'LatestVersion'
pwsh: true
- task: AzurePowerShell@4
displayName: Updating
inputs:
**azureSubscription: ${{ sub }}** # here it is giving me error?
ScriptType: 'FilePath'
ScriptPath: '$(System.DefaultWorkingDirectory)/Foundation/xxxxx.ps1'
azurePowerShellVersion: …Run Code Online (Sandbox Code Playgroud) 我尝试在 Azure Yaml Pipelines 中运行 PowerShell 脚本,但收到此错误:
##[error]The term 'D:\a\1\s\myPowershellFile.ps1' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
Run Code Online (Sandbox Code Playgroud)
代码:
jobs:
- deployment: Deploy
displayName: Deploy
environment: $(myEnvironment)
pool:
vmImage: 'windows-latest'
strategy:
runOnce:
deploy:
steps:
- task: AzurePowerShell@5
displayName: 'Run Powershell script'
inputs:
azureSubscription: $(azureConnectionName)
scriptType: filePath
scriptPath: './myPowershellFile.ps1'
azurePowerShellVersion: latestVersion
Run Code Online (Sandbox Code Playgroud)
该文件被推送到触发构建的分支的存储库。$(Pipeline.Workspace) …
azure azure-powershell azure-devops azure-pipelines azure-yaml-pipelines
即使我设置了 System.Debug=True,除了“作业被跳过”之外,我没有得到其他信息。字面意思就是这四个字。
我在 Azure Devops 上创建了一个 YAML-Release 管道,它基本上运行这些作业:
为了测试行为,我首先只运行前两个作业并部署到 TEST。现在我想部署到 STAGE,但似乎只有当我从头开始/创建新版本时,管道才起作用。但是我现在想要做的是将已经存在的版本从 TEST 部署到 STAGE。当我尝试通过重新运行管道来做到这一点时,Azure 只会跳过所有步骤。为什么会这样?如何避免这种情况并重新运行管道?我没有设置任何条件。
编辑附加信息:
管道结构
trigger:
- release/*
variables:
...
resources:
- repo: self
pool:
vmImage: $(vmImageName)
stages:
- stage: build_release
displayName: 'awesome build'
condition: contains(variables['Build.SourceBranchName'], 'release/')
jobs:
- job: build_release
steps:
...
- stage: deploy_test
displayName: 'awesome test deploy'
jobs:
- deployment: deploy_test
environment: 'test'
strategy:
runOnce:
deploy:
steps:
...
- stage: deploy_stage
displayName: 'awesome stage deploy'
jobs:
- deployment: deploy_stage
environment: 'stage'
strategy: …Run Code Online (Sandbox Code Playgroud) 我们的服务连接证书上周到期,因此我们创建了一个新的服务连接,从那时起,我们的 yaml 管道中的部署阶段将不会运行,UI 报告取消状态,当我进入日志时,我看到的就是这些:
我启用了系统诊断,但没有任何结果。
以前有人遇到过这种情况吗?
我尝试删除并创建服务连接,但没有成功
我的 Azure DevOps 管道使用来自两个不同存储库的 yaml 模板,其配置如下。
模板存储库作为根模板中的资源被引用。我没有找到只检出模板存储库一次然后在所有管道阶段使用模板和脚本的方法。现在,我必须在需要使用其他模板或脚本的每个阶段手动克隆模板存储库。在每个阶段结束时,Azure Devops 会清除克隆的存储库。是否有一种简单的方法可以只检出模板 repo 一次,或者以其他方式从子阶段引用其资源?