gpt4 book ai didi

azure - 是否可以将构建工件从管道复制到存储库中

转载 作者:行者123 更新时间:2023-12-02 23:37:16 25 4
gpt4 key购买 nike

我正在尝试将我发布的 zip 版本复制到我的 azure 存储库中以便于访问。我有以下 YML 代码。请参阅我的问题的内嵌评论:

- task: ArchiveFiles@2
inputs:
rootFolderOrFile: '$(build.artifactstagingdirectory)\MyFolder'
includeRootFolder: true
archiveType: 'zip'
archiveFile: '$(Build.ArtifactStagingDirectory)\zipfolder/$(Build.BuildId).zip'
replaceExistingArchive: true

- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: drop'
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)\zipfolder'
TargetPath: '$(Build.SourcesDirectory)\MyFolder' // Here I would expect the code to copy the zip into my repo.

免责声明:这通常不是一个好主意,在大多数情况下从工件提要中获取工件要好得多!

最佳答案

您可以下载该工件并在命令行任务中使用 git 命令将其推送到存储库,引用下面的示例,它对我有用。

# 'Allow scripts to access the OAuth token' was selected in pipeline.  Add the following YAML to any steps requiring access:
# env:
# MY_ACCESS_TOKEN: $(System.AccessToken)
# Variable Group 'vargroup1' was defined in the Variables tab
resources:
repositories:
- repository: self
type: git
ref: refs/heads/testb2
jobs:
- job: Job_1
displayName: Agent job 1
pool:
vmImage: ubuntu-20.04
steps:
- checkout: self
persistCredentials: True
- task: ArchiveFiles@2
displayName: Archive README.md
inputs:
rootFolderOrFile: README.md
archiveFile: $(Build.ArtifactStagingDirectory)\zipfolder/$(Build.BuildId).zip
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: drop'
inputs:
PathtoPublish: $(Build.ArtifactStagingDirectory)\zipfolder
- task: DownloadBuildArtifacts@1
displayName: Download Build Artifacts
inputs:
artifactName: drop
- task: CmdLine@2
displayName: Command Line Script
inputs:
script: >-
cd $(System.ArtifactsDirectory)\zipfolder

git config --global user.email "xxxxx"

git config --global user.name "xxxxx"

git init

git add .

git commit -m "123"

git remote add origin https://$(System.AccessToken)@dev.azure.com/orgname/testpro1/_git/testpro4

git push https://$(System.AccessToken)@dev.azure.com/orgname/testpro1/_git/testpro4
...

enter image description here

enter image description here

关于azure - 是否可以将构建工件从管道复制到存储库中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69270012/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com