将文件从CI管道复制到Azure Devops存储库

时间:2020-02-28 15:59:57

标签: azure-devops azure-pipelines

我正在创建管道,并希望在管道中处理完之后将文件复制到Azure devops存储库中。 我使用cURL按照以下设置进行复制。但仍然无法复制。

我可以使用什么工作来复制文件?

Setting of cURL

3 个答案:

答案 0 :(得分:0)

此上传的用例是什么? Azure存储库用于代码存储而非数据存储。 您可以将文件作为工件发布,并且可以使用其他管道。

如果出于存储目的,我建议使用天蓝色斑点存储或其他方式

答案 1 :(得分:0)

将文件从CI管道复制到Azure Devops存储库

如果您的仓库是git repo,则可以使用git命令行来提交并将文件推回仓库。

详细信息:

在管道中添加命令行任务以使用git命令行克隆存储库:

git config --global user.email "xxx@xyz.com"
git config --global user.name "Admin"

git clone <repo> <directory>

我们使用复制任务将docs.zip文件复制到<directory>文件夹中。

然后添加命令行任务以提交更改并将更改推送到存储库:

git commit -m "Add docs.zip file"

git push -u origin master

注意:使用git clone克隆存储库时,需要在源链接中提供证书,通常使用PAT:

enter image description here

链接看起来像:

https://<OrganizationName>@dev.azure.com/<OrganizationName>/MyTestProject/_git/TestSample

然后,我们需要用PAT替换第一个OrganizationName。因此,它将是:

https://<PAT>@dev.azure.com/<OrganizationName>/MyTestProject/_git/TestSample

希望这会有所帮助。

答案 2 :(得分:0)

@Leo Liu-MSFT 谢谢您,先生。 我用了这张纸条就跑了。

git config --global user.email "yourname@email.com"
git config --global user.name "yourname"

git status

git checkout xxxbranch


git add $(Build.SourcesDirectory)/doc/Jsdoc.zip 
$(Build.SourcesDirectory)/doc/coverage.zip


git status

git commit -m "Latest JsDoc Version"

git push origin xxxbranch
相关问题