Azure DevOps YAML Pipelines - 他们可以从存储库中提取脚本吗?
Azure DevOps YAML Pipelines - can they pull a script from a repo?
在我发布的图形版本中,我正在连接到一个 "Azure Repo" 以从中提取脚本,而不是 BUILD 工件
这可以在 YAML 管道中完成吗?目前还不是很清楚,先谢谢了
repo 中有很多脚本,因此不需要构建或打包为 zip/drop 包。
是的,对不起,我的错。是的,有可能。正在关注 doc
如果您的管道在另一个存储库中有模板,或者如果您想对需要服务连接的存储库使用多存储库检出,则必须让系统知道该存储库。 repository 关键字可让您指定外部存储库。
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)
资源是作为管道的一部分使用的任何外部服务。资源的一个示例是另一个 CI/CD 管道,它产生:
resources:
pipelines: [ pipeline ]
repositories: [ repository ]
containers: [ container ]
- Azure Pipelines 或 Jenkins 等工件。
- 代码存储库,例如 GitHub、Azure Repos 或 Git。
- 容器映像注册表,例如 Azure 容器注册表或 Docker
枢纽。
YAML 中的资源表示管道、容器、存储库和类型的来源。有关资源的更多信息,请参阅 here。
@Hugh Lin - MSFT
@Krzysztof Madej
我的 Azure DevOps GIT 存储库称为 "AZDO_Scripts"(同一个项目的所有部分)并且具有这样的结构...
/Scripts/AzureCLI/ResourceGroup/Provision_ResourceGroup_withTags.ps1
我的YAML现在是这样的...
name: $(date:yyyyMMdd)$(rev:.r)-$(SourceBranchName)
trigger:
- master
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
resources:
repositories:
- repository: commonscripts
type: git
name: AZDO_Scripts
stages:
- stage: Test
variables:
- name: resourcegroup
value: 'rg-testthescript'
- name: location
value: 'WestEurope'
- name: environmenttag
value: 'Test'
jobs:
- job : TestJob
pool:
vmImage: 'windows-latest'
steps:
- task: AzureCLI@2
inputs:
azureSubscription: 'My-Azure-Sub-ServiceConnection'
scriptType: 'ps'
scriptLocation: 'scriptPath'
scriptPath: 'Scripts/AzureCLI/ResourceGroup/Provision_ResourceGroup_withTags.ps1@commonscripts'
arguments: '-resourcegroup $(resourcegroup) -location $(location) -environmenttag $(environmenttag)'
我需要在 scriptPath: 语句中做什么才能引用该脚本? (倒数第二行)
scriptPath: 'Scripts/AzureCLI/ResourceGroup/Provision_ResourceGroup_withTags.ps1@commonscripts'
在我发布的图形版本中,我正在连接到一个 "Azure Repo" 以从中提取脚本,而不是 BUILD 工件
这可以在 YAML 管道中完成吗?目前还不是很清楚,先谢谢了
repo 中有很多脚本,因此不需要构建或打包为 zip/drop 包。
是的,对不起,我的错。是的,有可能。正在关注 doc
如果您的管道在另一个存储库中有模板,或者如果您想对需要服务连接的存储库使用多存储库检出,则必须让系统知道该存储库。 repository 关键字可让您指定外部存储库。
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)
资源是作为管道的一部分使用的任何外部服务。资源的一个示例是另一个 CI/CD 管道,它产生:
resources:
pipelines: [ pipeline ]
repositories: [ repository ]
containers: [ container ]
- Azure Pipelines 或 Jenkins 等工件。
- 代码存储库,例如 GitHub、Azure Repos 或 Git。
- 容器映像注册表,例如 Azure 容器注册表或 Docker 枢纽。
YAML 中的资源表示管道、容器、存储库和类型的来源。有关资源的更多信息,请参阅 here。
@Hugh Lin - MSFT @Krzysztof Madej
我的 Azure DevOps GIT 存储库称为 "AZDO_Scripts"(同一个项目的所有部分)并且具有这样的结构...
/Scripts/AzureCLI/ResourceGroup/Provision_ResourceGroup_withTags.ps1
我的YAML现在是这样的...
name: $(date:yyyyMMdd)$(rev:.r)-$(SourceBranchName)
trigger:
- master
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
resources:
repositories:
- repository: commonscripts
type: git
name: AZDO_Scripts
stages:
- stage: Test
variables:
- name: resourcegroup
value: 'rg-testthescript'
- name: location
value: 'WestEurope'
- name: environmenttag
value: 'Test'
jobs:
- job : TestJob
pool:
vmImage: 'windows-latest'
steps:
- task: AzureCLI@2
inputs:
azureSubscription: 'My-Azure-Sub-ServiceConnection'
scriptType: 'ps'
scriptLocation: 'scriptPath'
scriptPath: 'Scripts/AzureCLI/ResourceGroup/Provision_ResourceGroup_withTags.ps1@commonscripts'
arguments: '-resourcegroup $(resourcegroup) -location $(location) -environmenttag $(environmenttag)'
我需要在 scriptPath: 语句中做什么才能引用该脚本? (倒数第二行)
scriptPath: 'Scripts/AzureCLI/ResourceGroup/Provision_ResourceGroup_withTags.ps1@commonscripts'