azure - 更改多阶段管道中 1 阶段的存储库
问题描述
我有一个 azure devops 多阶段管道,它需要 1 个阶段将文件从另一个存储库复制到$(build.artifactstagingdirectory)
例如我的 YAML 看起来像
trigger:
- master
resources:
- repo: self
variables:
tag: '$(Build.BuildId)'
stages:
- stage: Build
displayName: Build image
jobs:
- job: Build
...
- stage: Build
... define other resource/repository ...
- task: CopyFiles@2
inputs:
SourceFolder: 'k8s'
Contents: '**'
TargetFolder: '$(build.artifactstagingdirectory)'
此管道连接到存储库,该存储库可能由repo: self
. 所以问题是,我可以为特定阶段更改此存储库吗?
解决方案
您可以在 powershell 脚本中运行 git 命令。在你的阶段添加一个步骤来执行 git 命令,如下例所示。这样,另一个 repo 将被克隆到工件目录。
- powershell: |
cd $(Build.artifactstagingdirectory)
git clone "https://<<Your PAT>>@dev.azure.com/_organization/_project/_git/_repo"
注意:使用您的个人访问令牌 (PAT) 作为身份验证。
推荐阅读
- java - 使用字符串标记器在列表中查找两个特定数字
- julia - how to plot an image on a specific coordinates in the graph using Plots.jl
- three.js - Three.js:解释renderer.info.render 输出
- python - 特征重要性是否会随着 RandomForestRegressor、scikit-learn 中选择的 max_features 的数量而变化?
- python - Paramiko:通过 SFTP 传输文件时 Windows 文件路径出错
- c++ - 无法设置断点以查看错误 C++ ORDERED LIST
- docker - 使用多阶段 Dockerfile 构建时的 COPY 问题——没有这样的文件或目录
- bash - 在 for 循环中打印带有 awk 的列
- visual-studio - Visual Studio 烦人的自动完成 IF 空间 -> #IF
- javascript - execCommand粗体不要在Firefox中切换