如何获取上次成功构建的版本号?

编程入门 行业动态 更新时间:2024-10-09 06:28:27
本文介绍了如何获取上次成功构建的版本号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

背景

我有一个第三方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:

  • 调用 http:// localhost / httpAuth / app / rest / builds /?locator = buildType:Development,count:1,status:SUCCESS
  • 使用内部版本步骤1的响应ID来调用 http://本地主机/ httpAuth / app / rest / builds / id:[build-id] / resulting-properties
  • 从fol检索值在步骤2的响应中降低节点,<属性名称= maven.project.version value = 1.2.3 /> 。
  • Call localhost/httpAuth/app/rest/builds/?locator=buildType:Development,count:1,status:SUCCESS
  • Use build id in response from step 1 to call localhost/httpAuth/app/rest/builds/id:[build-id]/resulting-properties
  • Retrieve value from the following node in the response from step 2, <property name="maven.project.version" value="1.2.3"/>.
  • 问题

    有没有比使用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

    更多推荐

    如何获取上次成功构建的版本号?

    本文发布于:2023-11-12 02:15:12,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1580216.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:版本号

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!