我正在使用 azure_pipeline.yaml 配置设置 Github 项目的分支。这似乎对社区中的其他人都适用,但是当我设置管道时,它给了我以下异常:
A task is missing. The pipeline references a task called 'Cache'. This usually indicates the task isn't installed, and you may be able to install it from the Marketplace: https://marketplace.visualstudio.com. (Task version 2, job 'compile_ci_build', step ''.)
A task is missing. The pipeline references a task called 'Cache'. This usually indicates the task isn't installed, and you may be able to install it from the Marketplace: https://marketplace.visualstudio.com. (Task version 2, job 'test_ci_build', step ''.)
A …Run Code Online (Sandbox Code Playgroud) 我有两个存储库,第一个位于 Azure DevOps 上,第二个位于 GitHub 上。我想更新 GitHub 存储库,以便在两个存储库上拥有相同的代码。如何在不手动复制源代码的情况下做到这一点?
我有一个包含 Dockerfile 和其他代码的存储库。无论发生什么变化,我们都希望运行某些步骤,但只想在发生变化docker build时运行作业。**/Dockerfile
我已经查看了条件文档和表达式文档,但我不清楚如何(如果可能的话)如何组合这些文档或以其他方式实现所需的结果。
我意识到在bash(例如git rev-list...和git diff --name-only <previous_commit>..HEAD | grep <pattern>)中这是可能的,但这有点麻烦,并且它仍然在 Azure Pipelines 中显示作业已运行,只是短路了。理想情况下,它会(适当地)表明该作业被全部跳过。
我还意识到 Docker 部分和代码部分可以位于具有单独构建触发器的单独存储库中,但如果可能的话,希望将它们放在同一个存储库中。
在 AzureDevOps 管道中,我有用 Bash/Powershell 脚本编写的任务。
如果我选择使用Inline scrpit,我可以直接使用预定义的变量,例如
cd $(Build.SourcesDirectory)
Run Code Online (Sandbox Code Playgroud)
但是,如果我选择使用文件路径来调用脚本,则无法直接在脚本文件中使用预定义变量。我必须将预定义变量传递给任务定义中的环境变量,如下例所示,这样我就可以在 script.sh 中使用 $SourceDirectoy,

