Azure DevOps 管道:参考旧版本存储库
Azure DevOps pipelines: refer to old version repository
可以从阶段中的特定哈希引用回购协议吗?
例如:作为参数,我给出了提交的哈希值,并且由于这个参数,我可以在 'build'.
阶段使用特定版本存储库中的存储库文件夹
不,这是不可能的,因为有两个原因需要使用开箱即用的工具来做到这一点。
一个资源库不允许传递特定的提交:
resources:
repositories:
- repository: string # identifier (A-Z, a-z, 0-9, and underscore)
type: enum # see the following "Type" topic
name: string # repository name (format depends on `type`)
ref: string # ref name to use; defaults to 'refs/heads/master'
endpoint: string # name of the service connection to use (for types that aren't Azure Repos)
trigger: # CI trigger for this repository, no CI trigger if skipped (only works for Azure Repos)
branches:
include: [ string ] # branch names which will trigger a build
exclude: [ string ] # branch names which will not
tags:
include: [ string ] # tag names which will trigger a build
exclude: [ string ] # tag names which will not
paths:
include: [ string ] # file paths which must match to trigger a build
exclude: [ string ] # file paths which will not trigger a build
第二个目前您不能在资源范围内使用模板语法。而使用运行时参数就是模板表达式的一个例子。
所以要做到这一点你应该设置
- checkout: none
阻止获取源代码然后使用命令行自行处理。通过这种方式,您应该能够使用运行时参数来执行此操作(并将您的提交 sha 作为参数传递)。
你可以看看here
同意 Krzysztof Madej 的观点。
在 azure devops 中,没有 out-of-the-box 方法可以通过 Commit Sha 指定特定版本的 repo。
但是你可以通过git命令实现。
因为你已经有一个commit sha,你可以运行 git reset --hard
with Command Line Task。然后源码回滚到对应版本
示例如下:
cd $(build.sourcesdirectory)
git reset --hard $commithash
经典管道
Yaml 管道:
steps:
- task: CmdLine@2
inputs:
script: |
cd $(build.sourcesdirectory)
git reset --hard Commitsha
在Azure Pipeline中,默认的checkout步骤相当于git clone,它会包含提交历史,所以你可以直接使用git命令来回滚repo版本而不用禁用(- checkout: none
) 结帐步骤。这样会更方便
可以从阶段中的特定哈希引用回购协议吗? 例如:作为参数,我给出了提交的哈希值,并且由于这个参数,我可以在 'build'.
阶段使用特定版本存储库中的存储库文件夹不,这是不可能的,因为有两个原因需要使用开箱即用的工具来做到这一点。
一个资源库不允许传递特定的提交:
resources:
repositories:
- repository: string # identifier (A-Z, a-z, 0-9, and underscore)
type: enum # see the following "Type" topic
name: string # repository name (format depends on `type`)
ref: string # ref name to use; defaults to 'refs/heads/master'
endpoint: string # name of the service connection to use (for types that aren't Azure Repos)
trigger: # CI trigger for this repository, no CI trigger if skipped (only works for Azure Repos)
branches:
include: [ string ] # branch names which will trigger a build
exclude: [ string ] # branch names which will not
tags:
include: [ string ] # tag names which will trigger a build
exclude: [ string ] # tag names which will not
paths:
include: [ string ] # file paths which must match to trigger a build
exclude: [ string ] # file paths which will not trigger a build
第二个目前您不能在资源范围内使用模板语法。而使用运行时参数就是模板表达式的一个例子。
所以要做到这一点你应该设置
- checkout: none
阻止获取源代码然后使用命令行自行处理。通过这种方式,您应该能够使用运行时参数来执行此操作(并将您的提交 sha 作为参数传递)。
你可以看看here
同意 Krzysztof Madej 的观点。
在 azure devops 中,没有 out-of-the-box 方法可以通过 Commit Sha 指定特定版本的 repo。
但是你可以通过git命令实现。
因为你已经有一个commit sha,你可以运行 git reset --hard
with Command Line Task。然后源码回滚到对应版本
示例如下:
cd $(build.sourcesdirectory)
git reset --hard $commithash
经典管道
Yaml 管道:
steps:
- task: CmdLine@2
inputs:
script: |
cd $(build.sourcesdirectory)
git reset --hard Commitsha
在Azure Pipeline中,默认的checkout步骤相当于git clone,它会包含提交历史,所以你可以直接使用git命令来回滚repo版本而不用禁用(- checkout: none
) 结帐步骤。这样会更方便