Features
用于预声明资源的“uses”语句
当管道在代理上运行作业时,该代理会获得访问令牌,以调用 Azure Pipelines REST API 并下载存储库等资源。 对于 YAML 管道,我们最近添加了一个设置,以限制令牌至仅在作业中实际使用的存储库。 但是,某些客户在没有显式执行 checkout 步骤的情况下使用存储库,例如,当他们使用脚本步骤直接调用 Git 时。 这些客户无法启用令牌限制功能,因为 Azure Pipelines 无法准确确定作业所需的存储库。
通过此更新,我们提供了一种替代方法,让 Azure Pipelines 作业可以在不使用 checkout 步骤的情况下使用存储库。 相反,可以使用新 uses 关键字,如下所示:
resources:
repositories:
- repository: myrepo
type: git
name: MyProject/MyRepo
jobs:
- job: myjob
uses:
repositories:
- myrepo
steps:
# without the preceding "uses" statement, if you have the
# new limit-repositories feature turned on, then Azure Pipelines
# won't include this repo in the access token and you'll
# get an access error at runtime (also, in a real pipeline
# you must include the auth token header as an argument to Git)
- script: git clone https://dev.azure.com/MyOrg/MyProject/_git/MyRepo
此功能还解决了相关的(虽然不太常见的)问题。 如果使用 matrix 关键字生成多个作业,并且这些作业使用矩阵步骤中指定的池,则可能遇到授权这些池用于管道的问题。 根本原因相同:由于矩阵是在运行时计算的,因此前期资源授权系统无法准确确定使用哪些池。 使用 uses时,可以声明作业将使用哪些池,以便提前授权这些池。
jobs:
- job: mtrx
strategy:
matrix:
windows:
mypoolname: Private-Windows
mac:
mypoolname: Private-Mac
pool: $(mypoolname)
# without the following "uses" statement, "pool" won't see
# the pool names until it's too late, and you'll get an error
# at runtime
uses:
pools:
- Private-Windows
- Private-Mac
适合 YAML 管道的手动验证功能
使用新发布的 手动验证 任务,可以暂停 YAML 管道中间阶段。 这样,便可以执行手动或脱机活动,然后恢复(或拒绝)运行。 在想要暂停管道并让对等方在转到长时间运行的计算密集型作业之前验证配置设置、生成包等,这尤其有用。 了解详细信息。
后续步骤
注释
这些功能将在未来两到三周内推出。
请去 Azure DevOps 上看看。
如何提供反馈
我们很乐意听到你对这些功能的看法。 使用帮助菜单报告问题或提供建议。
你还可以在 Stack Overflow 上获取社区的建议和问题解答。