将文件从Visual Studio Team Services中的生成服务器提交回存储库 [英] Commit file back to repository from build server in Visual Studio Team Services

查看:76
本文介绍了将文件从Visual Studio Team Services中的生成服务器提交回存储库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用TFS/Visual Studio Team Services(是VS Online)设置持续集成,并且正在使用

I'm currently setting up continuous integration using TFS/Visual Studio Team Services (was VS Online), and I'm using the Team Foundation Build 2015 tasks. So not the XAML builds.

我正在使用它来构建Xamarin Android项目,但是我猜那是很不礼貌的,

I'm using it to build a Xamarin Android project, but that's pretty irreverent I guess,

该过程应如下所示:

  • 签到后:
  • TFS应该下载源代码
  • TFS应该增加AndroidManifest.xml中的版本号
    • 我已经通过为此编写PowerShell脚本来做到这一点.
    • After a check-in:
    • TFS should download the sources
    • TFS should increment the version number within AndroidManifest.xml
      • I've managed to do this by making a PowerShell script for this.

      然后其余的,部署到hockeyapp等

      Then the rest, build deploy into hockeyapp etc

      所有步骤均已配置,但是我在提交部分上苦苦挣扎.如何获得TFS提交文件?我真的看不到任何适合的任务.我尝试使用复制和发布Build Artifacts Utility -但这似乎不起作用,我甚至不确定这是否是正确的实用程序

      The first steps are all configured, but I'm struggling with the commit part. How do I get TFS to commit the file? I don't really see any task suitable for it. I've tried using the Copy and Publish Build Artifacts Utility - But that did not seem to work, and I'm not even sure if that's the right utility

      我正在使用默认的托管构建代理btw.任何帮助将不胜感激

      I'm using the default hosted build agent btw. Any help would be appreciated

      推荐答案

      警告

      我确实要指出,将更改作为构建的一部分进行检查会导致VSTS/TFS的某些功能无法正常工作.工作项与签入,源和符号生成的关联,从更改到构建的易处理性以及与Test Manager的集成和集成,远程调试,可能不会产生预期的结果,因为在te版本中记录的Changeset/commit可能与实际不匹配资料来源.这可能会导致意外的有趣行为.

      Warning

      I do want to point out that checking in changes as part of the build can lead to some features of VSTS/TFS not working. Association of work items to the checkin, sources and symbol generation, tractability from changes to build to release and integration with Test Manager, remote debugging, will likely not yield the expected results because the Changeset/commit recorded in te build may not match the actual sources. This may lead to unexpected funny behavior.

      此外,如果在构建开始后已经提交/签入任何新更改,则可能会在Source Control中针对该版本下未实际发布的代码更新版本号.

      Also, if any new changes have already been committed/checked-in after the build has started, the version number may be updated in Source Control for code that was not actually released under that version.

      因此:首先,从构建过程中更改源被认为是不好的做法.

      有更好的方法,一种是使用构建版本(Build_BuildNumber或Build_BuildID变量).或者,您可以使用任务(如GitVersion)来生成基于分支的语义版本并在您的git仓库中标记.这样一来,您的构建将生成正确的版本号,并在多次构建相同源的情况下增加版本.

      There are better ways of doing it, one is to use the build version (Build_BuildNumber or Build_BuildID variables). Alternatively you an use a task like GitVersion to generate the semantic version based on the branch and tag in your git repository. That way your build will generate the correct version number and will increment the revision in case the same sources are built multiple times.

      如果这些都不适合您,并且您仍想在构建过程中检入更改,则可以使用 Git构建工具将远程添加到本地存储库,然后使用git命令行工具提交并将更改推回存储库

      If these things don't work for you and you still want to check in the changes as part of the build, you can either use the TFVC Build Tasks if you're using TFVC or use the Git Build Tools to add the remote to the local repository and then use the git commandline tools to commit and push the changes back to the repository.

      这些扩展要求安装TFS Update 2.但是您可以使用tfx commandlien工具推送各个构建任务. 对于TFVC任务,此处介绍了该过程

      These extensions require TFS Update 2 to install. But you can push the individual build tasks using the tfx commandlien tool. For the TFVC tasks the process is explained here.

      在Mac上

      在Mac上,由于使用TFVC,这将变得更加困难.我的TFVC任务利用TFS客户端对象模型和Powershell与TFS服务器进行通信.在构建环境中,tf.exe工具甚至无法在Windows上运行,这就是为什么我需要直接调用VersionControlServer对象的原因.由于我依赖于这些技术,因此这些任务将无法在Mac或Linux代理上运行.

      On the mac it's going to be harder since you're using TFVC. My TFVC tasks leverage the TFS Client Object Model and Powershell to communicate to the TFS Server. The tf.exe tool doesn't even work on windows when you're in the context of a build, which is why I need to call into the VersionControlServer object directly. Given I'm dependent on these technologies, the tasks won't run on a Mac or Linux agent.

      您可以尝试查看 Team Explorer Explorer Everywhere X-平台命令行可从构建代理(使用Shell脚本)运行.我无法在实际的Mac上进行测试.

      You could try to see whether the Team explorer Everywhere X-platform commandline works from the build agent (using a shell script). I have no way to test this on an actual Mac.

      考虑到您项目的跨平台性质,我建议移至Git,它已集成到XCode和Android Studio中,可以更轻松地执行本机UI或在本机库之上构建.

      Given the cross platform nature of your project I'd recommend to move to Git, it integrates into XCode and Android Studio, making it easier to do a native UI or build on top of native libraries.

      替代2

      您可以设置一个构建,对代码进行必要的更改,然后检入修改后的代码.然后,使用修改后的代码运行一个(CI)构建来运行Android和Mac构建.

      You could setup a build which does the required changes to the code and then checks in the modified code. Then have a (CI) build run the Android and the Mac builds using the modified code.

      这篇关于将文件从Visual Studio Team Services中的生成服务器提交回存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