Commit a file to remote github repo through Azure DevOps

爷,独闯天下 提交于 2021-02-05 11:48:24

问题


A build definition in Azure DevOps generates a .ipa file(iOS app file). I want to push this .ipa file generated by Azure DevOps build, directly into a remote GitHub Repository.


回答1:


A build definition in Azure DevOps generates a .ipa file(iOS app file). I want to push this .ipa file generated by Azure DevOps build, directly into a remote GitHub Repository.

It's not recommended to add build output into Source Control. If you have special reason to do this, you can run git commands in Command-line task or Powershell Task to do the commit and push.

My steps to get it work(I use Microsoft windows-hosted agent with one public github repos):

1.Check the log of build task to get the path of Test.txt file

2.Add one Command-Line task after last build task with content similar to this:

git clone https://github.com/xxx/TestUpload.git

git config --global user.email xxx@outlook.com

git config --global user.name xxx

copy "D:\a\1\s\xxx\Test.txt" TestUpload

cd TestUpload

git add .

git commit -m "Do sth."

git push https://UserName:UserPassword@github.com/xxx/TestUpload.git master

For more details about git push you can check this. And since I run the pipeline in windows-hosted agent, so I need to git clone the remote repos first.

Also, I'm not sure if you're running that in Mac OS agent, if so, the command-line task is still available for you. But you may need to replace the copy xxx and cd xxx in script with bash syntax in MacOS.

Other directions:

If what you actually need is to download the output xx.ipa file. Consider using Publish Build Artifacts task, you can use this task to copy the build output and zip that into one xx.zip file. After the build pipeline succeeds, you can download it from Summary:

If what you want is to have one place to store your file for a long time. Consider using Azure Artifacts, you can use Universal Package to host the file. It's convenient to publish/download the package to/from feed in local machine or in cloud build pipeline.

Hope all above helps and if I misunderstand anything, feel free to let me know it:)



来源:https://stackoverflow.com/questions/59845915/commit-a-file-to-remote-github-repo-through-azure-devops

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!