希望有人能帮我解决这个问题,回顾一下我的 git 日志,我现在已经尝试了 14 种不同的方法来尝试让它发挥作用。这是场景:
我在 UI 中创建了一个名为deploy_custom_env“用户可以在运行时设置变量”的变量。我将其初始化为“默认”,但我希望用户在开始手动运行时覆盖它。
我试图在condition我的一些管道阶段中使用这个变量。
我尝试过很多很多不同的事情。这里有些例子:
第一的:
condition: ne(variables.deploy_custom_env, 'default')
Run Code Online (Sandbox Code Playgroud)
和
condition: ne('${{ variables.deploy_custom_env }}', 'default')
Run Code Online (Sandbox Code Playgroud)
和
variables:
- name: isCustomEnv
value: ne[($(deploy_custom_env), 'default')]
Run Code Online (Sandbox Code Playgroud)
乃至
variables:
- name: isCustomEnv
value: ne[(variables.deploy_custom_env, 'default')]
Run Code Online (Sandbox Code Playgroud)
有趣的是,当尝试使用上述内容时,以下两种情况都会导致跳过阶段:
condition: eq(variables.isCustomEnv, true)
condition: eq(variables.isCustomEnv, false)
Run Code Online (Sandbox Code Playgroud)
这是否意味着它既是 又是true和false?(当然,我在开玩笑:我不知道这实际上会评估什么。)我也尝试过启用System.debug和检查“启用系统诊断”,但是当我的阶段被跳过时,我真的看不出这些是什么变量正在评估。
我将不胜感激任何可以帮助我解决这个问题的建议或文档。这肯定是人们做的事情吗?另外,建议任何来自 Azure 的人阅读:我很乐意在文档中的某个地方看到这个示例。
我查看了以下内容来尝试回答这个问题:
在后者中,我看到了编译时和运行时之间的区别,并附有以下注释:
运行时和编译时表达式语法之间的区别主要在于可用的上下文。在编译时表达式 (${{ }}) 中,您可以访问参数和静态定义的变量。在运行时表达式 ($[ ]) 中,您可以访问更多变量,但不能访问参数。
这似乎是相关的,但我如何将其转化为在我的condition系统中有效的东西?
我已经将初始的图像拆分出来azure-pipelines.yml以使用模板、迭代等...无论出于何种原因,尽管使用了latest标签和/或imagePullPolicy: Always.
另外,我基本上有两个PR管道Release:
PR当提交 PR 请求合并到 时触发production。它会自动触发此管道来运行单元测试、构建 Docker 映像、进行集成测试等,然后如果一切都通过,则将映像推送到 ACR。PR管道通过并且 PR 获得批准时,它会被合并到其中,production然后触发Release管道。这是我的部署清单之一的示例k8s(管道说明unchanged何时应用这些清单):
apiVersion: apps/v1
kind: Deployment
metadata:
name: admin-v2-deployment-prod
namespace: prod
spec:
replicas: 3
selector:
matchLabels:
component: admin-v2
template:
metadata:
labels:
component: admin-v2
spec:
containers:
- name: admin-v2
imagePullPolicy: Always
image: appacr.azurecr.io/app-admin-v2:latest
ports:
- containerPort: 4001
---
apiVersion: v1
kind: Service
metadata:
name: admin-v2-cluster-ip-service-prod
namespace: …Run Code Online (Sandbox Code Playgroud) 当我尝试在 Azure Devops 中使用发布管道进行部署时,我遇到了锁定 DLL 文件的问题。
错误的截图是:
输出为文本:
2021-03-31T17:43:18.2626492Z ##[error]Error Code: ERROR_FILE_IN_USE
More Information: Web Deploy cannot modify the file 'Microsoft.Data.SqlClient.SNI.x64.dll' on the destination because it is locked by an external process. In order to allow the publish operation to succeed, you may need to either restart your application to release the lock, or use the AppOffline rule handler for .Net applications on your next publish attempt. Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_FILE_IN_USE.
Error count: 1.
Run Code Online (Sandbox Code Playgroud)
该问题似乎是由错误处置的 .NET 资源引起的。(例如:非托管 SqlConnection)无论如何,我无法更改源代码。
这是我的发布管道。
这是我的问题: …
azure locked-files azure-devops azure-pipelines-release-pipeline
我在使用自托管 Windows 代理时遇到以下错误。
##[错误]无法找到可执行文件:“bash”。请验证文件路径是否存在,或者是否可以在 PATH 环境变量指定的目录中找到该文件。还要验证该文件是否具有有效的可执行文件扩展名。
filename这是我的管道 - 任务目标是从整体中获取单独的内容filePath并将其用于filename进一步的任务。
trigger:
- master
parameters:
project: './test/abc/UnitTest.proj'
pool: self-hosted-windows
steps:
- task: Bash@3
inputs:
targetType: 'inline'
script: |
input="${Parameters.project}"
file_name_with_ext="${input##*/}"
file_only="${file_name%.*}"
echo "File : $file_only"
Run Code Online (Sandbox Code Playgroud) 我不明白有关 Git 身份验证如何在 Azure Devops Yaml 管道中工作的一点。
我做什么
我运行这个管道:
resources: repositories:
- repository: TutoDeployin Tuto-DeployBuild repository
ref: main
type: git
name: Tuto-Deploy
jobs:
- job: Build
steps:
- checkout: self
clean: true
persistCredentials: true
- checkout: TutoDeploy
clean: true
persistCredentials: true
- task: Powershell@2
inputs:
pwsh: true
filePath: '.\tuto-deploybuild\CI\build.ps1'
arguments: "-repositoryName tuto-deploy"
Run Code Online (Sandbox Code Playgroud)
它本质上运行位于 Tuto-Deploy 中的 PowerShell 脚本:
Param(
$repositoryName
)
cd "$($env:Build_SourcesDirectory)/$repositoryName"
$version = @{
numero = 0
date = Get-Date
}
$path = "$env:Build_SourcesDirectory" + "/$repositoryName/version"
$versionFile = "$path/version.json" …Run Code Online (Sandbox Code Playgroud) 我试图从嵌套参数中获取值,如下所示:
parameters:
- name: myObject
type: object
default:
foo: FOO
things:
- one
nested:
one: apple
count: 3
Run Code Online (Sandbox Code Playgroud)
所以我期望写这样的东西${{ parameters.myObject.foo }}或${{ parameters.myObject.nested.one }}检索一个值。
还有一个循环遍历列表对象的示例,如下所示:
- name: listOfStrings
type: object
default:
- one
- two
steps:
- ${{ each value in parameters.listOfStrings }}:
- script: echo ${{ value }}
Run Code Online (Sandbox Code Playgroud)
这就是为什么我试图以这种方式获得价值,但它对我来说也不起作用:
- name: myObject
type: object
default:
foo: FOO
nested:
one: apple
steps:
- ${{ each value in parameters.myObject }}:
- script: echo ${{ value.foo }}
Run Code Online (Sandbox Code Playgroud)
不幸的是,微软没有在文档中提供示例https://learn.microsoft.com/en-us/azure/devops/pipelines/process/templates?view=azure-devops …
有没有办法查看或获取我在 Azure DevOps 中创建的服务连接的服务连接 ID?
我在创建的 yaml 管道中需要它们。例如,您在下面看到的 dockerRegistryServiceConnection 在 docker@02 任务中用于设置 containerRegistry(如果您看到下面的内容)。
variables:
- name: vmImageName
value: ubuntu-latest
# Container registry service connection established during pipeline creation
- name: dockerRegistryServiceConnection
value: 'd072f8f7-fag1-asdf-467e-7fd5jfr5gjh6' # This is not a true id
- name: imageRepository
value: 'globoticket.services.discount'
- name: containerRegistry
value: 'reacrtrialsregistry.azurecr.io'
- name: dockerfileFolderPath
value: 'src/Services/GloboTicket.Services.Discount'
- name: tag
value: '$(Build.BuildId)'
name: $(date:yyyyMMdd)$(rev:.r)
stages:
- stage: Build
jobs:
- job: buildWebApp
displayName: Build Release pipeline for Discount Service on Master branch …Run Code Online (Sandbox Code Playgroud) 我想使用 azure devops cli 来使用 WIQL 或保存的查询来查询工作项。我尝试在 azure cli 文档和azboard中查找,但它通过工作项 ID 进行查询。谁能告诉我如何使用 az cli 查询工作项。
实际的
部署时发布管道失败
预期的
部署不会失败
根本原因
文件“Microsoft.Data.SqlClient.SNI.x86.dll”被外部进程锁定,即使“使应用程序脱机标志”设置处于打开状态
解决方法
手动回收应用程序池并重新运行失败的部署。
当使用“recycleAppPool”应用“Action IIS Application Pool”设置时,尝试自动回收也失败。
信息
错误信息
Error Code: ERROR_FILE_IN_USE More Information: Web Deploy cannot modify the file 'Microsoft.Data.SqlClient.SNI.x86.dll' on the destination because it is locked by an external process.
In order to allow the publish operation to succeed, you may need to either restart your application to release the lock, or use the AppOffline rule handler for .Net applications on your next publish attempt.
Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_FILE_IN_USE. Error: The process cannot …Run Code Online (Sandbox Code Playgroud) yaml continuous-deployment azure-devops azure-pipelines-release-pipeline microsoft-data-sqlclient
我正在尝试使用az pipelines管道中的 cli 更新变量组中的变量,我创建了一个 PAT 并将其传递到管道,其工作正常。但我使用默认的,例如$(System.AccessToken)它能够列出变量组中的变量,但无法更新变量组。其曰
错误:您无权对变量组执行此操作。变量组管理员应将您添加到管理员角色。##[错误]脚本失败,退出代码:1
经过一番搜索,我发现我需要将 Project Collection Build Service ( name ) 添加为变量组中的管理员,然后重试。我已经添加了这一点,但我仍然遇到同样的错误。有什么建议么?
我使用的是经典管道,这是从管道导出的任务。
steps
- task: AzureCLI@2
displayName: 'Azure CLI '
inputs:
azureSubscription: 'sc'
scriptType: pscore
scriptLocation: inlineScript
inlineScript: |
az extension add --name azure-devops
az pipelines variable-group variable list --group-id id --org "orgname" --project "projectname"
az pipelines variable-group variable update --group-id id --name apim-service-name --value $(str_tf_module_containername) --org "orgname" --project "projectname"
env:
AZURE_DEVOPS_EXT_PAT: $(System.AccessToken)
Run Code Online (Sandbox Code Playgroud) azure azure-cli azure-devops azure-pipelines azure-pipelines-yaml
azure-devops ×10
azure ×4
azure-cli ×2
azure-pipelines-release-pipeline ×2
yaml ×2
azure-aks ×1
bash ×1
git ×1
kubernetes ×1
locked-files ×1