3

I have been playing around with TeamCity to get a CI environment up and running.

I started by following Troy Hunt's 'You're deploying wrong', which was very useful, however I wanted to split the packaging and deployment into 2 seperate steps, for the following reasons:

  1. I wanted to pass some additional flags to msdeploy, which isnt possible (to m,y knowledge) by using the MSBuild Package and Deploy that Troy describes.
  2. I can easily disable the Second Build Step i.e. deployment, if I ever need to build the package but not deploy it.
  3. I wanted to use the -skip flag on msdeploy to prevent it from deleting certain folders, which again I couldn't find any method of doing without passing as an argument to the command line.

So, in my first MSBuild step I just have the parameters:

/P:Configuration=%env.Configuration%
/P:VisualStudioVersion=11.0
/P:IgnoreDeployManagedRuntimeVersion=True

And then I have a second Build Step that uses a command line build runner to execute the following msdeploy command:

"C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe" -verb:sync       -source:package="C:\ProgramData\JetBrains\TeamCity\system\artifacts\MyProject\%system.teamcity.buildConfName%\%teamcity.build.id%\MyProject.Web.csproj.zip"   -dest:auto,ComputerName='https://devserver:8172/msdeploy.axd?site=MyWebsite',UserName='domain\username',Password='password',IncludeAcls='False',AuthType='Basic' -skip:objectName=dirPath,absolutePath=media$ -disableLink:AppPoolExtension -disableLink:ContentExtension   -disableLink:CertificateExtension -retryAttempts=2 -allowuntrusted

The problem with this is that apparently TeamCity doesnt publish the artifacts until all the build steps are complete, so therefore the Command Line process fails because the package zip file doesnt actually exist at that point.

I have read something about publishing artifacts whilst the Build is still in progress but that does seem like a bit of a hack.

Any advice would be greatly appreciated.

4

1 回答 1

8

你最好有两个构建而不是两个构建步骤。

第一个(构建 A)将有一个构建步骤来进行构建,然后第二个(构建 B)将使用第一个构建步骤中的一个构建步骤进行部署。

因此,在构建 A 的第一个配置选项卡下,您将指定需要从第一个构建中获得的工件。然后,您可以运行构建并确认在 artifacts 部分下您需要的所有内容都可用。(这些将在构建 A 完成运行时显示)。

然后在构建 B 的依赖项部分(不记得确切的名称,并且我离开了我的 TC 实例)下,您可以将其设置为使用构建 A 的工件,然后将其用于部署。

完成所有工作后,您可以添加一个构建触发器以在构建 A 成功执行后运行构建 B,然后如果您有一次只想运行构建 A,请禁用构建 B 上的触发器或暂停构建 B将阻止触发器触发的配置。

于 2013-12-01T19:32:45.130 回答