背景
我有一个第三方Web服务,其中包含用于安装和卸载工件的方法。在安装和卸载时,都指定了一个名为package-%maven.project.version%.zip的工件。在安装新软件包之前,我需要卸载以前安装的软件包。
I have a third-party web service with methods for installing and uninstalling an artifact. Both when installing and uninstalling, you specify an artifact named package-%maven.project.version%.zip. Before installing a new package, I need to uninstall the previously installed package.
解决方案
我发现了这个解决方案,但这是实现连续部署的最后一步,因此我需要一些东西
I found this solution, but as this is the final step to achieve continuous deployment, I need something automated and not a prompt.
另一个可以通过构建步骤自动化的解决方案是利用TeamCity REST API:
Another solution that can be automated by a build step is to make use of the TeamCity REST API:
问题
有没有比使用TeamCity更简单的方法REST API?
Is there a simpler way than using the TeamCity REST API?
推荐答案因此,我决定从PowerShell构建步骤中使用TeamCity REST API来检索%maven.project.version%来自最近一次成功的构建:
So, I decided on using the TeamCity REST API from a PowerShell build step to retrieve %maven.project.version% from the last successful build:
$client = New-Object System.Net.WebClient $client.Credentials = New-Object System.Net.NetworkCredential $username, $password $latestBuildUrl = "localhost/httpAuth/app/rest/builds/?locator=buildType:Development,count:1,status:SUCCESS" [xml]$latestBuild = $client.DownloadString($latestBuildUrl) $latestBuildId = $latestBuild.builds.build.id $propertiesUrl = "localhost/httpAuth/app/rest/builds/id:$latestBuildId/resulting-properties" [xml]$properties = $client.DownloadString($propertiesUrl) $mavenProjectVersion = $properties.SelectSingleNode("//property[@name='maven.project.version']").value更多推荐
如何获取上次成功构建的版本号?
发布评论