有没有更好的方法在脚本中直接调用预定义变量?
我正在尝试学习 azure devops yaml 并使用模板。
这是我的管道 yaml(基本上想要设置参数并调用模板文件):
trigger:
branches:
include:
- master
paths:
exclude:
- YAML/*
extends:
template: azure-pipeline.yaml
parameters:
MergeSprintToMaster: false
Run Code Online (Sandbox Code Playgroud)
这是我的模板文件 azure-pipeline.yaml,其中包含所有公共内容:
parameters:
- name: MergeSprintToMaster # name of the parameter; required
type: boolean # data type of the parameter; required
default: false
pool:
name: Azure Pipelines
vmImage: 'windows-latest'
demands:
- msbuild
- visualstudio
- vstest
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
steps:
- task: AzureCLI@2
Run Code Online (Sandbox Code Playgroud)
我收到一条验证错误,显示 /YAML/azure-pipeline.yaml (Line: 11, Col: 1): Unexpected value 'pool'
我尝试使用 …
我必须使用此 API:PATCH https://vsaex.dev.azure.com/{organization}/_apis/userentitlements/{userId}向组织中的所有用户授予对某些项目的读取权限。我能够成功调用此 API,但我不知道如何为用户获取正确的 GUID。(为了为用户获取正确的 Guid,我使用 Fiddler 来监视请求)。
当我使用此 API 时,(GET https://vssps.dev.azure.com/{organization}/_apis/graph/users?api-version=6.0-preview.1)我获得了组织的所有用户,但在列表中没有 userId,我只有 originId,它是来自 AAD 的 guid,我无法使用该信息更新用户。
我也尝试使用描述符字段,但没有成功。有人知道如何获取这个特定的 userId 吗?
我通过此 API 获得的用户列表示例:
{
"count": 133,
"value": [{
"subjectKind": "user",
"metaType": "member",
"directoryAlias": "COD0001",
"domain": "10a83eaa-05c5-4b22-a201-63cddba4fe8c",
"principalName": "bidon.person@example.com",
"mailAddress": "bidon.person@example.com",
"origin": "aad",
"originId": "7c3408d6-62f4-43ff-bdbe-5be97000ba30",
"displayName": "Personne bidon",
"_links": {
"self": {
"href": "https://vssps.dev.azure.com/BIDON/_apis/Graph/Users/aad.ZDYzNzUwNzctNWJjYy03ZTkzLWIzZGUtMDEzNTdhM2JiMDIx"
},
"memberships": {
"href": "https://vssps.dev.azure.com/BIDON/_apis/Graph/Memberships/aad.ZDYzNzUwNzctNWJjYy03ZTkzLWIzZGUtMDEzNTdhM2JiMDIx"
},
"membershipState": {
"href": "https://vssps.dev.azure.com/BIDON/_apis/Graph/MembershipStates/aad.ZDYzNzUwNzctNWJjYy03ZTkzLWIzZGUtMDEzNTdhM2JiMDIx"
},
"storageKey": {
"href": "https://vssps.dev.azure.com/BIDON/_apis/Graph/StorageKeys/aad.ZDYzNzUwNzctNWJjYy03ZTkzLWIzZGUtMDEzNTdhM2JiMDIx"
},
"avatar": {
"href": "https://dev.azure.com/BIDON/_apis/GraphProfile/MemberAvatars/aad.ZDYzNzUwNzctNWJjYy03ZTkzLWIzZGUtMDEzNTdhM2JiMDIx"
}
},
"url": "https://vssps.dev.azure.com/BIDON/_apis/Graph/Users/aad.ZDYzNzUwNzctNWJjYy03ZTkzLWIzZGUtMDEzNTdhM2JiMDIx",
"descriptor": …Run Code Online (Sandbox Code Playgroud) 我正在尝试在天蓝色管道中运行 cypress 测试。为此,我需要在运行测试之前运行“dotnet run”。我有一个管道任务成功运行“dotnet run”命令,但因为它永远不会退出,所以管道永远不会进入下一个任务。有没有办法使用 YAML 使管道作业进入下一步,同时保持“dotnet run”命令运行?
如果这不可能,是否有办法在 Azure 管道中运行 cypress 测试时在后台运行“dotnet run”?
这是我的 YAML 代码的一部分:
- task: DotNetCoreCLI@2
displayName: 'dotnet run'
inputs:
command: run
projects: Api/Api.csproj
arguments: '--configuration Release --verbosity normal'
- script: 'npx cypress verify' // pipeline job never gets to this step
displayName: 'Verify Cypress Can Run'
failOnStderr: true
Run Code Online (Sandbox Code Playgroud) 在我们的 Git 项目中,我们在 .gitmodules 中定义了以下内容
[submodule "DBPkg"]
path = DBPkg
url = https://MainCo@dev.azure.com/MainCo/OurProject/_git/DBPkg
Run Code Online (Sandbox Code Playgroud)
构建 Azure Pipeline 时,在“获取源”管道步骤(我使用“Azure Repos Git”)中,我启用了子模块的检出
在我们的项目设置中,我还做了以下配置...
然而,在构建项目时,当尝试使用以下命令签出子模块时,它会死掉......
2020-10-16T20:29:44.9912145Z HEAD is now at e06abce Modified docker file to remove unnecessary container name.
2020-10-16T20:29:44.9913415Z ##[command]git submodule sync
2020-10-16T20:29:44.9920288Z ##[command]git -c http.https://MainCo@dev.azure.com.extraheader="AUTHORIZATION: bearer ***" submodule update --init --force
2020-10-16T20:29:44.9923206Z Submodule 'DBPkg' (https://MainCo@dev.azure.com/MainCo/OurProject/_git/DBPkg) registered for path 'DBPkg'
2020-10-16T20:29:44.9923842Z Cloning into '/home/vsts/work/1/s/DBPkg'...
2020-10-16T20:29:44.9924246Z remote: TF401019: The Git repository with name or identifier DBPkg does not exist or you do not have …Run Code Online (Sandbox Code Playgroud) 几天前,我们的生产发布管道开始失败,并出现以下错误:
2020-10-17T00:14:13.1233435Z Omitting next output lines...
2020-10-17T00:14:13.1234108Z Error: ENOENT: no such file or directory, stat '/home/site/wwwroot/node_modules/.bin/semver'
2020-10-17T00:14:13.1234825Z An error has occurred during web site deployment.
2020-10-17T00:14:13.1235127Z Kudu Sync failed
2020-10-17T00:14:13.1235451Z \n/opt/Kudu/Scripts/starter.sh "/home/site/deployments/tools/deploy.sh"
2020-10-17T00:14:13.1265401Z ##[error]Failed to deploy web package to App Service.
2020-10-17T00:14:13.1276348Z ##[error]Error: Package deployment using ZIP Deploy failed. Refer logs for more details.
2020-10-17T00:14:13.6429241Z Successfully updated deployment History at https://{omitted}.scm.azurewebsites.net/api/deployments/{omitted}
2020-10-17T00:14:13.6510314Z ##[section]Finishing: Deploy Azure App Service
Run Code Online (Sandbox Code Playgroud)
管道将成功完成所有测试/脚本+发布删除工件。发布过程启动,但在部署步骤失败,并出现上述错误。
我尝试回滚到成功部署的最后一个工作提交,但在此步骤中它仍然会失败。
我花了几天时间试图解决这个问题,但没有任何运气。有什么想法会导致这样的事情随机开始发生吗?
如果有助于调试的话,我可以提供有关我们堆栈的其他信息。
编辑
我当前的应用程序设置:
azure-pipelines.yml
trigger:
- master
variables: …Run Code Online (Sandbox Code Playgroud) 我使用 .NET Core 3.1.0 开发了 WebAPI 项目,并使用 XUnit 开发了集成测试。
我在 Azure DevOps CI Pipeline (azure-pipelines.yaml) 中添加了以下任务来运行集成测试项目。
- task: DotNetCoreCLI@2
displayName: 'Run API integration tests - $(buildConfiguration)'
inputs:
command: 'test'
arguments: '--configuration $(buildConfiguration)'
publishTestResults: true
projects: '**/IntegrationTests/IntegrationTests.csproj'
Run Code Online (Sandbox Code Playgroud)
我在管道执行期间收到以下错误。如何解决此错误?
##[error] 错误:进程 '/usr/bin/dotnet' 失败,退出代码为 1
##[警告].NET 5 与较旧的 Nuget 版本(<=5.7)存在一些兼容性问题,因此如果您使用较旧的 Nuget 版本(而不是 dotnet cli)进行还原,则使用 dotnet cli 命令(例如 dotnet build)依赖于这种恢复的包可能会失败。要减轻此类错误,您可以:(1) - 使用 dotnet cli 进行还原,(2) - 使用 Nuget 5.8 版进行还原,(3) - 使用 global.json 使用较旧的 sdk 版本 (<=3) 进行构建
信息:Azure Pipelines 托管代理已更新,现在包含 .Net 5.x SDK/Runtime …
azure-pipelines ×10
azure-devops ×7
azure ×4
git ×2
yaml ×2
azure-repos ×1
deployment ×1
github ×1
node.js ×1
permissions ×1